diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp index 8b4e1bf9a..6b49706ea 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry.hpp @@ -24,23 +24,23 @@ namespace ams::ddsf { NON_COPYABLE(DeviceCodeEntry); NON_MOVEABLE(DeviceCodeEntry); private: - ams::DeviceCode device_code = ams::InvalidDeviceCode; - IDevice *device = nullptr; + ams::DeviceCode m_device_code = ams::InvalidDeviceCode; + IDevice *m_device = nullptr; public: - constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : device_code(dc), device(dev) { + constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : m_device_code(dc), m_device(dev) { AMS_ASSERT(dev != nullptr); } constexpr ams::DeviceCode GetDeviceCode() const { - return this->device_code; + return m_device_code; } constexpr IDevice &GetDevice() { - return *this->device; + return *m_device; } constexpr const IDevice &GetDevice() const { - return *this->device; + return *m_device; } }; @@ -48,15 +48,15 @@ namespace ams::ddsf { NON_COPYABLE(DeviceCodeEntryHolder); NON_MOVEABLE(DeviceCodeEntryHolder); private: - util::IntrusiveListNode list_node; - util::TypedStorage entry_storage; - bool is_constructed; + util::IntrusiveListNode m_list_node; + util::TypedStorage m_entry_storage; + bool m_is_constructed; public: - using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>; + using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>; using List = typename ListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; public: - DeviceCodeEntryHolder() : list_node(), entry_storage(), is_constructed(false) { + DeviceCodeEntryHolder() : m_list_node(), m_entry_storage(), m_is_constructed(false) { /* ... */ } @@ -75,34 +75,34 @@ namespace ams::ddsf { } bool IsLinkedToList() const { - return this->list_node.IsLinked(); + return m_list_node.IsLinked(); } DeviceCodeEntry &Construct(DeviceCode dc, IDevice *dev) { AMS_ASSERT(!this->IsConstructed()); - DeviceCodeEntry *entry = util::ConstructAt(this->entry_storage, dc, dev); - this->is_constructed = true; + DeviceCodeEntry *entry = util::ConstructAt(m_entry_storage, dc, dev); + m_is_constructed = true; return *entry; } bool IsConstructed() const { - return this->is_constructed; + return m_is_constructed; } void Destroy() { AMS_ASSERT(this->IsConstructed()); - util::DestroyAt(this->entry_storage); - this->is_constructed = false; + util::DestroyAt(m_entry_storage); + m_is_constructed = false; } DeviceCodeEntry &Get() { AMS_ASSERT(this->IsConstructed()); - return GetReference(this->entry_storage); + return GetReference(m_entry_storage); } const DeviceCodeEntry &Get() const { AMS_ASSERT(this->IsConstructed()); - return GetReference(this->entry_storage); + return GetReference(m_entry_storage); } }; static_assert(DeviceCodeEntryHolder::ListTraits::IsValid()); diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry_manager.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry_manager.hpp index 607872458..204f952cf 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_device_code_entry_manager.hpp @@ -25,33 +25,33 @@ namespace ams::ddsf { class DeviceCodeEntryManager { private: - ams::MemoryResource *memory_resource; - ddsf::DeviceCodeEntryHolder::List entry_list; - mutable os::SdkMutex entry_list_lock; + ams::MemoryResource *m_memory_resource; + ddsf::DeviceCodeEntryHolder::List m_entry_list; + mutable os::SdkMutex m_entry_list_lock; private: void DestroyAllEntries() { - auto it = this->entry_list.begin(); - while (it != this->entry_list.end()) { + auto it = m_entry_list.begin(); + while (it != m_entry_list.end()) { ddsf::DeviceCodeEntryHolder *entry = std::addressof(*it); - it = this->entry_list.erase(it); + it = m_entry_list.erase(it); AMS_ASSERT(entry->IsConstructed()); if (entry->IsConstructed()) { entry->Destroy(); } - this->memory_resource->Deallocate(entry, sizeof(*entry)); + m_memory_resource->Deallocate(entry, sizeof(*entry)); } } public: - DeviceCodeEntryManager(ams::MemoryResource *mr) : memory_resource(mr), entry_list(), entry_list_lock() { /* ... */ } + DeviceCodeEntryManager(ams::MemoryResource *mr) : m_memory_resource(mr), m_entry_list(), m_entry_list_lock() { /* ... */ } ~DeviceCodeEntryManager() { this->DestroyAllEntries(); } void Reset() { - std::scoped_lock lk(this->entry_list_lock); + std::scoped_lock lk(m_entry_list_lock); this->DestroyAllEntries(); } @@ -66,7 +66,7 @@ namespace ams::ddsf { template int ForEachEntry(F f) { - return impl::ForEach(this->entry_list_lock, this->entry_list, [&](DeviceCodeEntryHolder &holder) -> bool { + return impl::ForEach(m_entry_list_lock, m_entry_list, [&](DeviceCodeEntryHolder &holder) -> bool { AMS_ASSERT(holder.IsConstructed()); return f(holder.Get()); }); @@ -74,7 +74,7 @@ namespace ams::ddsf { template int ForEachEntry(F f) const { - return impl::ForEach(this->entry_list_lock, this->entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool { + return impl::ForEach(m_entry_list_lock, m_entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool { AMS_ASSERT(holder.IsConstructed()); return f(holder.Get()); }); diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_event_handler_manager.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_event_handler_manager.hpp index 7fcbfd2ab..6ecac9988 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_event_handler_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_event_handler_manager.hpp @@ -28,41 +28,41 @@ namespace ams::ddsf { private: struct LoopControlCommandParameters; private: - bool is_initialized; - bool is_looping; - os::SdkConditionVariable is_looping_cv; - os::MultiWaitType multi_wait; - os::ThreadType *loop_thread; - os::Event loop_control_event; - os::MultiWaitHolderType loop_control_event_holder; - LoopControlCommandParameters *loop_control_command_params; - os::LightEvent loop_control_command_done_event; - os::SdkMutex loop_control_lock; + bool m_is_initialized; + bool m_is_looping; + os::SdkConditionVariable m_is_looping_cv; + os::MultiWaitType m_multi_wait; + os::ThreadType *m_loop_thread; + os::Event m_loop_control_event; + os::MultiWaitHolderType m_loop_control_event_holder; + LoopControlCommandParameters *m_loop_control_command_params; + os::LightEvent m_loop_control_command_done_event; + os::SdkMutex m_loop_control_lock; private: void ProcessControlCommand(LoopControlCommandParameters *params); void ProcessControlCommandImpl(LoopControlCommandParameters *params); public: EventHandlerManager() - : is_initialized(false), is_looping(false), is_looping_cv(), multi_wait(), - loop_thread(), loop_control_event(os::EventClearMode_AutoClear), loop_control_event_holder(), - loop_control_command_params(), loop_control_command_done_event(os::EventClearMode_AutoClear), - loop_control_lock() + : m_is_initialized(false), m_is_looping(false), m_is_looping_cv(), m_multi_wait(), + m_loop_thread(), m_loop_control_event(os::EventClearMode_AutoClear), m_loop_control_event_holder(), + m_loop_control_command_params(), m_loop_control_command_done_event(os::EventClearMode_AutoClear), + m_loop_control_lock() { this->Initialize(); } ~EventHandlerManager() { - if (this->is_looping) { + if (m_is_looping) { AMS_ASSERT(!this->IsRunningOnLoopThread()); this->RequestStop(); } - if (this->is_initialized) { + if (m_is_initialized) { this->Finalize(); } } - bool IsRunningOnLoopThread() const { return this->loop_thread == os::GetCurrentThread(); } - bool IsLooping() const { return this->is_looping; } + bool IsRunningOnLoopThread() const { return m_loop_thread == os::GetCurrentThread(); } + bool IsLooping() const { return m_is_looping; } void Initialize(); void Finalize(); diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp index 95da6551b..1eeb99775 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_device.hpp @@ -32,57 +32,57 @@ namespace ams::ddsf { public: AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice); private: - util::IntrusiveListNode list_node; - IDriver *driver; - ISession::List session_list; - mutable os::SdkMutex session_list_lock; - bool is_exclusive_write; + util::IntrusiveListNode m_list_node; + IDriver *m_driver; + ISession::List m_session_list; + mutable os::SdkMutex m_session_list_lock; + bool m_is_exclusive_write; public: - using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>; + using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>; using List = typename ListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; private: Result AttachSession(ISession *session) { AMS_ASSERT(session != nullptr); - std::scoped_lock lk(this->session_list_lock); + std::scoped_lock lk(m_session_list_lock); /* Check if we're allowed to attach the session. */ - if (this->is_exclusive_write && session->CheckExclusiveWrite()) { - for (const auto &attached : this->session_list) { + if (m_is_exclusive_write && session->CheckExclusiveWrite()) { + for (const auto &attached : m_session_list) { R_UNLESS(!attached.CheckAccess(AccessMode_Write), ddsf::ResultAccessModeDenied()); } } /* Attach the session. */ - this->session_list.push_back(*session); + m_session_list.push_back(*session); return ResultSuccess(); } void DetachSession(ISession *session) { AMS_ASSERT(session != nullptr); - std::scoped_lock lk(this->session_list_lock); - this->session_list.erase(this->session_list.iterator_to(*session)); + std::scoped_lock lk(m_session_list_lock); + m_session_list.erase(m_session_list.iterator_to(*session)); } void AttachDriver(IDriver *drv) { AMS_ASSERT(drv != nullptr); AMS_ASSERT(!this->IsDriverAttached()); - this->driver = drv; + m_driver = drv; AMS_ASSERT(this->IsDriverAttached()); } void DetachDriver() { AMS_ASSERT(this->IsDriverAttached()); - this->driver = nullptr; + m_driver = nullptr; AMS_ASSERT(!this->IsDriverAttached()); } public: - IDevice(bool exclusive_write) : list_node(), driver(nullptr), session_list(), session_list_lock(), is_exclusive_write(exclusive_write) { - this->session_list.clear(); + IDevice(bool exclusive_write) : m_list_node(), m_driver(nullptr), m_session_list(), m_session_list_lock(), m_is_exclusive_write(exclusive_write) { + m_session_list.clear(); } protected: ~IDevice() { - this->session_list.clear(); + m_session_list.clear(); } public: void AddTo(List &list) { @@ -94,45 +94,45 @@ namespace ams::ddsf { } bool IsLinkedToList() const { - return this->list_node.IsLinked(); + return m_list_node.IsLinked(); } IDriver &GetDriver() { AMS_ASSERT(this->IsDriverAttached()); - return *this->driver; + return *m_driver; } const IDriver &GetDriver() const { AMS_ASSERT(this->IsDriverAttached()); - return *this->driver; + return *m_driver; } bool IsDriverAttached() const { - return this->driver != nullptr; + return m_driver != nullptr; } template Result ForEachSession(F f, bool return_on_fail) { - return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail); + return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail); } template Result ForEachSession(F f, bool return_on_fail) const { - return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail); + return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail); } template int ForEachSession(F f) { - return impl::ForEach(this->session_list_lock, this->session_list, f); + return impl::ForEach(m_session_list_lock, m_session_list, f); } template int ForEachSession(F f) const { - return impl::ForEach(this->session_list_lock, this->session_list, f); + return impl::ForEach(m_session_list_lock, m_session_list, f); } bool HasAnyOpenSession() const { - return !this->session_list.empty(); + return !m_session_list.empty(); } }; static_assert(IDevice::ListTraits::IsValid()); diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp index b27ddbdbd..f1feef57a 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_driver.hpp @@ -27,21 +27,21 @@ namespace ams::ddsf { public: AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDriver); private: - util::IntrusiveListNode list_node; - IDevice::List device_list; - mutable os::SdkMutex device_list_lock; + util::IntrusiveListNode m_list_node; + IDevice::List m_device_list; + mutable os::SdkMutex m_device_list_lock; public: - using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::list_node>; + using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::m_list_node>; using List = typename ListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; private: public: - IDriver() : list_node(), device_list(), device_list_lock() { - this->device_list.clear(); + IDriver() : m_list_node(), m_device_list(), m_device_list_lock() { + m_device_list.clear(); } protected: ~IDriver() { - this->device_list.clear(); + m_device_list.clear(); } public: void AddTo(List &list) { @@ -53,45 +53,45 @@ namespace ams::ddsf { } bool IsLinkedToList() const { - return this->list_node.IsLinked(); + return m_list_node.IsLinked(); } bool HasAnyDevice() const { - return !this->device_list.empty(); + return !m_device_list.empty(); } void RegisterDevice(IDevice *dev) { AMS_ASSERT(dev != nullptr); - std::scoped_lock lk(this->device_list_lock); + std::scoped_lock lk(m_device_list_lock); dev->AttachDriver(this); - this->device_list.push_back(*dev); + m_device_list.push_back(*dev); } void UnregisterDevice(IDevice *dev) { AMS_ASSERT(dev != nullptr); - std::scoped_lock lk(this->device_list_lock); - this->device_list.erase(this->device_list.iterator_to(*dev)); + std::scoped_lock lk(m_device_list_lock); + m_device_list.erase(m_device_list.iterator_to(*dev)); dev->DetachDriver(); } template Result ForEachDevice(F f, bool return_on_fail) { - return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail); + return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail); } template Result ForEachDevice(F f, bool return_on_fail) const { - return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail); + return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail); } template int ForEachDevice(F f) { - return impl::ForEach(this->device_list_lock, this->device_list, f); + return impl::ForEach(m_device_list_lock, m_device_list, f); } template int ForEachDevice(F f) const { - return impl::ForEach(this->device_list_lock, this->device_list, f); + return impl::ForEach(m_device_list_lock, m_device_list, f); } }; static_assert(IDriver::ListTraits::IsValid()); diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_event_handler.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_event_handler.hpp index 107afa89f..f3be5e105 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_event_handler.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_event_handler.hpp @@ -26,22 +26,22 @@ namespace ams::ddsf { NON_MOVEABLE(IEventHandler); friend class EventHandlerManager; private: - os::MultiWaitHolderType holder; - uintptr_t user_data; - bool is_initialized; - bool is_registered; + os::MultiWaitHolderType m_holder; + uintptr_t m_user_data; + bool m_is_initialized; + bool m_is_registered; private: void Link(os::MultiWaitType *multi_wait) { AMS_ASSERT(this->IsInitialized()); AMS_ASSERT(!this->IsRegistered()); AMS_ASSERT(multi_wait != nullptr); - os::LinkMultiWaitHolder(multi_wait, std::addressof(this->holder)); + os::LinkMultiWaitHolder(multi_wait, std::addressof(m_holder)); } void Unlink() { AMS_ASSERT(this->IsInitialized()); AMS_ASSERT(this->IsRegistered()); - os::UnlinkMultiWaitHolder(std::addressof(this->holder)); + os::UnlinkMultiWaitHolder(std::addressof(m_holder)); } static IEventHandler &ToEventHandler(os::MultiWaitHolderType *holder) { @@ -51,7 +51,7 @@ namespace ams::ddsf { return event_handler; } public: - IEventHandler() : holder(), user_data(0), is_initialized(false), is_registered(false) { /* ... */ } + IEventHandler() : m_holder(), m_user_data(0), m_is_initialized(false), m_is_registered(false) { /* ... */ } ~IEventHandler() { if (this->IsRegistered()) { @@ -62,28 +62,28 @@ namespace ams::ddsf { } } - bool IsInitialized() const { return this->is_initialized; } - bool IsRegistered() const { return this->is_registered; } + bool IsInitialized() const { return m_is_initialized; } + bool IsRegistered() const { return m_is_registered; } - uintptr_t GetUserData() const { return this->user_data; } - void SetUserData(uintptr_t d) { this->user_data = d; } + uintptr_t GetUserData() const { return m_user_data; } + void SetUserData(uintptr_t d) { m_user_data = d; } template void Initialize(T *object) { AMS_ASSERT(object != nullptr); AMS_ASSERT(!this->IsInitialized()); - os::InitializeMultiWaitHolder(std::addressof(this->holder), object); - os::SetMultiWaitHolderUserData(std::addressof(this->holder), reinterpret_cast(this)); - this->is_initialized = true; - this->is_registered = false; + os::InitializeMultiWaitHolder(std::addressof(m_holder), object); + os::SetMultiWaitHolderUserData(std::addressof(m_holder), reinterpret_cast(this)); + m_is_initialized = true; + m_is_registered = false; } void Finalize() { AMS_ASSERT(this->IsInitialized()); AMS_ASSERT(!this->IsRegistered()); - os::FinalizeMultiWaitHolder(std::addressof(this->holder)); - this->is_initialized = false; - this->is_registered = false; + os::FinalizeMultiWaitHolder(std::addressof(m_holder)); + m_is_initialized = false; + m_is_registered = false; } protected: virtual void HandleEvent() = 0; diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_session.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_session.hpp index dd881cf94..5705b6f85 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_session.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/ddsf_i_session.hpp @@ -33,30 +33,30 @@ namespace ams::ddsf { public: AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice); private: - util::IntrusiveListNode list_node; - IDevice *device; - AccessMode access_mode; + util::IntrusiveListNode m_list_node; + IDevice *m_device; + AccessMode m_access_mode; public: - using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::list_node>; + using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::m_list_node>; using List = typename ListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; private: void AttachDevice(IDevice *dev, AccessMode mode) { AMS_ASSERT(dev != nullptr); AMS_ASSERT(!this->IsOpen()); - this->device = dev; - this->access_mode = mode; + m_device = dev; + m_access_mode = mode; AMS_ASSERT(this->IsOpen()); } void DetachDevice() { AMS_ASSERT(this->IsOpen()); - this->device = nullptr; - this->access_mode = AccessMode_None; + m_device = nullptr; + m_access_mode = AccessMode_None; AMS_ASSERT(!this->IsOpen()); } public: - ISession() : list_node(), device(nullptr), access_mode() { /* ... */ } + ISession() : m_list_node(), m_device(nullptr), m_access_mode() { /* ... */ } protected: ~ISession() { this->DetachDevice(); AMS_ASSERT(!this->IsOpen()); } public: @@ -69,26 +69,26 @@ namespace ams::ddsf { } bool IsLinkedToList() const { - return this->list_node.IsLinked(); + return m_list_node.IsLinked(); } IDevice &GetDevice() { AMS_ASSERT(this->IsOpen()); - return *this->device; + return *m_device; } const IDevice &GetDevice() const { AMS_ASSERT(this->IsOpen()); - return *this->device; + return *m_device; } bool IsOpen() const { - return this->device != nullptr; + return m_device != nullptr; } bool CheckAccess(AccessMode mode) const { AMS_ASSERT(this->IsOpen()); - return ((~this->access_mode) & mode) == 0; + return ((~m_access_mode) & mode) == 0; } bool CheckExclusiveWrite() const { diff --git a/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_type_tag.hpp b/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_type_tag.hpp index a5871179d..bd1ede04a 100644 --- a/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_type_tag.hpp +++ b/libraries/libstratosphere/include/stratosphere/ddsf/impl/ddsf_type_tag.hpp @@ -37,21 +37,21 @@ namespace ams::ddsf::impl { class TypeTag { private: - const char * const class_name; - const TypeTag * const base; + const char * const m_class_name; + const TypeTag * const m_base; public: #if !(defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING)) - constexpr TypeTag() : class_name(nullptr), base(nullptr) { /* ... */} - constexpr TypeTag(const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_ASSERT(this != this->base); } + constexpr TypeTag() : m_class_name(nullptr), m_base(nullptr) { /* ... */} + constexpr TypeTag(const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); } - constexpr TypeTag(const char *c) : class_name(nullptr), base(nullptr) { AMS_UNUSED(c); } - constexpr TypeTag(const char *c, const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != this->base); } + constexpr TypeTag(const char *c) : m_class_name(nullptr), m_base(nullptr) { AMS_UNUSED(c); } + constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != m_base); } #else - constexpr TypeTag(const char *c) : class_name(c), base(nullptr) { /* ... */ } - constexpr TypeTag(const char *c, const TypeTag &b) : class_name(c), base(std::addressof(b)) { AMS_ASSERT(this != this->base); } + constexpr TypeTag(const char *c) : m_class_name(c), m_base(nullptr) { /* ... */ } + constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(c), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); } #endif - constexpr const char * GetClassName() const { return this->class_name; } + constexpr const char * GetClassName() const { return m_class_name; } constexpr bool Is(const TypeTag &rhs) const { return this == std::addressof(rhs); } @@ -61,7 +61,7 @@ namespace ams::ddsf::impl { if (cur == std::addressof(rhs)) { return true; } - cur = cur->base; + cur = cur->m_base; } return false; } diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp index f3ec7094a..17de21778 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp @@ -135,8 +135,8 @@ namespace ams::fs { using DirectoryEntryMapTable = EntryMapTable; using FileEntryMapTable = EntryMapTable; private: - DirectoryEntryMapTable dir_table; - FileEntryMapTable file_table; + DirectoryEntryMapTable m_dir_table; + FileEntryMapTable m_file_table; public: static s64 QueryDirectoryEntryBucketStorageSize(s64 count); static size_t QueryDirectoryEntrySize(size_t aux_size); @@ -148,11 +148,11 @@ namespace ams::fs { HierarchicalRomFileTable(); constexpr u32 GetDirectoryEntryCount() const { - return this->dir_table.GetEntryCount(); + return m_dir_table.GetEntryCount(); } constexpr u32 GetFileEntryCount() const { - return this->file_table.GetEntryCount(); + return m_file_table.GetEntryCount(); } Result Initialize(SubStorage dir_bucket, SubStorage dir_entry, SubStorage file_bucket, SubStorage file_entry); diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp index 5d860803a..c4b82ab77 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_key_value_storage.hpp @@ -43,11 +43,11 @@ namespace ams::fs { }; static_assert(util::is_pod::value); private: - s64 bucket_count; - SubStorage bucket_storage; - SubStorage kv_storage; - s64 total_entry_size; - u32 entry_count; + s64 m_bucket_count; + SubStorage m_bucket_storage; + SubStorage m_kv_storage; + s64 m_total_entry_size; + u32 m_entry_count; public: static constexpr s64 QueryBucketStorageSize(s64 num) { return num * sizeof(Position); @@ -69,42 +69,42 @@ namespace ams::fs { return ResultSuccess(); } public: - KeyValueRomStorageTemplate() : bucket_count(), bucket_storage(), kv_storage(), total_entry_size(), entry_count() { /* ... */ } + KeyValueRomStorageTemplate() : m_bucket_count(), m_bucket_storage(), m_kv_storage(), m_total_entry_size(), m_entry_count() { /* ... */ } Result Initialize(const SubStorage &bucket, s64 count, const SubStorage &kv) { AMS_ASSERT(count > 0); - this->bucket_storage = bucket; - this->bucket_count = count; - this->kv_storage = kv; + m_bucket_storage = bucket; + m_bucket_count = count; + m_kv_storage = kv; return ResultSuccess(); } void Finalize() { - this->bucket_storage = SubStorage(); - this->kv_storage = SubStorage(); - this->bucket_count = 0; + m_bucket_storage = SubStorage(); + m_kv_storage = SubStorage(); + m_bucket_count = 0; } s64 GetTotalEntrySize() const { - return this->total_entry_size; + return m_total_entry_size; } Result GetFreeSize(s64 *out) { AMS_ASSERT(out != nullptr); s64 kv_size = 0; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); - *out = kv_size - this->total_entry_size; + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); + *out = kv_size - m_total_entry_size; return ResultSuccess(); } constexpr u32 GetEntryCount() const { - return this->entry_count; + return m_entry_count; } protected: Result AddInternal(Position *out, const Key &key, u32 hash_key, const void *aux, size_t aux_size, const Value &value) { AMS_ASSERT(out != nullptr); AMS_ASSERT(aux != nullptr || aux_size == 0); - AMS_ASSERT(this->bucket_count > 0); + AMS_ASSERT(m_bucket_count > 0); { Position pos, prev_pos; @@ -125,7 +125,7 @@ namespace ams::fs { R_TRY(this->WriteKeyValue(std::addressof(elem), pos, aux, aux_size)); *out = pos; - this->entry_count++; + m_entry_count++; return ResultSuccess(); } @@ -178,7 +178,7 @@ namespace ams::fs { } private: BucketIndex HashToBucket(u32 hash_key) const { - return hash_key % this->bucket_count; + return hash_key % m_bucket_count; } Result FindInternal(Position *out_pos, Position *out_prev, Element *out_elem, const Key &key, u32 hash_key, const void *aux, size_t aux_size) { @@ -186,7 +186,7 @@ namespace ams::fs { AMS_ASSERT(out_prev != nullptr); AMS_ASSERT(out_elem != nullptr); AMS_ASSERT(aux != nullptr || aux_size == 0); - AMS_ASSERT(this->bucket_count > 0); + AMS_ASSERT(m_bucket_count > 0); *out_pos = 0; *out_prev = 0; @@ -197,7 +197,7 @@ namespace ams::fs { R_TRY(this->ReadBucket(std::addressof(cur), ind)); s64 kv_size; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); AMS_ASSERT(cur == InvalidPosition || cur < kv_size); R_UNLESS(cur != InvalidPosition, fs::ResultDbmKeyNotFound()); @@ -225,13 +225,13 @@ namespace ams::fs { AMS_ASSERT(out != nullptr); s64 kv_size; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); - const size_t end_pos = this->total_entry_size + sizeof(Element) + aux_size; + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); + const size_t end_pos = m_total_entry_size + sizeof(Element) + aux_size; R_UNLESS(end_pos <= static_cast(kv_size), fs::ResultDbmKeyFull()); - *out = static_cast(this->total_entry_size); + *out = static_cast(m_total_entry_size); - this->total_entry_size = util::AlignUp(static_cast(end_pos), alignof(Position)); + m_total_entry_size = util::AlignUp(static_cast(end_pos), alignof(Position)); return ResultSuccess(); } @@ -244,7 +244,7 @@ namespace ams::fs { R_TRY(this->ReadBucket(std::addressof(next), ind)); s64 kv_size; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); AMS_ASSERT(next == InvalidPosition || next < kv_size); R_TRY(this->WriteBucket(pos, ind)); @@ -255,27 +255,27 @@ namespace ams::fs { Result ReadBucket(Position *out, BucketIndex ind) { AMS_ASSERT(out != nullptr); - AMS_ASSERT(ind < this->bucket_count); + AMS_ASSERT(ind < m_bucket_count); const s64 offset = ind * sizeof(Position); - return this->bucket_storage.Read(offset, out, sizeof(*out)); + return m_bucket_storage.Read(offset, out, sizeof(*out)); } Result WriteBucket(Position pos, BucketIndex ind) { - AMS_ASSERT(ind < this->bucket_count); + AMS_ASSERT(ind < m_bucket_count); const s64 offset = ind * sizeof(Position); - return this->bucket_storage.Write(offset, std::addressof(pos), sizeof(pos)); + return m_bucket_storage.Write(offset, std::addressof(pos), sizeof(pos)); } Result ReadKeyValue(Element *out, Position pos) { AMS_ASSERT(out != nullptr); s64 kv_size; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); AMS_ASSERT(pos < kv_size); - return this->kv_storage.Read(pos, out, sizeof(*out)); + return m_kv_storage.Read(pos, out, sizeof(*out)); } Result ReadKeyValue(Element *out, void *out_aux, size_t *out_aux_size, Position pos) { @@ -287,7 +287,7 @@ namespace ams::fs { *out_aux_size = out->size; if (out->size > 0) { - R_TRY(this->kv_storage.Read(pos + sizeof(*out), out_aux, out->size)); + R_TRY(m_kv_storage.Read(pos + sizeof(*out), out_aux, out->size)); } return ResultSuccess(); @@ -298,13 +298,13 @@ namespace ams::fs { AMS_ASSERT(aux != nullptr); s64 kv_size; - R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); + R_TRY(m_kv_storage.GetSize(std::addressof(kv_size))); AMS_ASSERT(pos < kv_size); - R_TRY(this->kv_storage.Write(pos, elem, sizeof(*elem))); + R_TRY(m_kv_storage.Write(pos, elem, sizeof(*elem))); if (aux != nullptr && aux_size > 0) { - R_TRY(this->kv_storage.Write(pos + sizeof(*elem), aux, aux_size)); + R_TRY(m_kv_storage.Write(pos + sizeof(*elem), aux, aux_size)); } return ResultSuccess(); diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_path_tool.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_path_tool.hpp index ea6fb998b..deadc0fb7 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_path_tool.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_dbm_rom_path_tool.hpp @@ -81,12 +81,12 @@ namespace ams::fs::RomPathTool { class PathParser { private: - const RomPathChar *prev_path_start; - const RomPathChar *prev_path_end; - const RomPathChar *next_path; - bool finished; + const RomPathChar *m_prev_path_start; + const RomPathChar *m_prev_path_end; + const RomPathChar *m_next_path; + bool m_finished; public: - constexpr PathParser() : prev_path_start(), prev_path_end(), next_path(), finished() { /* ... */ } + constexpr PathParser() : m_prev_path_start(), m_prev_path_end(), m_next_path(), m_finished() { /* ... */ } Result Initialize(const RomPathChar *path); void Finalize(); diff --git a/libraries/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp index 100407111..4d470db4f 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/common/fs_file_storage.hpp @@ -28,42 +28,42 @@ namespace ams::fs { private: static constexpr s64 InvalidSize = -1; private: - std::unique_ptr unique_file; - std::shared_ptr shared_file; - fsa::IFile *base_file; - s64 size; + std::unique_ptr m_unique_file; + std::shared_ptr m_shared_file; + fsa::IFile *m_base_file; + s64 m_size; public: - FileStorage(fsa::IFile *f) : unique_file(f), size(InvalidSize) { - this->base_file = this->unique_file.get(); + FileStorage(fsa::IFile *f) : m_unique_file(f), m_size(InvalidSize) { + m_base_file = m_unique_file.get(); } - FileStorage(std::unique_ptr f) : unique_file(std::move(f)), size(InvalidSize) { - this->base_file = this->unique_file.get(); + FileStorage(std::unique_ptr f) : m_unique_file(std::move(f)), m_size(InvalidSize) { + m_base_file = m_unique_file.get(); } - FileStorage(std::shared_ptr f) : shared_file(f), size(InvalidSize) { - this->base_file = this->shared_file.get(); + FileStorage(std::shared_ptr f) : m_shared_file(f), m_size(InvalidSize) { + m_base_file = m_shared_file.get(); } virtual ~FileStorage() { /* ... */ } private: Result UpdateSize(); protected: - constexpr FileStorage() : unique_file(), shared_file(), base_file(nullptr), size(InvalidSize) { /* ... */ } + constexpr FileStorage() : m_unique_file(), m_shared_file(), m_base_file(nullptr), m_size(InvalidSize) { /* ... */ } void SetFile(fs::fsa::IFile *file) { AMS_ASSERT(file != nullptr); - AMS_ASSERT(this->base_file == nullptr); - this->base_file = file; + AMS_ASSERT(m_base_file == nullptr); + m_base_file = file; } void SetFile(std::unique_ptr &&file) { AMS_ASSERT(file != nullptr); - AMS_ASSERT(this->base_file == nullptr); - AMS_ASSERT(this->unique_file == nullptr); + AMS_ASSERT(m_base_file == nullptr); + AMS_ASSERT(m_unique_file == nullptr); - this->unique_file = std::move(file); - this->base_file = this->unique_file.get(); + m_unique_file = std::move(file); + m_base_file = m_unique_file.get(); } public: virtual Result Read(s64 offset, void *buffer, size_t size) override; @@ -78,9 +78,9 @@ namespace ams::fs { NON_COPYABLE(FileStorageBasedFileSystem); NON_MOVEABLE(FileStorageBasedFileSystem); private: - std::shared_ptr base_file_system; + std::shared_ptr m_base_file_system; public: - constexpr FileStorageBasedFileSystem() : FileStorage(), base_file_system(nullptr) { /* ... */ } + constexpr FileStorageBasedFileSystem() : FileStorage(), m_base_file_system(nullptr) { /* ... */ } Result Initialize(std::shared_ptr base_file_system, const char *path, fs::OpenMode mode); }; @@ -89,17 +89,17 @@ namespace ams::fs { private: static constexpr s64 InvalidSize = -1; private: - FileHandle handle; - bool close_file; - s64 size; - os::SdkMutex mutex; + FileHandle m_handle; + bool m_close_file; + s64 m_size; + os::SdkMutex m_mutex; public: - constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : handle(handle), close_file(close_file), size(InvalidSize), mutex() { /* ... */ } + constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : m_handle(handle), m_close_file(close_file), m_size(InvalidSize), m_mutex() { /* ... */ } constexpr explicit FileHandleStorage(FileHandle handle) : FileHandleStorage(handle, false) { /* ... */ } virtual ~FileHandleStorage() override { - if (this->close_file) { - CloseFile(this->handle); + if (m_close_file) { + CloseFile(m_handle); } } protected: diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_context.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_context.hpp index 212f3459b..d1b5454bf 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_context.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_context.hpp @@ -28,13 +28,13 @@ namespace ams::fs { class FsContext { private: - ResultHandler handler; + ResultHandler m_handler; public: - constexpr explicit FsContext(ResultHandler h) : handler(h) { /* ... */ } + constexpr explicit FsContext(ResultHandler h) : m_handler(h) { /* ... */ } - constexpr void SetHandler(ResultHandler h) { this->handler = h; } + constexpr void SetHandler(ResultHandler h) { m_handler = h; } - constexpr AbortSpecifier HandleResult(Result result) const { return this->handler(result); } + constexpr AbortSpecifier HandleResult(Result result) const { return m_handler(result); } }; void SetDefaultFsContextResultHandler(const ResultHandler handler); @@ -44,24 +44,24 @@ namespace ams::fs { class ScopedFsContext { private: - const FsContext * const prev_context; + const FsContext * const m_prev_context; public: - ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : prev_context(GetCurrentThreadFsContext()) { + ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : m_prev_context(GetCurrentThreadFsContext()) { SetCurrentThreadFsContext(std::addressof(ctx)); } ALWAYS_INLINE ~ScopedFsContext() { - SetCurrentThreadFsContext(this->prev_context); + SetCurrentThreadFsContext(m_prev_context); } }; class ScopedAutoAbortDisabler { private: - const FsContext * const prev_context; + const FsContext * const m_prev_context; public: ScopedAutoAbortDisabler(); ALWAYS_INLINE ~ScopedAutoAbortDisabler() { - SetCurrentThreadFsContext(this->prev_context); + SetCurrentThreadFsContext(m_prev_context); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_file.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_file.hpp index cc7667ba5..898aeb7e2 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_file.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_file.hpp @@ -19,7 +19,7 @@ namespace ams::fs { struct ReadOption { - u32 value; + u32 _value; static const ReadOption None; }; @@ -27,7 +27,7 @@ namespace ams::fs { inline constexpr const ReadOption ReadOption::None = {FsReadOption_None}; inline constexpr bool operator==(const ReadOption &lhs, const ReadOption &rhs) { - return lhs.value == rhs.value; + return lhs._value == rhs._value; } inline constexpr bool operator!=(const ReadOption &lhs, const ReadOption &rhs) { @@ -37,10 +37,10 @@ namespace ams::fs { static_assert(util::is_pod::value && sizeof(ReadOption) == sizeof(u32)); struct WriteOption { - u32 value; + u32 _value; constexpr inline bool HasFlushFlag() const { - return this->value & FsWriteOption_Flush; + return _value & FsWriteOption_Flush; } static const WriteOption None; @@ -51,7 +51,7 @@ namespace ams::fs { inline constexpr const WriteOption WriteOption::Flush = {FsWriteOption_Flush}; inline constexpr bool operator==(const WriteOption &lhs, const WriteOption &rhs) { - return lhs.value == rhs.value; + return lhs._value == rhs._value; } inline constexpr bool operator!=(const WriteOption &lhs, const WriteOption &rhs) { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp index 8d026a9f5..139bf552d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_istorage.hpp @@ -64,36 +64,36 @@ namespace ams::fs { class ReadOnlyStorageAdapter : public IStorage { private: - std::shared_ptr shared_storage; - std::unique_ptr unique_storage; - IStorage *storage; + std::shared_ptr m_shared_storage; + std::unique_ptr m_unique_storage; + IStorage *m_storage; public: - ReadOnlyStorageAdapter(IStorage *s) : unique_storage(s) { - this->storage = this->unique_storage.get(); + ReadOnlyStorageAdapter(IStorage *s) : m_unique_storage(s) { + m_storage = m_unique_storage.get(); } - ReadOnlyStorageAdapter(std::shared_ptr s) : shared_storage(s) { - this->storage = this->shared_storage.get(); + ReadOnlyStorageAdapter(std::shared_ptr s) : m_shared_storage(s) { + m_storage = m_shared_storage.get(); } - ReadOnlyStorageAdapter(std::unique_ptr s) : unique_storage(std::move(s)) { - this->storage = this->unique_storage.get(); + ReadOnlyStorageAdapter(std::unique_ptr s) : m_unique_storage(std::move(s)) { + m_storage = m_unique_storage.get(); } virtual ~ReadOnlyStorageAdapter() { /* ... */ } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { - return this->storage->Read(offset, buffer, size); + return m_storage->Read(offset, buffer, size); } virtual Result Flush() override { - return this->storage->Flush(); + return m_storage->Flush(); } virtual Result GetSize(s64 *out) override { - return this->storage->GetSize(out); + return m_storage->GetSize(out); } virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return this->storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_management.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_management.hpp index 589c61be8..b7cbf5c92 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_management.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_management.hpp @@ -30,13 +30,13 @@ namespace ams::fs { class Deleter { private: - size_t size; + size_t m_size; public: - Deleter() : size() { /* ... */ } - explicit Deleter(size_t sz) : size(sz) { /* ... */ } + Deleter() : m_size() { /* ... */ } + explicit Deleter(size_t sz) : m_size(sz) { /* ... */ } void operator()(void *ptr) const { - ::ams::fs::impl::Deallocate(ptr, this->size); + ::ams::fs::impl::Deallocate(ptr, m_size); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp index 7a1881ebd..8b3b377e4 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp @@ -22,21 +22,21 @@ namespace ams::fs { class MemoryStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable { private: - u8 * const buf; - const s64 size; + u8 * const m_buf; + const s64 m_size; public: - MemoryStorage(void *b, s64 sz) : buf(static_cast(b)), size(sz) { /* .. */ } + MemoryStorage(void *b, s64 sz) : m_buf(static_cast(b)), m_size(sz) { /* .. */ } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { /* Succeed immediately on zero-sized read. */ R_SUCCEED_IF(size == 0); /* Validate arguments. */ - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); /* Copy from memory. */ - std::memcpy(buffer, this->buf + offset, size); + std::memcpy(buffer, m_buf + offset, size); return ResultSuccess(); } @@ -45,11 +45,11 @@ namespace ams::fs { R_SUCCEED_IF(size == 0); /* Validate arguments. */ - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); /* Copy to memory. */ - std::memcpy(this->buf + offset, buffer, size); + std::memcpy(m_buf + offset, buffer, size); return ResultSuccess(); } @@ -58,7 +58,7 @@ namespace ams::fs { } virtual Result GetSize(s64 *out) override { - *out = this->size; + *out = m_size; return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp index c766dcfa4..32fa79012 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp @@ -28,17 +28,17 @@ namespace ams::fs { NON_COPYABLE(ReadOnlyFile); NON_MOVEABLE(ReadOnlyFile); private: - std::unique_ptr base_file; + std::unique_ptr m_base_file; public: - explicit ReadOnlyFile(std::unique_ptr &&f) : base_file(std::move(f)) { /* ... */ } + explicit ReadOnlyFile(std::unique_ptr &&f) : m_base_file(std::move(f)) { /* ... */ } virtual ~ReadOnlyFile() { /* ... */ } private: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { - return this->base_file->Read(out, offset, buffer, size, option); + return m_base_file->Read(out, offset, buffer, size, option); } virtual Result DoGetSize(s64 *out) override final { - return this->base_file->GetSize(out); + return m_base_file->GetSize(out); } virtual Result DoFlush() override final { @@ -59,14 +59,14 @@ namespace ams::fs { switch (op_id) { case OperationId::Invalidate: case OperationId::QueryRange: - return this->base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); default: return fs::ResultUnsupportedOperationInReadOnlyFileB(); } } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return this->base_file->GetDomainObjectId(); + return m_base_file->GetDomainObjectId(); } }; @@ -77,9 +77,9 @@ namespace ams::fs { NON_COPYABLE(ReadOnlyFileSystemTemplate); NON_MOVEABLE(ReadOnlyFileSystemTemplate); private: - T base_fs; + T m_base_fs; public: - explicit ReadOnlyFileSystemTemplate(T &&fs) : base_fs(std::move(fs)) { /* ... */ } + explicit ReadOnlyFileSystemTemplate(T &&fs) : m_base_fs(std::move(fs)) { /* ... */ } virtual ~ReadOnlyFileSystemTemplate() { /* ... */ } private: virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, OpenMode mode) override final { @@ -87,7 +87,7 @@ namespace ams::fs { R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode()); std::unique_ptr base_file; - R_TRY(this->base_fs->OpenFile(std::addressof(base_file), path, mode)); + R_TRY(m_base_fs->OpenFile(std::addressof(base_file), path, mode)); auto read_only_file = std::make_unique(std::move(base_file)); R_UNLESS(read_only_file != nullptr, fs::ResultAllocationFailureInReadOnlyFileSystemA()); @@ -97,11 +97,11 @@ namespace ams::fs { } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, OpenDirectoryMode mode) override final { - return this->base_fs->OpenDirectory(out_dir, path, mode); + return m_base_fs->OpenDirectory(out_dir, path, mode); } virtual Result DoGetEntryType(DirectoryEntryType *out, const char *path) override final { - return this->base_fs->GetEntryType(out, path); + return m_base_fs->GetEntryType(out, path); } virtual Result DoCommit() override final { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp index 19e658539..cb8c2cb91 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp @@ -26,30 +26,30 @@ namespace ams::fs { class RemoteFile : public fsa::IFile, public impl::Newable { private: - ::FsFile base_file; + ::FsFile m_base_file; public: - RemoteFile(const ::FsFile &f) : base_file(f) { /* ... */ } + RemoteFile(const ::FsFile &f) : m_base_file(f) { /* ... */ } - virtual ~RemoteFile() { fsFileClose(std::addressof(this->base_file)); } + virtual ~RemoteFile() { fsFileClose(std::addressof(m_base_file)); } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { - return fsFileRead(std::addressof(this->base_file), offset, buffer, size, option.value, out); + return fsFileRead(std::addressof(m_base_file), offset, buffer, size, option._value, out); } virtual Result DoGetSize(s64 *out) override final { - return fsFileGetSize(std::addressof(this->base_file), out); + return fsFileGetSize(std::addressof(m_base_file), out); } virtual Result DoFlush() override final { - return fsFileFlush(std::addressof(this->base_file)); + return fsFileFlush(std::addressof(m_base_file)); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final { - return fsFileWrite(std::addressof(this->base_file), offset, buffer, size, option.value); + return fsFileWrite(std::addressof(m_base_file), offset, buffer, size, option._value); } virtual Result DoSetSize(s64 size) override final { - return fsFileSetSize(std::addressof(this->base_file), size); + return fsFileSetSize(std::addressof(m_base_file), size); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { @@ -58,42 +58,42 @@ namespace ams::fs { R_UNLESS(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperationInFileServiceObjectAdapterA()); R_UNLESS(dst_size == sizeof(FileQueryRangeInfo), fs::ResultInvalidSize()); - return fsFileOperateRange(std::addressof(this->base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst)); + return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst)); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(this->base_file.s)))}; + return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(m_base_file.s)))}; } }; class RemoteDirectory : public fsa::IDirectory, public impl::Newable { private: - ::FsDir base_dir; + ::FsDir m_base_dir; public: - RemoteDirectory(const ::FsDir &d) : base_dir(d) { /* ... */ } + RemoteDirectory(const ::FsDir &d) : m_base_dir(d) { /* ... */ } - virtual ~RemoteDirectory() { fsDirClose(std::addressof(this->base_dir)); } + virtual ~RemoteDirectory() { fsDirClose(std::addressof(m_base_dir)); } public: virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final { - return fsDirRead(std::addressof(this->base_dir), out_count, max_entries, out_entries); + return fsDirRead(std::addressof(m_base_dir), out_count, max_entries, out_entries); } virtual Result DoGetEntryCount(s64 *out) override final { - return fsDirGetEntryCount(std::addressof(this->base_dir), out); + return fsDirGetEntryCount(std::addressof(m_base_dir), out); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(this->base_dir.s)))}; + return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(m_base_dir.s)))}; } }; class RemoteFileSystem : public fsa::IFileSystem, public impl::Newable { private: - ::FsFileSystem base_fs; + ::FsFileSystem m_base_fs; public: - RemoteFileSystem(const ::FsFileSystem &fs) : base_fs(fs) { /* ... */ } + RemoteFileSystem(const ::FsFileSystem &fs) : m_base_fs(fs) { /* ... */ } - virtual ~RemoteFileSystem() { fsFsClose(std::addressof(this->base_fs)); } + virtual ~RemoteFileSystem() { fsFsClose(std::addressof(m_base_fs)); } private: Result GetPathForServiceObject(fssrv::sf::Path *out_path, const char *path) { /* Copy and null terminate. */ @@ -113,31 +113,31 @@ namespace ams::fs { virtual Result DoCreateFile(const char *path, s64 size, int flags) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCreateFile(std::addressof(this->base_fs), sf_path.str, size, flags); + return fsFsCreateFile(std::addressof(m_base_fs), sf_path.str, size, flags); } virtual Result DoDeleteFile(const char *path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteFile(std::addressof(this->base_fs), sf_path.str); + return fsFsDeleteFile(std::addressof(m_base_fs), sf_path.str); } virtual Result DoCreateDirectory(const char *path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCreateDirectory(std::addressof(this->base_fs), sf_path.str); + return fsFsCreateDirectory(std::addressof(m_base_fs), sf_path.str); } virtual Result DoDeleteDirectory(const char *path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteDirectory(std::addressof(this->base_fs), sf_path.str); + return fsFsDeleteDirectory(std::addressof(m_base_fs), sf_path.str); } virtual Result DoDeleteDirectoryRecursively(const char *path) override final { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsDeleteDirectoryRecursively(std::addressof(this->base_fs), sf_path.str); + return fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), sf_path.str); } virtual Result DoRenameFile(const char *old_path, const char *new_path) override final { @@ -145,7 +145,7 @@ namespace ams::fs { fssrv::sf::Path new_sf_path; R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path)); - return fsFsRenameFile(std::addressof(this->base_fs), old_sf_path.str, new_sf_path.str); + return fsFsRenameFile(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str); } virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override final { @@ -153,7 +153,7 @@ namespace ams::fs { fssrv::sf::Path new_sf_path; R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path)); - return fsFsRenameDirectory(std::addressof(this->base_fs), old_sf_path.str, new_sf_path.str); + return fsFsRenameDirectory(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str); } virtual Result DoGetEntryType(DirectoryEntryType *out, const char *path) override final { @@ -161,7 +161,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); static_assert(sizeof(::FsDirEntryType) == sizeof(DirectoryEntryType)); - return fsFsGetEntryType(std::addressof(this->base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out)); + return fsFsGetEntryType(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out)); } virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, OpenMode mode) override final { @@ -169,7 +169,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); FsFile f; - R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(f))); + R_TRY(fsFsOpenFile(std::addressof(m_base_fs), sf_path.str, mode, std::addressof(f))); auto file = std::make_unique(f); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew()); @@ -183,7 +183,7 @@ namespace ams::fs { R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); FsDir d; - R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(d))); + R_TRY(fsFsOpenDirectory(std::addressof(m_base_fs), sf_path.str, mode, std::addressof(d))); auto dir = std::make_unique(d); R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew()); @@ -193,39 +193,39 @@ namespace ams::fs { } virtual Result DoCommit() override final { - return fsFsCommit(std::addressof(this->base_fs)); + return fsFsCommit(std::addressof(m_base_fs)); } virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsGetFreeSpace(std::addressof(this->base_fs), sf_path.str, out); + return fsFsGetFreeSpace(std::addressof(m_base_fs), sf_path.str, out); } virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsGetTotalSpace(std::addressof(this->base_fs), sf_path.str, out); + return fsFsGetTotalSpace(std::addressof(m_base_fs), sf_path.str, out); } virtual Result DoCleanDirectoryRecursively(const char *path) { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsCleanDirectoryRecursively(std::addressof(this->base_fs), sf_path.str); + return fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), sf_path.str); } virtual Result DoGetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); static_assert(sizeof(FileTimeStampRaw) == sizeof(::FsTimeStampRaw)); - return fsFsGetFileTimeStampRaw(std::addressof(this->base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out)); + return fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out)); } virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path) { fssrv::sf::Path sf_path; R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); - return fsFsQueryEntry(std::addressof(this->base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast(query)); + return fsFsQueryEntry(std::addressof(m_base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast(query)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp index 972208508..949468983 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp @@ -22,33 +22,33 @@ namespace ams::fs { class RemoteStorage : public IStorage, public impl::Newable { private: - std::unique_ptr<::FsStorage, impl::Deleter> base_storage; + std::unique_ptr<::FsStorage, impl::Deleter> m_base_storage; public: RemoteStorage(::FsStorage &s) { - this->base_storage = impl::MakeUnique<::FsStorage>(); - *this->base_storage = s; + m_base_storage = impl::MakeUnique<::FsStorage>(); + *m_base_storage = s; } - virtual ~RemoteStorage() { fsStorageClose(this->base_storage.get()); } + virtual ~RemoteStorage() { fsStorageClose(m_base_storage.get()); } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { - return fsStorageRead(this->base_storage.get(), offset, buffer, size); + return fsStorageRead(m_base_storage.get(), offset, buffer, size); }; virtual Result Write(s64 offset, const void *buffer, size_t size) override { - return fsStorageWrite(this->base_storage.get(), offset, buffer, size); + return fsStorageWrite(m_base_storage.get(), offset, buffer, size); }; virtual Result Flush() override { - return fsStorageFlush(this->base_storage.get()); + return fsStorageFlush(m_base_storage.get()); }; virtual Result GetSize(s64 *out_size) override { - return fsStorageGetSize(this->base_storage.get(), out_size); + return fsStorageGetSize(m_base_storage.get(), out_size); }; virtual Result SetSize(s64 size) override { - return fsStorageSetSize(this->base_storage.get(), size); + return fsStorageSetSize(m_base_storage.get(), size); }; virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_romfs_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_romfs_filesystem.hpp index 5c5e0097c..b64e06348 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_romfs_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_romfs_filesystem.hpp @@ -28,14 +28,14 @@ namespace ams::fs { public: using RomFileTable = HierarchicalRomFileTable; private: - RomFileTable rom_file_table; - IStorage *base_storage; - std::unique_ptr unique_storage; - std::unique_ptr dir_bucket_storage; - std::unique_ptr dir_entry_storage; - std::unique_ptr file_bucket_storage; - std::unique_ptr file_entry_storage; - s64 entry_size; + RomFileTable m_rom_file_table; + IStorage *m_base_storage; + std::unique_ptr m_unique_storage; + std::unique_ptr m_dir_bucket_storage; + std::unique_ptr m_dir_entry_storage; + std::unique_ptr m_file_bucket_storage; + std::unique_ptr m_file_entry_storage; + s64 m_entry_size; private: Result GetFileInfo(RomFileTable::FileInfo *out, const char *path); public: diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_shared_filesystem_holder.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_shared_filesystem_holder.hpp index b4f181f98..058e7b310 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_shared_filesystem_holder.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_shared_filesystem_holder.hpp @@ -26,29 +26,29 @@ namespace ams::fs { NON_COPYABLE(SharedFileSystemHolder); NON_MOVEABLE(SharedFileSystemHolder); private: - std::shared_ptr fs; + std::shared_ptr m_fs; public: - SharedFileSystemHolder(std::shared_ptr f) : fs(std::move(f)) { /* ... */ } + SharedFileSystemHolder(std::shared_ptr f) : m_fs(std::move(f)) { /* ... */ } public: - virtual Result DoCreateFile(const char *path, s64 size, int flags) override { return this->fs->CreateFile(path, size, flags); } - virtual Result DoDeleteFile(const char *path) override { return this->fs->DeleteFile(path); } - virtual Result DoCreateDirectory(const char *path) override { return this->fs->CreateDirectory(path); } - virtual Result DoDeleteDirectory(const char *path) override { return this->fs->DeleteDirectory(path); } - virtual Result DoDeleteDirectoryRecursively(const char *path) override { return this->fs->DeleteDirectoryRecursively(path); } - virtual Result DoRenameFile(const char *old_path, const char *new_path) override { return this->fs->RenameFile(old_path, new_path); } - virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override { return this->fs->RenameDirectory(old_path, new_path); } - virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override { return this->fs->GetEntryType(out, path); } - virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override { return this->fs->OpenFile(out_file, path, mode); } - virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) override { return this->fs->OpenDirectory(out_dir, path, mode); } - virtual Result DoCommit() override { return this->fs->Commit(); } - virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { return this->fs->GetFreeSpaceSize(out, path); } - virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override { return this->fs->GetTotalSpaceSize(out, path); } - virtual Result DoCleanDirectoryRecursively(const char *path) override { return this->fs->CleanDirectoryRecursively(path); } + virtual Result DoCreateFile(const char *path, s64 size, int flags) override { return m_fs->CreateFile(path, size, flags); } + virtual Result DoDeleteFile(const char *path) override { return m_fs->DeleteFile(path); } + virtual Result DoCreateDirectory(const char *path) override { return m_fs->CreateDirectory(path); } + virtual Result DoDeleteDirectory(const char *path) override { return m_fs->DeleteDirectory(path); } + virtual Result DoDeleteDirectoryRecursively(const char *path) override { return m_fs->DeleteDirectoryRecursively(path); } + virtual Result DoRenameFile(const char *old_path, const char *new_path) override { return m_fs->RenameFile(old_path, new_path); } + virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override { return m_fs->RenameDirectory(old_path, new_path); } + virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override { return m_fs->GetEntryType(out, path); } + virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override { return m_fs->OpenFile(out_file, path, mode); } + virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) override { return m_fs->OpenDirectory(out_dir, path, mode); } + virtual Result DoCommit() override { return m_fs->Commit(); } + virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { return m_fs->GetFreeSpaceSize(out, path); } + virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override { return m_fs->GetTotalSpaceSize(out, path); } + virtual Result DoCleanDirectoryRecursively(const char *path) override { return m_fs->CleanDirectoryRecursively(path); } /* These aren't accessible as commands. */ - virtual Result DoCommitProvisionally(s64 counter) override { return this->fs->CommitProvisionally(counter); } - virtual Result DoRollback() override { return this->fs->Rollback(); } - virtual Result DoFlush() override { return this->fs->Flush(); } + virtual Result DoCommitProvisionally(s64 counter) override { return m_fs->CommitProvisionally(counter); } + virtual Result DoRollback() override { return m_fs->Rollback(); } + virtual Result DoFlush() override { return m_fs->Flush(); } }; } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp index dd2ec3fe4..41383dc2d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp @@ -21,51 +21,51 @@ namespace ams::fs { class SubStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable { private: - std::shared_ptr shared_base_storage; - fs::IStorage *base_storage; - s64 offset; - s64 size; - bool resizable; + std::shared_ptr m_shared_base_storage; + fs::IStorage *m_base_storage; + s64 m_offset; + s64 m_size; + bool m_resizable; private: constexpr bool IsValid() const { - return this->base_storage != nullptr; + return m_base_storage != nullptr; } public: - SubStorage() : shared_base_storage(), base_storage(nullptr), offset(0), size(0), resizable(false) { /* ... */ } + SubStorage() : m_shared_base_storage(), m_base_storage(nullptr), m_offset(0), m_size(0), m_resizable(false) { /* ... */ } - SubStorage(const SubStorage &rhs) : shared_base_storage(), base_storage(rhs.base_storage), offset(rhs.offset), size(rhs.size), resizable(rhs.resizable) { /* ... */} + SubStorage(const SubStorage &rhs) : m_shared_base_storage(), m_base_storage(rhs.m_base_storage), m_offset(rhs.m_offset), m_size(rhs.m_size), m_resizable(rhs.m_resizable) { /* ... */} SubStorage &operator=(const SubStorage &rhs) { if (this != std::addressof(rhs)) { - this->base_storage = rhs.base_storage; - this->offset = rhs.offset; - this->size = rhs.size; - this->resizable = rhs.resizable; + m_base_storage = rhs.m_base_storage; + m_offset = rhs.m_offset; + m_size = rhs.m_size; + m_resizable = rhs.m_resizable; } return *this; } - SubStorage(IStorage *storage, s64 o, s64 sz) : shared_base_storage(), base_storage(storage), offset(o), size(sz), resizable(false) { + SubStorage(IStorage *storage, s64 o, s64 sz) : m_shared_base_storage(), m_base_storage(storage), m_offset(o), m_size(sz), m_resizable(false) { AMS_ABORT_UNLESS(this->IsValid()); - AMS_ABORT_UNLESS(this->offset >= 0); - AMS_ABORT_UNLESS(this->size >= 0); + AMS_ABORT_UNLESS(m_offset >= 0); + AMS_ABORT_UNLESS(m_size >= 0); } - SubStorage(std::shared_ptr storage, s64 o, s64 sz) : shared_base_storage(storage), base_storage(storage.get()), offset(o), size(sz), resizable(false) { + SubStorage(std::shared_ptr storage, s64 o, s64 sz) : m_shared_base_storage(storage), m_base_storage(storage.get()), m_offset(o), m_size(sz), m_resizable(false) { AMS_ABORT_UNLESS(this->IsValid()); - AMS_ABORT_UNLESS(this->offset >= 0); - AMS_ABORT_UNLESS(this->size >= 0); + AMS_ABORT_UNLESS(m_offset >= 0); + AMS_ABORT_UNLESS(m_size >= 0); } - SubStorage(SubStorage *sub, s64 o, s64 sz) : shared_base_storage(), base_storage(sub->base_storage), offset(o + sub->offset), size(sz), resizable(false) { + SubStorage(SubStorage *sub, s64 o, s64 sz) : m_shared_base_storage(), m_base_storage(sub->m_base_storage), m_offset(o + sub->m_offset), m_size(sz), m_resizable(false) { AMS_ABORT_UNLESS(this->IsValid()); - AMS_ABORT_UNLESS(this->offset >= 0); - AMS_ABORT_UNLESS(this->size >= 0); - AMS_ABORT_UNLESS(sub->size >= o + sz); + AMS_ABORT_UNLESS(m_offset >= 0); + AMS_ABORT_UNLESS(m_size >= 0); + AMS_ABORT_UNLESS(sub->m_size >= o + sz); } public: void SetResizable(bool rsz) { - this->resizable = rsz; + m_resizable = rsz; } public: virtual Result Read(s64 offset, void *buffer, size_t size) override { @@ -77,9 +77,9 @@ namespace ams::fs { /* Validate arguments and read. */ - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); - return this->base_storage->Read(this->offset + offset, buffer, size); + R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); + return m_base_storage->Read(m_offset + offset, buffer, size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override{ @@ -90,31 +90,31 @@ namespace ams::fs { R_SUCCEED_IF(size == 0); /* Validate arguments and write. */ - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); - return this->base_storage->Write(this->offset + offset, buffer, size); + R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); + return m_base_storage->Write(m_offset + offset, buffer, size); } virtual Result Flush() override { R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - return this->base_storage->Flush(); + return m_base_storage->Flush(); } virtual Result SetSize(s64 size) override { /* Ensure we're initialized and validate arguments. */ - R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - R_UNLESS(this->resizable, fs::ResultUnsupportedOperationInSubStorageA()); - R_UNLESS(IStorage::CheckOffsetAndSize(this->offset, size), fs::ResultInvalidSize()); + R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); + R_UNLESS(m_resizable, fs::ResultUnsupportedOperationInSubStorageA()); + R_UNLESS(IStorage::CheckOffsetAndSize(m_offset, size), fs::ResultInvalidSize()); /* Ensure that we're allowed to set size. */ s64 cur_size; - R_TRY(this->base_storage->GetSize(std::addressof(cur_size))); - R_UNLESS(cur_size == this->offset + this->size, fs::ResultUnsupportedOperationInSubStorageB()); + R_TRY(m_base_storage->GetSize(std::addressof(cur_size))); + R_UNLESS(cur_size == m_offset + m_size, fs::ResultUnsupportedOperationInSubStorageB()); /* Set the size. */ - R_TRY(this->base_storage->SetSize(this->offset + size)); + R_TRY(m_base_storage->SetSize(m_offset + size)); - this->size = size; + m_size = size; return ResultSuccess(); } @@ -122,7 +122,7 @@ namespace ams::fs { /* Ensure we're initialized. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - *out = this->size; + *out = m_size; return ResultSuccess(); } @@ -135,7 +135,7 @@ namespace ams::fs { /* Validate arguments and operate. */ R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange()); - return this->base_storage->OperateRange(dst, dst_size, op_id, this->offset + offset, size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, m_offset + offset, size, src, src_size); } using IStorage::OperateRange; diff --git a/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp b/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp index 38eb78f26..ab48bb117 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/impl/fs_access_log_impl.hpp @@ -66,7 +66,7 @@ namespace ams::fs::impl { class IdString { private: - char buffer[0x20]; + char m_buffer[0x20]; private: const char *ToValueString(int id); public: diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_rom_file_system_creator.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_rom_file_system_creator.hpp index a38d3ef20..5a62cfa49 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_rom_file_system_creator.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_rom_file_system_creator.hpp @@ -23,9 +23,9 @@ namespace ams::fssrv::fscreator { NON_COPYABLE(RomFileSystemCreator); NON_MOVEABLE(RomFileSystemCreator); private: - MemoryResource *allocator; + MemoryResource *m_allocator; public: - explicit RomFileSystemCreator(MemoryResource *mr) : allocator(mr) { /* ... */ } + explicit RomFileSystemCreator(MemoryResource *mr) : m_allocator(mr) { /* ... */ } virtual Result Create(std::shared_ptr *out, std::shared_ptr storage) override; }; diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp index 95c49cac1..44a979112 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp @@ -30,15 +30,15 @@ namespace ams::fssrv::fscreator { NON_COPYABLE(StorageOnNcaCreator); NON_MOVEABLE(StorageOnNcaCreator); private: - MemoryResource *allocator; - fssystem::IBufferManager * const buffer_manager; - const fssystem::NcaCryptoConfiguration &nca_crypto_cfg; - bool is_prod; - bool is_enabled_program_verification; + MemoryResource *m_allocator; + fssystem::IBufferManager * const m_buffer_manager; + const fssystem::NcaCryptoConfiguration &m_nca_crypto_cfg; + bool m_is_prod; + bool m_is_enabled_program_verification; private: Result VerifyNcaHeaderSign2(fssystem::NcaReader *nca_reader, fs::IStorage *storage); public: - explicit StorageOnNcaCreator(MemoryResource *mr, const fssystem::NcaCryptoConfiguration &cfg, bool prod, fssystem::IBufferManager *bm) : allocator(mr), buffer_manager(bm), nca_crypto_cfg(cfg), is_prod(prod), is_enabled_program_verification(true) { + explicit StorageOnNcaCreator(MemoryResource *mr, const fssystem::NcaCryptoConfiguration &cfg, bool prod, fssystem::IBufferManager *bm) : m_allocator(mr), m_buffer_manager(bm), m_nca_crypto_cfg(cfg), m_is_prod(prod), m_is_enabled_program_verification(true) { /* ... */ } diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp index 7393e5e1d..90942da17 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp @@ -22,17 +22,17 @@ namespace ams::fssrv { class MemoryResourceFromExpHeap : public ams::MemoryResource { private: - lmem::HeapHandle heap_handle; + lmem::HeapHandle m_heap_handle; public: - constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : heap_handle(handle) { /* ... */ } + constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : m_heap_handle(handle) { /* ... */ } protected: virtual void *AllocateImpl(size_t size, size_t align) override { - return lmem::AllocateFromExpHeap(this->heap_handle, size, static_cast(align)); + return lmem::AllocateFromExpHeap(m_heap_handle, size, static_cast(align)); } virtual void DeallocateImpl(void *p, size_t size, size_t align) override { AMS_UNUSED(size, align); - return lmem::FreeToExpHeap(this->heap_handle, p); + return lmem::FreeToExpHeap(m_heap_handle, p); } virtual bool IsEqualImpl(const MemoryResource &rhs) const override { @@ -43,24 +43,24 @@ namespace ams::fssrv { class PeakCheckableMemoryResourceFromExpHeap : public ams::MemoryResource { private: - lmem::HeapHandle heap_handle; - os::SdkMutex mutex; - size_t peak_free_size; - size_t current_free_size; + lmem::HeapHandle m_heap_handle; + os::SdkMutex m_mutex; + size_t m_peak_free_size; + size_t m_current_free_size; public: - constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : heap_handle(nullptr), mutex(), peak_free_size(heap_size), current_free_size(heap_size) { /* ... */ } + constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : m_heap_handle(nullptr), m_mutex(), m_peak_free_size(heap_size), m_current_free_size(heap_size) { /* ... */ } void SetHeapHandle(lmem::HeapHandle handle) { - this->heap_handle = handle; + m_heap_handle = handle; } - size_t GetPeakFreeSize() const { return this->peak_free_size; } - size_t GetCurrentFreeSize() const { return this->current_free_size; } + size_t GetPeakFreeSize() const { return m_peak_free_size; } + size_t GetCurrentFreeSize() const { return m_current_free_size; } - void ClearPeak() { this->peak_free_size = this->current_free_size; } + void ClearPeak() { m_peak_free_size = m_current_free_size; } std::scoped_lock GetScopedLock() { - return std::scoped_lock(this->mutex); + return std::scoped_lock(m_mutex); } void OnAllocate(void *p, size_t size); diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_standard_allocator.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_standard_allocator.hpp index 566c5b954..f80a2ccf6 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_standard_allocator.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_memory_resource_from_standard_allocator.hpp @@ -27,17 +27,17 @@ namespace ams::fssrv { class MemoryResourceFromStandardAllocator : public ams::MemoryResource { private: - mem::StandardAllocator *allocator; - os::SdkMutex mutex; - size_t peak_free_size; - size_t current_free_size; - size_t peak_allocated_size; + mem::StandardAllocator *m_allocator; + os::SdkMutex m_mutex; + size_t m_peak_free_size; + size_t m_current_free_size; + size_t m_peak_allocated_size; public: explicit MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator); public: - size_t GetPeakFreeSize() const { return this->peak_free_size; } - size_t GetCurrentFreeSize() const { return this->current_free_size; } - size_t GetPeakAllocatedSize() const { return this->peak_allocated_size; } + size_t GetPeakFreeSize() const { return m_peak_free_size; } + size_t GetCurrentFreeSize() const { return m_current_free_size; } + size_t GetPeakAllocatedSize() const { return m_peak_allocated_size; } void ClearPeak(); protected: diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp index b07c625ad..d206f5b22 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp @@ -33,34 +33,34 @@ namespace ams::fssrv { private: using Buffer = std::unique_ptr; private: - Buffer buffer; - const char *path; - Result result; + Buffer m_buffer; + const char *m_path; + Result m_result; private: static Result Normalize(const char **out_path, Buffer *out_buf, const char *path, bool preserve_unc, bool preserve_tail_sep, bool has_mount_name); public: /* TODO: Remove non-option constructor. */ - explicit PathNormalizer(const char *p) : buffer(), path(nullptr), result(ResultSuccess()) { - this->result = Normalize(std::addressof(this->path), std::addressof(this->buffer), p, false, false, false); + explicit PathNormalizer(const char *p) : m_buffer(), m_path(nullptr), m_result(ResultSuccess()) { + m_result = Normalize(std::addressof(m_path), std::addressof(m_buffer), p, false, false, false); } - PathNormalizer(const char *p, u32 option) : buffer(), path(nullptr), result(ResultSuccess()) { + PathNormalizer(const char *p, u32 option) : m_buffer(), m_path(nullptr), m_result(ResultSuccess()) { if ((option & Option_AcceptEmpty) && p[0] == '\x00') { - this->path = path; + m_path = p; } else { const bool preserve_unc = (option & Option_PreserveUnc); const bool preserve_tail_sep = (option & Option_PreserveTailSeparator); const bool has_mount_name = (option & Option_HasMountName); - this->result = Normalize(std::addressof(this->path), std::addressof(this->buffer), p, preserve_unc, preserve_tail_sep, has_mount_name); + m_result = Normalize(std::addressof(m_path), std::addressof(m_buffer), p, preserve_unc, preserve_tail_sep, has_mount_name); } } Result GetResult() const { - return this->result; + return m_result; } const char *GetPath() const { - return this->path; + return m_path; } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp index 51f2869da..ac4a06dda 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp @@ -40,9 +40,9 @@ namespace ams::fssrv::impl { class FileInterfaceAdapter { NON_COPYABLE(FileInterfaceAdapter); private: - ams::sf::SharedPointer parent_filesystem; - std::unique_ptr base_file; - util::unique_lock open_count_semaphore; + ams::sf::SharedPointer m_parent_filesystem; + std::unique_ptr m_base_file; + util::unique_lock m_open_count_semaphore; public: FileInterfaceAdapter(std::unique_ptr &&file, FileSystemInterfaceAdapter *parent, util::unique_lock &&sema); ~FileInterfaceAdapter(); @@ -63,9 +63,9 @@ namespace ams::fssrv::impl { class DirectoryInterfaceAdapter { NON_COPYABLE(DirectoryInterfaceAdapter); private: - ams::sf::SharedPointer parent_filesystem; - std::unique_ptr base_dir; - util::unique_lock open_count_semaphore; + ams::sf::SharedPointer m_parent_filesystem; + std::unique_ptr m_base_dir; + util::unique_lock m_open_count_semaphore; public: DirectoryInterfaceAdapter(std::unique_ptr &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock &&sema); ~DirectoryInterfaceAdapter(); @@ -79,11 +79,11 @@ namespace ams::fssrv::impl { class FileSystemInterfaceAdapter : public ams::sf::ISharedObject { NON_COPYABLE(FileSystemInterfaceAdapter); private: - std::shared_ptr base_fs; - util::unique_lock mount_count_semaphore; - os::ReaderWriterLock invalidation_lock; - bool open_count_limited; - bool deep_retry_enabled = false; + std::shared_ptr m_base_fs; + util::unique_lock m_mount_count_semaphore; + os::ReaderWriterLock m_invalidation_lock; + bool m_open_count_limited; + bool m_deep_retry_enabled = false; public: FileSystemInterfaceAdapter(std::shared_ptr &&fs, bool open_limited); /* TODO: Other constructors. */ diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp index 7e8894fb5..dfe09a837 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp @@ -31,11 +31,11 @@ namespace ams::fssrv::impl { NON_COPYABLE(StorageInterfaceAdapter); private: /* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */ - std::shared_ptr base_storage; - util::unique_lock open_count_semaphore; - os::ReaderWriterLock invalidation_lock; + std::shared_ptr m_base_storage; + util::unique_lock m_open_count_semaphore; + os::ReaderWriterLock m_invalidation_lock; /* TODO: DataStorageContext. */ - bool deep_retry_enabled = false; + bool m_deep_retry_enabled = false; public: StorageInterfaceAdapter(fs::IStorage *storage); StorageInterfaceAdapter(std::unique_ptr storage); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_buffer_manager_utils.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_buffer_manager_utils.hpp index 072b273a0..b47bdca90 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_buffer_manager_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_buffer_manager_utils.hpp @@ -56,13 +56,13 @@ namespace ams::fssystem::buffers { class BufferManagerContext { private: - bool needs_blocking; + bool m_needs_blocking; public: - constexpr BufferManagerContext() : needs_blocking(false) { /* ... */ } + constexpr BufferManagerContext() : m_needs_blocking(false) { /* ... */ } public: - bool IsNeedBlocking() const { return this->needs_blocking; } + bool IsNeedBlocking() const { return m_needs_blocking; } - void SetNeedBlocking(bool need) { this->needs_blocking = need; } + void SetNeedBlocking(bool need) { m_needs_blocking = need; } }; void RegisterBufferManagerContext(const BufferManagerContext *context); @@ -71,19 +71,19 @@ namespace ams::fssystem::buffers { class ScopedBufferManagerContextRegistration { private: - BufferManagerContext cur_context; - const BufferManagerContext *old_context; + BufferManagerContext m_cur_context; + const BufferManagerContext *m_old_context; public: ALWAYS_INLINE explicit ScopedBufferManagerContextRegistration() { - this->old_context = GetBufferManagerContext(); - if (this->old_context != nullptr) { - this->cur_context = *this->old_context; + m_old_context = GetBufferManagerContext(); + if (m_old_context != nullptr) { + m_cur_context = *m_old_context; } - RegisterBufferManagerContext(std::addressof(this->cur_context)); + RegisterBufferManagerContext(std::addressof(m_cur_context)); } ALWAYS_INLINE ~ScopedBufferManagerContextRegistration() { - RegisterBufferManagerContext(this->old_context); + RegisterBufferManagerContext(m_old_context); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp index 5bc42e6bd..150785acc 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buddy_heap.hpp @@ -37,31 +37,31 @@ namespace ams::fssystem { NON_COPYABLE(PageList); NON_MOVEABLE(PageList); private: - PageEntry *first_page_entry; - PageEntry *last_page_entry; - s32 entry_count; + PageEntry *m_first_page_entry; + PageEntry *m_last_page_entry; + s32 m_entry_count; public: - constexpr PageList() : first_page_entry(), last_page_entry(), entry_count() { /* ... */ } + constexpr PageList() : m_first_page_entry(), m_last_page_entry(), m_entry_count() { /* ... */ } - constexpr bool IsEmpty() const { return this->entry_count == 0; } - constexpr s32 GetSize() const { return this->entry_count; } + constexpr bool IsEmpty() const { return m_entry_count == 0; } + constexpr s32 GetSize() const { return m_entry_count; } - constexpr const PageEntry *GetFront() const { return this->first_page_entry; } + constexpr const PageEntry *GetFront() const { return m_first_page_entry; } public: PageEntry *PopFront(); void PushBack(PageEntry *page_entry); bool Remove(PageEntry *page_entry); }; private: - size_t block_size; - s32 order_max; - uintptr_t heap_start; - size_t heap_size; + size_t m_block_size; + s32 m_order_max; + uintptr_t m_heap_start; + size_t m_heap_size; - PageList *free_lists; - size_t total_free_size; - PageList *external_free_lists; - std::unique_ptr internal_free_lists; + PageList *m_free_lists; + size_t m_total_free_size; + PageList *m_external_free_lists; + std::unique_ptr m_internal_free_lists; public: static constexpr s32 GetBlockCountFromOrder(s32 order) { AMS_ASSERT(0 <= order); @@ -87,7 +87,7 @@ namespace ams::fssystem { } public: - constexpr FileSystemBuddyHeap() : block_size(), order_max(), heap_start(), heap_size(), free_lists(), total_free_size(), external_free_lists(), internal_free_lists() { /* ... */ } + constexpr FileSystemBuddyHeap() : m_block_size(), m_order_max(), m_heap_start(), m_heap_size(), m_free_lists(), m_total_free_size(), m_external_free_lists(), m_internal_free_lists() { /* ... */ } Result Initialize(uintptr_t address, size_t size, size_t block_size, s32 order_max); @@ -100,7 +100,7 @@ namespace ams::fssystem { AMS_UNUSED(work_size); const auto aligned_work = util::AlignUp(reinterpret_cast(work), alignof(PageList)); - this->external_free_lists = reinterpret_cast(aligned_work); + m_external_free_lists = reinterpret_cast(aligned_work); return this->Initialize(address, size, block_size, order_max); } @@ -118,34 +118,34 @@ namespace ams::fssystem { void Dump() const; s32 GetOrderFromBytes(size_t size) const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); return this->GetOrderFromBlockCount(this->GetBlockCountFromSize(size)); } size_t GetBytesFromOrder(s32 order) const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); AMS_ASSERT(0 <= order); AMS_ASSERT(order < this->GetOrderMax()); return (this->GetBlockSize() << order); } s32 GetOrderMax() const { - AMS_ASSERT(this->free_lists != nullptr); - return this->order_max; + AMS_ASSERT(m_free_lists != nullptr); + return m_order_max; } size_t GetBlockSize() const { - AMS_ASSERT(this->free_lists != nullptr); - return this->block_size; + AMS_ASSERT(m_free_lists != nullptr); + return m_block_size; } s32 GetPageBlockCountMax() const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); return 1 << this->GetOrderMax(); } size_t GetPageSizeMax() const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); return this->GetPageBlockCountMax() * this->GetBlockSize(); } private: @@ -163,24 +163,24 @@ namespace ams::fssystem { uintptr_t GetAddressFromPageEntry(const PageEntry &page_entry) const { const uintptr_t address = reinterpret_cast(std::addressof(page_entry)); - AMS_ASSERT(this->heap_start <= address); - AMS_ASSERT(address < this->heap_start + this->heap_size); - AMS_ASSERT(util::IsAligned(address - this->heap_start, this->GetBlockSize())); + AMS_ASSERT(m_heap_start <= address); + AMS_ASSERT(address < m_heap_start + m_heap_size); + AMS_ASSERT(util::IsAligned(address - m_heap_start, this->GetBlockSize())); return address; } PageEntry *GetPageEntryFromAddress(uintptr_t address) const { - AMS_ASSERT(this->heap_start <= address); - AMS_ASSERT(address < this->heap_start + this->heap_size); - return reinterpret_cast(this->heap_start + util::AlignDown(address - this->heap_start, this->GetBlockSize())); + AMS_ASSERT(m_heap_start <= address); + AMS_ASSERT(address < m_heap_start + m_heap_size); + return reinterpret_cast(m_heap_start + util::AlignDown(address - m_heap_start, this->GetBlockSize())); } s32 GetIndexFromPageEntry(const PageEntry &page_entry) const { const uintptr_t address = reinterpret_cast(std::addressof(page_entry)); - AMS_ASSERT(this->heap_start <= address); - AMS_ASSERT(address < this->heap_start + this->heap_size); - AMS_ASSERT(util::IsAligned(address - this->heap_start, this->GetBlockSize())); - return static_cast((address - this->heap_start) / this->GetBlockSize()); + AMS_ASSERT(m_heap_start <= address); + AMS_ASSERT(address < m_heap_start + m_heap_size); + AMS_ASSERT(util::IsAligned(address - m_heap_start, this->GetBlockSize())); + return static_cast((address - m_heap_start) / this->GetBlockSize()); } bool IsAlignedToOrder(const PageEntry *page_entry, s32 order) const { diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp index 676bb0a65..765acc4fe 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp @@ -34,32 +34,32 @@ namespace ams::fssystem { private: class Entry { private: - CacheHandle handle; - uintptr_t address; - size_t size; - BufferAttribute attr; + CacheHandle m_handle; + uintptr_t m_address; + size_t m_size; + BufferAttribute m_attr; public: constexpr void Initialize(CacheHandle h, uintptr_t a, size_t sz, BufferAttribute t) { - this->handle = h; - this->address = a; - this->size = sz; - this->attr = t; + m_handle = h; + m_address = a; + m_size = sz; + m_attr = t; } constexpr CacheHandle GetHandle() const { - return this->handle; + return m_handle; } constexpr uintptr_t GetAddress() const { - return this->address; + return m_address; } constexpr size_t GetSize() const { - return this->size; + return m_size; } constexpr BufferAttribute GetBufferAttribute() const { - return this->attr; + return m_attr; } }; @@ -67,41 +67,41 @@ namespace ams::fssystem { NON_COPYABLE(AttrInfo); NON_MOVEABLE(AttrInfo); private: - s32 level; - s32 cache_count; - size_t cache_size; + s32 m_level; + s32 m_cache_count; + size_t m_cache_size; public: - constexpr AttrInfo(s32 l, s32 cc, size_t cs) : level(l), cache_count(cc), cache_size(cs) { + constexpr AttrInfo(s32 l, s32 cc, size_t cs) : m_level(l), m_cache_count(cc), m_cache_size(cs) { /* ... */ } constexpr s32 GetLevel() const { - return this->level; + return m_level; } constexpr s32 GetCacheCount() const { - return this->cache_count; + return m_cache_count; } constexpr void IncrementCacheCount() { - ++this->cache_count; + ++m_cache_count; } constexpr void DecrementCacheCount() { - --this->cache_count; + --m_cache_count; } constexpr size_t GetCacheSize() const { - return this->cache_size; + return m_cache_size; } constexpr void AddCacheSize(size_t diff) { - this->cache_size += diff; + m_cache_size += diff; } constexpr void SubtractCacheSize(size_t diff) { - AMS_ASSERT(this->cache_size >= diff); - this->cache_size -= diff; + AMS_ASSERT(m_cache_size >= diff); + m_cache_size -= diff; } using Newable::operator new; @@ -114,19 +114,19 @@ namespace ams::fssystem { using AttrListTraits = util::IntrusiveListBaseTraits; using AttrList = typename AttrListTraits::ListType; private: - std::unique_ptr internal_entry_buffer; - char *external_entry_buffer; - size_t entry_buffer_size; - Entry *entries; - s32 entry_count; - s32 entry_count_max; - AttrList attr_list; - char *external_attr_info_buffer; - s32 external_attr_info_count; - s32 cache_count_min; - size_t cache_size_min; - size_t total_cache_size; - CacheHandle current_handle; + std::unique_ptr m_internal_entry_buffer; + char *m_external_entry_buffer; + size_t m_entry_buffer_size; + Entry *m_entries; + s32 m_entry_count; + s32 m_entry_count_max; + AttrList m_attr_list; + char *m_external_attr_info_buffer; + s32 m_external_attr_info_count; + s32 m_cache_count_min; + size_t m_cache_size_min; + size_t m_total_cache_size; + CacheHandle m_current_handle; public: static constexpr size_t QueryWorkBufferSize(s32 max_cache_count) { AMS_ASSERT(max_cache_count > 0); @@ -135,7 +135,7 @@ namespace ams::fssystem { return util::AlignUp(entry_size + attr_list_size + alignof(Entry) + alignof(AttrInfo), 8); } public: - CacheHandleTable() : internal_entry_buffer(), external_entry_buffer(), entry_buffer_size(), entries(), entry_count(), entry_count_max(), attr_list(), external_attr_info_buffer(), external_attr_info_count(), cache_count_min(), cache_size_min(), total_cache_size(), current_handle() { + CacheHandleTable() : m_internal_entry_buffer(), m_external_entry_buffer(), m_entry_buffer_size(), m_entries(), m_entry_count(), m_entry_count_max(), m_attr_list(), m_external_attr_info_buffer(), m_external_attr_info_count(), m_cache_count_min(), m_cache_size_min(), m_total_cache_size(), m_current_handle() { /* ... */ } @@ -146,13 +146,13 @@ namespace ams::fssystem { Result Initialize(s32 max_cache_count); Result Initialize(s32 max_cache_count, void *work, size_t work_size) { const auto aligned_entry_buf = util::AlignUp(reinterpret_cast(work), alignof(Entry)); - this->external_entry_buffer = reinterpret_cast(aligned_entry_buf); - this->entry_buffer_size = sizeof(Entry) * max_cache_count; + m_external_entry_buffer = reinterpret_cast(aligned_entry_buf); + m_entry_buffer_size = sizeof(Entry) * max_cache_count; - const auto aligned_attr_info_buf = util::AlignUp(reinterpret_cast(this->external_entry_buffer + this->entry_buffer_size), alignof(AttrInfo)); + const auto aligned_attr_info_buf = util::AlignUp(reinterpret_cast(m_external_entry_buffer + m_entry_buffer_size), alignof(AttrInfo)); const auto work_end = reinterpret_cast(work) + work_size; - this->external_attr_info_buffer = reinterpret_cast(aligned_attr_info_buf); - this->external_attr_info_count = static_cast((work_end - aligned_attr_info_buf) / sizeof(AttrInfo)); + m_external_attr_info_buffer = reinterpret_cast(aligned_attr_info_buf); + m_external_attr_info_count = static_cast((work_end - aligned_attr_info_buf) / sizeof(AttrInfo)); return ResultSuccess(); } @@ -179,22 +179,22 @@ namespace ams::fssystem { s32 GetCacheCountMin(const BufferAttribute &attr) { AMS_UNUSED(attr); - return this->cache_count_min; + return m_cache_count_min; } size_t GetCacheSizeMin(const BufferAttribute &attr) { AMS_UNUSED(attr); - return this->cache_size_min; + return m_cache_size_min; } }; private: - BuddyHeap buddy_heap; - CacheHandleTable cache_handle_table; - size_t total_size; - size_t peak_free_size; - size_t peak_total_allocatable_size; - size_t retried_count; - mutable os::SdkRecursiveMutex mutex; + BuddyHeap m_buddy_heap; + CacheHandleTable m_cache_handle_table; + size_t m_total_size; + size_t m_peak_free_size; + size_t m_peak_total_allocatable_size; + size_t m_retried_count; + mutable os::SdkRecursiveMutex m_mutex; public: static constexpr size_t QueryWorkBufferSize(s32 max_cache_count, s32 max_order) { const auto buddy_size = FileSystemBuddyHeap::QueryWorkBufferSize(max_order); @@ -202,30 +202,30 @@ namespace ams::fssystem { return buddy_size + table_size; } public: - FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex() { /* ... */ } + FileSystemBufferManager() : m_total_size(), m_peak_free_size(), m_peak_total_allocatable_size(), m_retried_count(), m_mutex() { /* ... */ } virtual ~FileSystemBufferManager() { /* ... */ } Result Initialize(s32 max_cache_count, uintptr_t address, size_t buffer_size, size_t block_size) { AMS_ASSERT(buffer_size > 0); - R_TRY(this->cache_handle_table.Initialize(max_cache_count)); - R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size)); + R_TRY(m_cache_handle_table.Initialize(max_cache_count)); + R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size)); - this->total_size = this->buddy_heap.GetTotalFreeSize(); - this->peak_free_size = this->total_size; - this->peak_total_allocatable_size = this->total_size; + m_total_size = m_buddy_heap.GetTotalFreeSize(); + m_peak_free_size = m_total_size; + m_peak_total_allocatable_size = m_total_size; return ResultSuccess(); } Result Initialize(s32 max_cache_count, uintptr_t address, size_t buffer_size, size_t block_size, s32 max_order) { AMS_ASSERT(buffer_size > 0); - R_TRY(this->cache_handle_table.Initialize(max_cache_count)); - R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, max_order)); + R_TRY(m_cache_handle_table.Initialize(max_cache_count)); + R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, max_order)); - this->total_size = this->buddy_heap.GetTotalFreeSize(); - this->peak_free_size = this->total_size; - this->peak_total_allocatable_size = this->total_size; + m_total_size = m_buddy_heap.GetTotalFreeSize(); + m_peak_free_size = m_total_size; + m_peak_total_allocatable_size = m_total_size; return ResultSuccess(); } @@ -237,12 +237,12 @@ namespace ams::fssystem { const auto table_buffer = static_cast(work); const auto buddy_buffer = table_buffer + table_size; - R_TRY(this->cache_handle_table.Initialize(max_cache_count, table_buffer, table_size)); - R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, buddy_buffer, buddy_size)); + R_TRY(m_cache_handle_table.Initialize(max_cache_count, table_buffer, table_size)); + R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, buddy_buffer, buddy_size)); - this->total_size = this->buddy_heap.GetTotalFreeSize(); - this->peak_free_size = this->total_size; - this->peak_total_allocatable_size = this->total_size; + m_total_size = m_buddy_heap.GetTotalFreeSize(); + m_peak_free_size = m_total_size; + m_peak_total_allocatable_size = m_total_size; return ResultSuccess(); } @@ -254,19 +254,19 @@ namespace ams::fssystem { const auto table_buffer = static_cast(work); const auto buddy_buffer = table_buffer + table_size; - R_TRY(this->cache_handle_table.Initialize(max_cache_count, table_buffer, table_size)); - R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, max_order, buddy_buffer, buddy_size)); + R_TRY(m_cache_handle_table.Initialize(max_cache_count, table_buffer, table_size)); + R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, max_order, buddy_buffer, buddy_size)); - this->total_size = this->buddy_heap.GetTotalFreeSize(); - this->peak_free_size = this->total_size; - this->peak_total_allocatable_size = this->total_size; + m_total_size = m_buddy_heap.GetTotalFreeSize(); + m_peak_free_size = m_total_size; + m_peak_total_allocatable_size = m_total_size; return ResultSuccess(); } void Finalize() { - this->buddy_heap.Finalize(); - this->cache_handle_table.Finalize(); + m_buddy_heap.Finalize(); + m_cache_handle_table.Finalize(); } private: virtual const std::pair AllocateBufferImpl(size_t size, const BufferAttribute &attr) override; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_i_buffer_manager.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_i_buffer_manager.hpp index 7c95d6143..c13dcfa62 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_i_buffer_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/buffers/fssystem_i_buffer_manager.hpp @@ -22,12 +22,12 @@ namespace ams::fssystem { public: class BufferAttribute { private: - s32 level; + s32 m_level; public: - constexpr BufferAttribute() : level(0) { /* ... */ } - constexpr explicit BufferAttribute(s32 l) : level(l) { /* ... */ } + constexpr BufferAttribute() : m_level(0) { /* ... */ } + constexpr explicit BufferAttribute(s32 l) : m_level(l) { /* ... */ } - constexpr s32 GetLevel() const { return this->level; } + constexpr s32 GetLevel() const { return m_level; } }; using CacheHandle = s64; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp index 8e8c891c7..1ca5828d6 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp @@ -74,27 +74,27 @@ namespace ams::fssystem { static Result CreateExternalDecryptor(std::unique_ptr *out, DecryptFunction func, s32 key_index); static Result CreateSoftwareDecryptor(std::unique_ptr *out); private: - BucketTree table; - fs::SubStorage data_storage; - u8 key[KeySize]; - u32 secure_value; - s64 counter_offset; - std::unique_ptr decryptor; + BucketTree m_table; + fs::SubStorage m_data_storage; + u8 m_key[KeySize]; + u32 m_secure_value; + s64 m_counter_offset; + std::unique_ptr m_decryptor; public: - AesCtrCounterExtendedStorage() : table(), data_storage(), secure_value(), counter_offset(), decryptor() { /* ... */ } + AesCtrCounterExtendedStorage() : m_table(), m_data_storage(), m_secure_value(), m_counter_offset(), m_decryptor() { /* ... */ } virtual ~AesCtrCounterExtendedStorage() { this->Finalize(); } Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, s64 counter_offset, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count, std::unique_ptr &&decryptor); void Finalize(); - bool IsInitialized() const { return this->table.IsInitialized(); } + bool IsInitialized() const { return m_table.IsInitialized(); } virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override; virtual Result GetSize(s64 *out) override { AMS_ASSERT(out != nullptr); - *out = this->table.GetSize(); + *out = m_table.GetSize(); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage.hpp index 3be4d075b..ab23078f5 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage.hpp @@ -28,9 +28,9 @@ namespace ams::fssystem { static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize; static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize; private: - IStorage * const base_storage; - char key[KeySize]; - char iv[IvSize]; + IStorage * const m_base_storage; + char m_key[KeySize]; + char m_iv[IvSize]; public: static void MakeIv(void *dst, size_t dst_size, u64 upper, s64 offset); public: diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp index c181209bb..2d5a23b6c 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp @@ -29,11 +29,11 @@ namespace ams::fssystem { static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize; static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize; private: - IStorage * const base_storage; - char key[2][KeySize]; - char iv[IvSize]; - const size_t block_size; - os::SdkMutex mutex; + IStorage * const m_base_storage; + char m_key[2][KeySize]; + char m_iv[IvSize]; + const size_t m_block_size; + os::SdkMutex m_mutex; public: AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp index bc5cff044..b36985e67 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp @@ -35,16 +35,16 @@ namespace ams::fssystem { static_assert(util::IsPowerOfTwo(DataAlign)); static_assert(util::IsPowerOfTwo(BufferAlign)); private: - std::shared_ptr shared_base_storage; - fs::IStorage * const base_storage; - s64 base_storage_size; - bool is_base_storage_size_dirty; + std::shared_ptr m_shared_base_storage; + fs::IStorage * const m_base_storage; + s64 m_base_storage_size; + bool m_is_base_storage_size_dirty; public: - explicit AlignmentMatchingStorage(fs::IStorage *bs) : base_storage(bs), is_base_storage_size_dirty(true) { + explicit AlignmentMatchingStorage(fs::IStorage *bs) : m_base_storage(bs), m_is_base_storage_size_dirty(true) { /* ... */ } - explicit AlignmentMatchingStorage(std::shared_ptr bs) : shared_base_storage(bs), base_storage(shared_base_storage.get()), is_base_storage_size_dirty(true) { + explicit AlignmentMatchingStorage(std::shared_ptr bs) : m_shared_base_storage(bs), m_base_storage(m_shared_base_storage.get()), m_is_base_storage_size_dirty(true) { /* ... */ } @@ -63,7 +63,7 @@ namespace ams::fssystem { R_TRY(this->GetSize(std::addressof(bs_size))); R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); - return AlignmentMatchingStorageImpl::Read(this->base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); + return AlignmentMatchingStorageImpl::Read(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { @@ -81,30 +81,30 @@ namespace ams::fssystem { R_TRY(this->GetSize(std::addressof(bs_size))); R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); - return AlignmentMatchingStorageImpl::Write(this->base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); + return AlignmentMatchingStorageImpl::Write(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast(buffer), size); } virtual Result Flush() override { - return this->base_storage->Flush(); + return m_base_storage->Flush(); } virtual Result SetSize(s64 size) override { - ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; }; - return this->base_storage->SetSize(util::AlignUp(size, DataAlign)); + ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; }; + return m_base_storage->SetSize(util::AlignUp(size, DataAlign)); } virtual Result GetSize(s64 *out) override { AMS_ASSERT(out != nullptr); - if (this->is_base_storage_size_dirty) { + if (m_is_base_storage_size_dirty) { s64 size; - R_TRY(this->base_storage->GetSize(std::addressof(size))); + R_TRY(m_base_storage->GetSize(std::addressof(size))); - this->base_storage_size = size; - this->is_base_storage_size_dirty = false; + m_base_storage_size = size; + m_is_base_storage_size_dirty = false; } - *out = this->base_storage_size; + *out = m_base_storage_size; return ResultSuccess(); } @@ -123,7 +123,7 @@ namespace ams::fssystem { const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign); const auto aligned_size = aligned_offset_end - aligned_offset; - return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); } }; @@ -136,12 +136,12 @@ namespace ams::fssystem { static_assert(util::IsPowerOfTwo(BufferAlign)); private: - fs::IStorage * const base_storage; - s64 base_storage_size; - size_t data_align; - bool is_base_storage_size_dirty; + fs::IStorage * const m_base_storage; + s64 m_base_storage_size; + size_t m_data_align; + bool m_is_base_storage_size_dirty; public: - explicit AlignmentMatchingStoragePooledBuffer(fs::IStorage *bs, size_t da) : base_storage(bs), data_align(da), is_base_storage_size_dirty(true) { + explicit AlignmentMatchingStoragePooledBuffer(fs::IStorage *bs, size_t da) : m_base_storage(bs), m_data_align(da), m_is_base_storage_size_dirty(true) { AMS_ASSERT(util::IsPowerOfTwo(da)); } @@ -158,9 +158,9 @@ namespace ams::fssystem { /* Allocate a pooled buffer. */ PooledBuffer pooled_buffer; - pooled_buffer.AllocateParticularlyLarge(this->data_align, this->data_align); + pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align); - return AlignmentMatchingStorageImpl::Read(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast(buffer), size); + return AlignmentMatchingStorageImpl::Read(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { @@ -176,32 +176,32 @@ namespace ams::fssystem { /* Allocate a pooled buffer. */ PooledBuffer pooled_buffer; - pooled_buffer.AllocateParticularlyLarge(this->data_align, this->data_align); + pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align); - return AlignmentMatchingStorageImpl::Write(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast(buffer), size); + return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); } virtual Result Flush() override { - return this->base_storage->Flush(); + return m_base_storage->Flush(); } virtual Result SetSize(s64 size) override { - ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; }; - return this->base_storage->SetSize(util::AlignUp(size, this->data_align)); + ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; }; + return m_base_storage->SetSize(util::AlignUp(size, m_data_align)); } virtual Result GetSize(s64 *out) override { AMS_ASSERT(out != nullptr); - if (this->is_base_storage_size_dirty) { + if (m_is_base_storage_size_dirty) { s64 size; - R_TRY(this->base_storage->GetSize(std::addressof(size))); + R_TRY(m_base_storage->GetSize(std::addressof(size))); - this->base_storage_size = size; - this->is_base_storage_size_dirty = false; + m_base_storage_size = size; + m_is_base_storage_size_dirty = false; } - *out = this->base_storage_size; + *out = m_base_storage_size; return ResultSuccess(); } @@ -216,11 +216,11 @@ namespace ams::fssystem { /* Operate on the base storage. */ const auto valid_size = std::min(size, bs_size - offset); - const auto aligned_offset = util::AlignDown(offset, this->data_align); - const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align); + const auto aligned_offset = util::AlignDown(offset, m_data_align); + const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align); const auto aligned_size = aligned_offset_end - aligned_offset; - return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); } }; @@ -233,16 +233,16 @@ namespace ams::fssystem { static_assert(util::IsPowerOfTwo(BufferAlign)); private: - std::shared_ptr shared_base_storage; - fs::IStorage * const base_storage; - s64 base_storage_size; - size_t data_align; + std::shared_ptr m_shared_base_storage; + fs::IStorage * const m_base_storage; + s64 m_base_storage_size; + size_t m_data_align; public: - explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : shared_base_storage(), base_storage(bs), base_storage_size(-1), data_align(da) { - AMS_ASSERT(util::IsPowerOfTwo(this->data_align)); + explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : m_shared_base_storage(), m_base_storage(bs), m_base_storage_size(-1), m_data_align(da) { + AMS_ASSERT(util::IsPowerOfTwo(m_data_align)); } - explicit AlignmentMatchingStorageInBulkRead(std::shared_ptr bs, size_t da) : shared_base_storage(bs), base_storage(shared_base_storage.get()), base_storage_size(-1), data_align(da) { + explicit AlignmentMatchingStorageInBulkRead(std::shared_ptr bs, size_t da) : m_shared_base_storage(bs), m_base_storage(m_shared_base_storage.get()), m_base_storage_size(-1), m_data_align(da) { AMS_ASSERT(util::IsPowerOfTwo(da)); } @@ -260,30 +260,30 @@ namespace ams::fssystem { R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); /* Allocate a pooled buffer. */ - PooledBuffer pooled_buffer(this->data_align, this->data_align); - return AlignmentMatchingStorageImpl::Write(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast(buffer), size); + PooledBuffer pooled_buffer(m_data_align, m_data_align); + return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast(buffer), size); } virtual Result Flush() override { - return this->base_storage->Flush(); + return m_base_storage->Flush(); } virtual Result SetSize(s64 size) override { - ON_SCOPE_EXIT { this->base_storage_size = -1; }; - return this->base_storage->SetSize(util::AlignUp(size, this->data_align)); + ON_SCOPE_EXIT { m_base_storage_size = -1; }; + return m_base_storage->SetSize(util::AlignUp(size, m_data_align)); } virtual Result GetSize(s64 *out) override { AMS_ASSERT(out != nullptr); - if (this->base_storage_size < 0) { + if (m_base_storage_size < 0) { s64 size; - R_TRY(this->base_storage->GetSize(std::addressof(size))); + R_TRY(m_base_storage->GetSize(std::addressof(size))); - this->base_storage_size = size; + m_base_storage_size = size; } - *out = this->base_storage_size; + *out = m_base_storage_size; return ResultSuccess(); } @@ -298,11 +298,11 @@ namespace ams::fssystem { /* Operate on the base storage. */ const auto valid_size = std::min(size, bs_size - offset); - const auto aligned_offset = util::AlignDown(offset, this->data_align); - const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align); + const auto aligned_offset = util::AlignDown(offset, m_data_align); + const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align); const auto aligned_size = aligned_offset_end - aligned_offset; - return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree.hpp index 66cada0ec..a289c2b19 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree.hpp @@ -55,24 +55,24 @@ namespace ams::fssystem { class ContinuousReadingInfo { private: - size_t read_size; - s32 skip_count; - bool done; + size_t m_read_size; + s32 m_skip_count; + bool m_done; public: - constexpr ContinuousReadingInfo() : read_size(), skip_count(), done() { /* ... */ } + constexpr ContinuousReadingInfo() : m_read_size(), m_skip_count(), m_done() { /* ... */ } - constexpr void Reset() { this->read_size = 0; this->skip_count = 0; this->done = false; } + constexpr void Reset() { m_read_size = 0; m_skip_count = 0; m_done = false; } - constexpr void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); this->skip_count = count; } - constexpr s32 GetSkipCount() const { return this->skip_count; } - constexpr bool CheckNeedScan() { return (--this->skip_count) <= 0; } + constexpr void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); m_skip_count = count; } + constexpr s32 GetSkipCount() const { return m_skip_count; } + constexpr bool CheckNeedScan() { return (--m_skip_count) <= 0; } - constexpr void Done() { this->read_size = 0; this->done = true; } - constexpr bool IsDone() const { return this->done; } + constexpr void Done() { m_read_size = 0; m_done = true; } + constexpr bool IsDone() const { return m_done; } - constexpr void SetReadSize(size_t size) { this->read_size = size; } - constexpr size_t GetReadSize() const { return this->read_size; } - constexpr bool CanDo() const { return this->read_size > 0; } + constexpr void SetReadSize(size_t size) { m_read_size = size; } + constexpr size_t GetReadSize() const { return m_read_size; } + constexpr bool CanDo() const { return m_read_size > 0; } }; using IAllocator = MemoryResource; @@ -80,60 +80,60 @@ namespace ams::fssystem { class NodeBuffer { NON_COPYABLE(NodeBuffer); private: - IAllocator *allocator; - void *header; + IAllocator *m_allocator; + void *m_header; public: - NodeBuffer() : allocator(), header() { /* ... */ } + NodeBuffer() : m_allocator(), m_header() { /* ... */ } ~NodeBuffer() { - AMS_ASSERT(this->header == nullptr); + AMS_ASSERT(m_header == nullptr); } - NodeBuffer(NodeBuffer &&rhs) : allocator(rhs.allocator), header(rhs.allocator) { - rhs.allocator = nullptr; - rhs.header = nullptr; + NodeBuffer(NodeBuffer &&rhs) : m_allocator(rhs.m_allocator), m_header(rhs.m_allocator) { + rhs.m_allocator = nullptr; + rhs.m_header = nullptr; } NodeBuffer &operator=(NodeBuffer &&rhs) { if (this != std::addressof(rhs)) { - AMS_ASSERT(this->header == nullptr); + AMS_ASSERT(m_header == nullptr); - this->allocator = rhs.allocator; - this->header = rhs.header; + m_allocator = rhs.m_allocator; + m_header = rhs.m_header; - rhs.allocator = nullptr; - rhs.header = nullptr; + rhs.m_allocator = nullptr; + rhs.m_header = nullptr; } return *this; } bool Allocate(IAllocator *allocator, size_t node_size) { - AMS_ASSERT(this->header == nullptr); + AMS_ASSERT(m_header == nullptr); - this->allocator = allocator; - this->header = allocator->Allocate(node_size, sizeof(s64)); + m_allocator = allocator; + m_header = allocator->Allocate(node_size, sizeof(s64)); - AMS_ASSERT(util::IsAligned(this->header, sizeof(s64))); + AMS_ASSERT(util::IsAligned(m_header, sizeof(s64))); - return this->header != nullptr; + return m_header != nullptr; } void Free(size_t node_size) { - if (this->header) { - this->allocator->Deallocate(this->header, node_size); - this->header = nullptr; + if (m_header) { + m_allocator->Deallocate(m_header, node_size); + m_header = nullptr; } - this->allocator = nullptr; + m_allocator = nullptr; } void FillZero(size_t node_size) const { - if (this->header) { - std::memset(this->header, 0, node_size); + if (m_header) { + std::memset(m_header, 0, node_size); } } NodeHeader *Get() const { - return reinterpret_cast(this->header); + return reinterpret_cast(m_header); } NodeHeader *operator->() const { return this->Get(); } @@ -142,11 +142,11 @@ namespace ams::fssystem { T *Get() const { static_assert(util::is_pod::value); static_assert(sizeof(T) == sizeof(NodeHeader)); - return reinterpret_cast(this->header); + return reinterpret_cast(m_header); } IAllocator *GetAllocator() const { - return this->allocator; + return m_allocator; } }; private: @@ -205,43 +205,43 @@ namespace ams::fssystem { return GetEntrySetCount(node_size, entry_size, entry_count) * static_cast(node_size); } private: - mutable fs::SubStorage node_storage; - mutable fs::SubStorage entry_storage; - NodeBuffer node_l1; - size_t node_size; - size_t entry_size; - s32 entry_count; - s32 offset_count; - s32 entry_set_count; - s64 start_offset; - s64 end_offset; + mutable fs::SubStorage m_node_storage; + mutable fs::SubStorage m_entry_storage; + NodeBuffer m_node_l1; + size_t m_node_size; + size_t m_entry_size; + s32 m_entry_count; + s32 m_offset_count; + s32 m_entry_set_count; + s64 m_start_offset; + s64 m_end_offset; public: - BucketTree() : node_storage(), entry_storage(), node_l1(), node_size(), entry_size(), entry_count(), offset_count(), entry_set_count(), start_offset(), end_offset() { /* ... */ } + BucketTree() : m_node_storage(), m_entry_storage(), m_node_l1(), m_node_size(), m_entry_size(), m_entry_count(), m_offset_count(), m_entry_set_count(), m_start_offset(), m_end_offset() { /* ... */ } ~BucketTree() { this->Finalize(); } Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, size_t node_size, size_t entry_size, s32 entry_count); void Initialize(size_t node_size, s64 end_offset); void Finalize(); - bool IsInitialized() const { return this->node_size > 0; } - bool IsEmpty() const { return this->entry_size == 0; } + bool IsInitialized() const { return m_node_size > 0; } + bool IsEmpty() const { return m_entry_size == 0; } Result Find(Visitor *visitor, s64 virtual_address) const; Result InvalidateCache(); - s32 GetEntryCount() const { return this->entry_count; } - IAllocator *GetAllocator() const { return this->node_l1.GetAllocator(); } + s32 GetEntryCount() const { return m_entry_count; } + IAllocator *GetAllocator() const { return m_node_l1.GetAllocator(); } - s64 GetStart() const { return this->start_offset; } - s64 GetEnd() const { return this->end_offset; } - s64 GetSize() const { return this->end_offset - this->start_offset; } + s64 GetStart() const { return m_start_offset; } + s64 GetEnd() const { return m_end_offset; } + s64 GetSize() const { return m_end_offset - m_start_offset; } bool Includes(s64 offset) const { - return this->start_offset <= offset && offset < this->end_offset; + return m_start_offset <= offset && offset < m_end_offset; } bool Includes(s64 offset, s64 size) const { - return size > 0 && this->start_offset <= offset && size <= this->end_offset - offset; + return size > 0 && m_start_offset <= offset && size <= m_end_offset - offset; } private: template @@ -256,11 +256,11 @@ namespace ams::fssystem { template Result ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam ¶m) const; - bool IsExistL2() const { return this->offset_count < this->entry_set_count; } - bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && this->node_l1->count < this->offset_count; } + bool IsExistL2() const { return m_offset_count < m_entry_set_count; } + bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && m_node_l1->count < m_offset_count; } s64 GetEntrySetIndex(s32 node_index, s32 offset_index) const { - return (this->offset_count - this->node_l1->count) + (this->offset_count * node_index) + offset_index; + return (m_offset_count - m_node_l1->count) + (m_offset_count * node_index) + offset_index; } }; @@ -282,24 +282,24 @@ namespace ams::fssystem { }; static_assert(util::is_pod::value); private: - const BucketTree *tree; - void *entry; - s32 entry_index; - s32 entry_set_count; - EntrySetHeader entry_set; + const BucketTree *m_tree; + void *m_entry; + s32 m_entry_index; + s32 m_entry_set_count; + EntrySetHeader m_entry_set; public: - constexpr Visitor() : tree(), entry(), entry_index(-1), entry_set_count(), entry_set{} { /* ... */ } + constexpr Visitor() : m_tree(), m_entry(), m_entry_index(-1), m_entry_set_count(), m_entry_set{} { /* ... */ } ~Visitor() { - if (this->entry != nullptr) { - this->tree->GetAllocator()->Deallocate(this->entry, this->tree->entry_size); - this->tree = nullptr; - this->entry = nullptr; + if (m_entry != nullptr) { + m_tree->GetAllocator()->Deallocate(m_entry, m_tree->m_entry_size); + m_tree = nullptr; + m_entry = nullptr; } } - bool IsValid() const { return this->entry_index >= 0; } - bool CanMoveNext() const { return this->IsValid() && (this->entry_index + 1 < this->entry_set.info.count || this->entry_set.info.index + 1 < this->entry_set_count); } - bool CanMovePrevious() const { return this->IsValid() && (this->entry_index > 0 || this->entry_set.info.index > 0); } + bool IsValid() const { return m_entry_index >= 0; } + bool CanMoveNext() const { return this->IsValid() && (m_entry_index + 1 < m_entry_set.info.count || m_entry_set.info.index + 1 < m_entry_set_count); } + bool CanMovePrevious() const { return this->IsValid() && (m_entry_index > 0 || m_entry_set.info.index > 0); } Result MoveNext(); Result MovePrevious(); @@ -307,12 +307,12 @@ namespace ams::fssystem { template Result ScanContinuousReading(ContinuousReadingInfo *out_info, s64 offset, size_t size) const; - const void *Get() const { AMS_ASSERT(this->IsValid()); return this->entry; } + const void *Get() const { AMS_ASSERT(this->IsValid()); return m_entry; } template - const T *Get() const { AMS_ASSERT(this->IsValid()); return reinterpret_cast(this->entry); } + const T *Get() const { AMS_ASSERT(this->IsValid()); return reinterpret_cast(m_entry); } - const BucketTree *GetTree() const { return this->tree; } + const BucketTree *GetTree() const { return m_tree; } private: Result Initialize(const BucketTree *tree); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp index 685331570..3dc024a09 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp @@ -27,7 +27,7 @@ namespace ams::fssystem { /* Validate our preconditions. */ AMS_ASSERT(this->IsInitialized()); AMS_ASSERT(out_info != nullptr); - AMS_ASSERT(this->entry_size == sizeof(EntryType)); + AMS_ASSERT(m_entry_size == sizeof(EntryType)); /* Reset the output. */ out_info->Reset(); @@ -44,14 +44,14 @@ namespace ams::fssystem { R_UNLESS(entry.GetVirtualOffset() <= cur_offset, fs::ResultOutOfRange()); /* Create a pooled buffer for our scan. */ - PooledBuffer pool(this->node_size, 1); + PooledBuffer pool(m_node_size, 1); char *buffer = nullptr; /* Read the node. */ - if (this->node_size <= pool.GetSize()) { + if (m_node_size <= pool.GetSize()) { buffer = pool.GetBuffer(); - const auto ofs = param.entry_set.index * static_cast(this->node_size); - R_TRY(this->entry_storage.Read(ofs, buffer, this->node_size)); + const auto ofs = param.entry_set.index * static_cast(m_node_size); + R_TRY(m_entry_storage.Read(ofs, buffer, m_node_size)); } /* Calculate extents. */ @@ -81,11 +81,11 @@ namespace ams::fssystem { if (entry_index + 1 < entry_count) { if (buffer != nullptr) { - const auto ofs = impl::GetBucketTreeEntryOffset(0, this->entry_size, entry_index + 1); - std::memcpy(std::addressof(next_entry), buffer + ofs, this->entry_size); + const auto ofs = impl::GetBucketTreeEntryOffset(0, m_entry_size, entry_index + 1); + std::memcpy(std::addressof(next_entry), buffer + ofs, m_entry_size); } else { - const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, this->node_size, this->entry_size, entry_index + 1); - R_TRY(this->entry_storage.Read(ofs, std::addressof(next_entry), this->entry_size)); + const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, m_node_size, m_entry_size, entry_index + 1); + R_TRY(m_entry_storage.Read(ofs, std::addressof(next_entry), m_entry_size)); } next_entry_offset = next_entry.GetVirtualOffset(); @@ -154,12 +154,12 @@ namespace ams::fssystem { /* Create our parameters. */ ContinuousReadingParam param = { - offset, size, this->entry_set.header, this->entry_index + offset, size, m_entry_set.header, m_entry_index }; - std::memcpy(std::addressof(param.entry), this->entry, sizeof(EntryType)); + std::memcpy(std::addressof(param.entry), m_entry, sizeof(EntryType)); /* Scan. */ - return this->tree->ScanContinuousReading(out_info, param); + return m_tree->ScanContinuousReading(out_info, param); } } diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp index 1b6f30c0c..b531cca72 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp @@ -24,10 +24,10 @@ namespace ams::fssystem { using PathResolutionFileSystem = impl::IPathResolutionFileSystem; friend class impl::IPathResolutionFileSystem; private: - char *before_dir; - size_t before_dir_len; - char *after_dir; - size_t after_dir_len; + char *m_before_dir; + size_t m_before_dir_len; + char *m_after_dir; + size_t m_after_dir_len; public: DirectoryRedirectionFileSystem(std::shared_ptr fs, const char *before, const char *after, bool unc = false); DirectoryRedirectionFileSystem(std::unique_ptr fs, const char *before, const char *after, bool unc = false); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp index 3e0a5febd..dd32a611c 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp @@ -24,8 +24,8 @@ namespace ams::fssystem { using PathResolutionFileSystem = impl::IPathResolutionFileSystem; friend class impl::IPathResolutionFileSystem; private: - os::SdkMutex accessor_mutex; - s32 open_writable_files; + os::SdkMutex m_accessor_mutex; + s32 m_open_writable_files; public: DirectorySaveDataFileSystem(std::shared_ptr fs); DirectorySaveDataFileSystem(std::unique_ptr fs); @@ -35,7 +35,7 @@ namespace ams::fssystem { protected: inline util::optional> GetAccessorLock() { /* We have a real accessor lock that we want to use. */ - return util::make_optional>(this->accessor_mutex); + return util::make_optional>(m_accessor_mutex); } private: Result AllocateWorkBuffer(std::unique_ptr *out, size_t *out_size, size_t ideal_size); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp index c1145ec4b..293c91be1 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp @@ -100,30 +100,30 @@ namespace ams::fssystem { return BucketTree::QueryEntryStorageSize(NodeSize, sizeof(Entry), entry_count); } private: - BucketTree table; - fs::SubStorage data_storage[StorageCount]; + BucketTree m_table; + fs::SubStorage m_data_storage[StorageCount]; public: - IndirectStorage() : table(), data_storage() { /* ... */ } + IndirectStorage() : m_table(), m_data_storage() { /* ... */ } virtual ~IndirectStorage() { this->Finalize(); } Result Initialize(IAllocator *allocator, fs::SubStorage table_storage); void Finalize(); - bool IsInitialized() const { return this->table.IsInitialized(); } + bool IsInitialized() const { return m_table.IsInitialized(); } Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count) { - return this->table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count); + return m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count); } void SetStorage(s32 idx, fs::SubStorage storage) { AMS_ASSERT(0 <= idx && idx < StorageCount); - this->data_storage[idx] = storage; + m_data_storage[idx] = storage; } template void SetStorage(s32 idx, T storage, s64 offset, s64 size) { AMS_ASSERT(0 <= idx && idx < StorageCount); - this->data_storage[idx] = fs::SubStorage(storage, offset, size); + m_data_storage[idx] = fs::SubStorage(storage, offset, size); } Result GetEntryList(Entry *out_entries, s32 *out_entry_count, s32 entry_count, s64 offset, s64 size); @@ -133,7 +133,7 @@ namespace ams::fssystem { virtual Result GetSize(s64 *out) override { AMS_ASSERT(out != nullptr); - *out = this->table.GetEnd(); + *out = m_table.GetEnd(); return ResultSuccess(); } @@ -151,11 +151,11 @@ namespace ams::fssystem { return fs::ResultUnsupportedOperationInIndirectStorageB(); } protected: - BucketTree &GetEntryTable() { return this->table; } + BucketTree &GetEntryTable() { return m_table; } fs::SubStorage &GetDataStorage(s32 index) { AMS_ASSERT(0 <= index && index < StorageCount); - return this->data_storage[index]; + return m_data_storage[index]; } template diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage_template_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage_template_impl.hpp index dcb047dc6..f241c0b57 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage_template_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage_template_impl.hpp @@ -29,14 +29,14 @@ namespace ams::fssystem { R_SUCCEED_IF(size == 0); /* Validate arguments. */ - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); /* Find the offset in our tree. */ BucketTree::Visitor visitor; - R_TRY(this->table.Find(std::addressof(visitor), offset)); + R_TRY(m_table.Find(std::addressof(visitor), offset)); { const auto entry_offset = visitor.Get()->GetVirtualOffset(); - R_UNLESS(0 <= entry_offset && this->table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset()); + R_UNLESS(0 <= entry_offset && m_table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset()); } /* Prepare to operate in chunks. */ @@ -69,7 +69,7 @@ namespace ams::fssystem { /* Get the current data storage's size. */ s64 cur_data_storage_size; - R_TRY(this->data_storage[0].GetSize(std::addressof(cur_data_storage_size))); + R_TRY(m_data_storage[0].GetSize(std::addressof(cur_data_storage_size))); /* Ensure that we remain within range. */ const auto data_offset = cur_offset - cur_entry_offset; @@ -79,7 +79,7 @@ namespace ams::fssystem { R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultInvalidIndirectStorageSize()); /* Operate. */ - R_TRY(func(std::addressof(this->data_storage[0]), cur_entry_phys_offset + data_offset, cur_offset, cur_size)); + R_TRY(func(std::addressof(m_data_storage[0]), cur_entry_phys_offset + data_offset, cur_offset, cur_size)); /* Mark as done. */ cr_info.Done(); @@ -91,9 +91,9 @@ namespace ams::fssystem { if (visitor.CanMoveNext()) { R_TRY(visitor.MoveNext()); next_entry_offset = visitor.Get()->GetVirtualOffset(); - R_UNLESS(this->table.Includes(next_entry_offset), fs::ResultInvalidIndirectEntryOffset()); + R_UNLESS(m_table.Includes(next_entry_offset), fs::ResultInvalidIndirectEntryOffset()); } else { - next_entry_offset = this->table.GetEnd(); + next_entry_offset = m_table.GetEnd(); } R_UNLESS(cur_offset < next_entry_offset, fs::ResultInvalidIndirectEntryOffset()); @@ -118,14 +118,14 @@ namespace ams::fssystem { if (needs_operate) { /* Get the current data storage's size. */ s64 cur_data_storage_size; - R_TRY(this->data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size))); + R_TRY(m_data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size))); /* Ensure that we remain within range. */ const auto cur_entry_phys_offset = cur_entry.GetPhysicalOffset(); R_UNLESS(0 <= cur_entry_phys_offset && cur_entry_phys_offset <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted()); R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted()); - R_TRY(func(std::addressof(this->data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size)); + R_TRY(func(std::addressof(m_data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size)); } cur_offset += cur_size; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp index 2ef964bbb..4e585476a 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp @@ -28,46 +28,46 @@ namespace ams::fssystem { class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable { private: - save::HierarchicalIntegrityVerificationStorage integrity_storage; - save::FileSystemBufferManagerSet buffers; - os::SdkRecursiveMutex mutex; - Hash master_hash; - std::unique_ptr master_hash_storage; + save::HierarchicalIntegrityVerificationStorage m_integrity_storage; + save::FileSystemBufferManagerSet m_buffers; + os::SdkRecursiveMutex m_mutex; + Hash m_master_hash; + std::unique_ptr m_master_hash_storage; public: - IntegrityRomFsStorage() : mutex() { /* ... */ } + IntegrityRomFsStorage() : m_mutex() { /* ... */ } virtual ~IntegrityRomFsStorage() override { this->Finalize(); } Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm); void Finalize(); virtual Result Read(s64 offset, void *buffer, size_t size) override { - return this->integrity_storage.Read(offset, buffer, size); + return m_integrity_storage.Read(offset, buffer, size); } virtual Result Write(s64 offset, const void *buffer, size_t size) override { - return this->integrity_storage.Write(offset, buffer, size); + return m_integrity_storage.Write(offset, buffer, size); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedOperationInIntegrityRomFsStorageA(); } virtual Result GetSize(s64 *out) override { - return this->integrity_storage.GetSize(out); + return m_integrity_storage.GetSize(out); } virtual Result Flush() override { - return this->integrity_storage.Flush(); + return m_integrity_storage.Flush(); } virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return this->integrity_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_integrity_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } Result Commit() { - return this->integrity_storage.Commit(); + return m_integrity_storage.Commit(); } save::FileSystemBufferManagerSet *GetBuffers() { - return this->integrity_storage.GetBuffers(); + return m_integrity_storage.GetBuffers(); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp index b9a427f60..bc8d3b73d 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp @@ -85,16 +85,16 @@ namespace ams::fssystem { NON_COPYABLE(NcaReader); NON_MOVEABLE(NcaReader); private: - NcaHeader header; - u8 decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize]; - std::shared_ptr shared_base_storage; - std::unique_ptr header_storage; - fs::IStorage *body_storage; - u8 external_decryption_key[NcaCryptoConfiguration::Aes128KeySize]; - DecryptAesCtrFunction decrypt_aes_ctr; - DecryptAesCtrFunction decrypt_aes_ctr_external; - bool is_software_aes_prioritized; - NcaHeader::EncryptionType header_encryption_type; + NcaHeader m_header; + u8 m_decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize]; + std::shared_ptr m_shared_base_storage; + std::unique_ptr m_header_storage; + fs::IStorage *m_body_storage; + u8 m_external_decryption_key[NcaCryptoConfiguration::Aes128KeySize]; + DecryptAesCtrFunction m_decrypt_aes_ctr; + DecryptAesCtrFunction m_decrypt_aes_ctr_external; + bool m_is_software_aes_prioritized; + NcaHeader::EncryptionType m_header_encryption_type; public: NcaReader(); ~NcaReader(); @@ -143,18 +143,18 @@ namespace ams::fssystem { NON_COPYABLE(NcaFsHeaderReader); NON_MOVEABLE(NcaFsHeaderReader); private: - NcaFsHeader data; - s32 fs_index; + NcaFsHeader m_data; + s32 m_fs_index; public: - NcaFsHeaderReader() : fs_index(-1) { - std::memset(std::addressof(this->data), 0, sizeof(this->data)); + NcaFsHeaderReader() : m_fs_index(-1) { + std::memset(std::addressof(m_data), 0, sizeof(m_data)); } Result Initialize(const NcaReader &reader, s32 index); - bool IsInitialized() const { return this->fs_index >= 0; } + bool IsInitialized() const { return m_fs_index >= 0; } - NcaFsHeader &GetData() { return this->data; } - const NcaFsHeader &GetData() const { return this->data; } + NcaFsHeader &GetData() { return m_data; } + const NcaFsHeader &GetData() const { return m_data; } void GetRawData(void *dst, size_t dst_size) const; NcaFsHeader::HashData &GetHashData(); @@ -179,19 +179,19 @@ namespace ams::fssystem { class StorageOption; class StorageOptionWithHeaderReader; private: - std::shared_ptr original_reader; - std::shared_ptr reader; - MemoryResource * const allocator; - fssystem::IBufferManager * const buffer_manager; + std::shared_ptr m_original_reader; + std::shared_ptr m_reader; + MemoryResource * const m_allocator; + fssystem::IBufferManager * const m_buffer_manager; public: static Result SetupFsHeaderReader(NcaFsHeaderReader *out, const NcaReader &reader, s32 fs_index); public: - NcaFileSystemDriver(std::shared_ptr reader, MemoryResource *allocator, IBufferManager *buffer_manager) : original_reader(), reader(reader), allocator(allocator), buffer_manager(buffer_manager) { - AMS_ASSERT(this->reader != nullptr); + NcaFileSystemDriver(std::shared_ptr reader, MemoryResource *allocator, IBufferManager *buffer_manager) : m_original_reader(), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager) { + AMS_ASSERT(m_reader != nullptr); } - NcaFileSystemDriver(std::shared_ptr original_reader, std::shared_ptr reader, MemoryResource *allocator, IBufferManager *buffer_manager) : original_reader(original_reader), reader(reader), allocator(allocator), buffer_manager(buffer_manager) { - AMS_ASSERT(this->reader != nullptr); + NcaFileSystemDriver(std::shared_ptr original_reader, std::shared_ptr reader, MemoryResource *allocator, IBufferManager *buffer_manager) : m_original_reader(original_reader), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager) { + AMS_ASSERT(m_reader != nullptr); } Result OpenRawStorage(std::shared_ptr *out, s32 fs_index); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver_impl.hpp index 080032faf..ab1b6dfbb 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver_impl.hpp @@ -24,126 +24,126 @@ namespace ams::fssystem { private: friend class NcaFileSystemDriver; private: - const s32 fs_index; - NcaFsHeaderReader * const header_reader; - fs::IStorage *data_storage; - s64 data_storage_size; - fs::IStorage *aes_ctr_ex_table_storage; - AesCtrCounterExtendedStorage *aes_ctr_ex_storage_raw; - fs::IStorage *aes_ctr_ex_storage; - IndirectStorage *indirect_storage; - SparseStorage *sparse_storage; + const s32 m_fs_index; + NcaFsHeaderReader * const m_header_reader; + fs::IStorage *m_data_storage; + s64 m_data_storage_size; + fs::IStorage *m_aes_ctr_ex_table_storage; + AesCtrCounterExtendedStorage *m_aes_ctr_ex_storage_raw; + fs::IStorage *m_aes_ctr_ex_storage; + IndirectStorage *m_indirect_storage; + SparseStorage *m_sparse_storage; public: - explicit StorageOption(NcaFsHeaderReader *reader) : fs_index(reader->GetFsIndex()), header_reader(reader), data_storage(), data_storage_size(), aes_ctr_ex_table_storage(), aes_ctr_ex_storage_raw(), aes_ctr_ex_storage(), indirect_storage(), sparse_storage() { - AMS_ASSERT(this->header_reader != nullptr); + explicit StorageOption(NcaFsHeaderReader *reader) : m_fs_index(reader->GetFsIndex()), m_header_reader(reader), m_data_storage(), m_data_storage_size(), m_aes_ctr_ex_table_storage(), m_aes_ctr_ex_storage_raw(), m_aes_ctr_ex_storage(), m_indirect_storage(), m_sparse_storage() { + AMS_ASSERT(m_header_reader != nullptr); } - StorageOption(NcaFsHeaderReader *reader, s32 index) : fs_index(index), header_reader(reader), data_storage(), data_storage_size(), aes_ctr_ex_table_storage(), aes_ctr_ex_storage_raw(), aes_ctr_ex_storage(), indirect_storage(), sparse_storage() { - AMS_ASSERT(this->header_reader != nullptr); + StorageOption(NcaFsHeaderReader *reader, s32 index) : m_fs_index(index), m_header_reader(reader), m_data_storage(), m_data_storage_size(), m_aes_ctr_ex_table_storage(), m_aes_ctr_ex_storage_raw(), m_aes_ctr_ex_storage(), m_indirect_storage(), m_sparse_storage() { + AMS_ASSERT(m_header_reader != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); } - s32 GetFsIndex() const { return this->fs_index; } - NcaFsHeaderReader &GetHeaderReader() { return *this->header_reader; } - const NcaFsHeaderReader &GetHeaderReader() const { return *this->header_reader; } - fs::SubStorage GetDataStorage() const { return fs::SubStorage(this->data_storage, 0, this->data_storage_size); } - fs::IStorage *GetAesCtrExTableStorage() const { return this->aes_ctr_ex_table_storage; } - fs::IStorage *GetAesCtrExStorage() const { return this->aes_ctr_ex_storage; } - AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return this->aes_ctr_ex_storage_raw; } - IndirectStorage *GetIndirectStorage() const { return this->indirect_storage; } - SparseStorage *GetSparseStorage() const { return this->sparse_storage; } + s32 GetFsIndex() const { return m_fs_index; } + NcaFsHeaderReader &GetHeaderReader() { return *m_header_reader; } + const NcaFsHeaderReader &GetHeaderReader() const { return *m_header_reader; } + fs::SubStorage GetDataStorage() const { return fs::SubStorage(m_data_storage, 0, m_data_storage_size); } + fs::IStorage *GetAesCtrExTableStorage() const { return m_aes_ctr_ex_table_storage; } + fs::IStorage *GetAesCtrExStorage() const { return m_aes_ctr_ex_storage; } + AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return m_aes_ctr_ex_storage_raw; } + IndirectStorage *GetIndirectStorage() const { return m_indirect_storage; } + SparseStorage *GetSparseStorage() const { return m_sparse_storage; } private: void SetDataStorage(fs::IStorage *storage, s64 size) { AMS_ASSERT(storage != nullptr); AMS_ASSERT(size >= 0); - this->data_storage = storage; - this->data_storage_size = size; + m_data_storage = storage; + m_data_storage_size = size; } - void SetAesCtrExTableStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_table_storage = storage; } - void SetAesCtrExStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_storage = storage; } - void SetAesCtrExStorageRaw(AesCtrCounterExtendedStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_storage_raw = storage; } - void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); this->indirect_storage = storage; } - void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); this->sparse_storage = storage; } + void SetAesCtrExTableStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_table_storage = storage; } + void SetAesCtrExStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_storage = storage; } + void SetAesCtrExStorageRaw(AesCtrCounterExtendedStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_storage_raw = storage; } + void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); m_indirect_storage = storage; } + void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); m_sparse_storage = storage; } }; class NcaFileSystemDriver::StorageOptionWithHeaderReader : public NcaFileSystemDriver::StorageOption { private: - NcaFsHeaderReader header_reader_data; + NcaFsHeaderReader m_header_reader_data; public: - explicit StorageOptionWithHeaderReader(s32 index) : StorageOption(std::addressof(header_reader_data), index) { /* ... */ } + explicit StorageOptionWithHeaderReader(s32 index) : StorageOption(std::addressof(m_header_reader_data), index) { /* ... */ } }; class NcaFileSystemDriver::BaseStorage { private: - std::unique_ptr storage; - fs::SubStorage sub_storage; - s64 storage_offset; - NcaAesCtrUpperIv aes_ctr_upper_iv; + std::unique_ptr m_storage; + fs::SubStorage m_sub_storage; + s64 m_storage_offset; + NcaAesCtrUpperIv m_aes_ctr_upper_iv; public: - BaseStorage() : storage(), sub_storage(), storage_offset(0) { - this->aes_ctr_upper_iv.value = 0; + BaseStorage() : m_storage(), m_sub_storage(), m_storage_offset(0) { + m_aes_ctr_upper_iv.value = 0; } - explicit BaseStorage(const fs::SubStorage &ss) : storage(), sub_storage(ss), storage_offset(0) { - this->aes_ctr_upper_iv.value = 0; + explicit BaseStorage(const fs::SubStorage &ss) : m_storage(), m_sub_storage(ss), m_storage_offset(0) { + m_aes_ctr_upper_iv.value = 0; } template - BaseStorage(T s, s64 offset, s64 size) : storage(), sub_storage(s, offset, size), storage_offset(0) { - this->aes_ctr_upper_iv.value = 0; + BaseStorage(T s, s64 offset, s64 size) : m_storage(), m_sub_storage(s, offset, size), m_storage_offset(0) { + m_aes_ctr_upper_iv.value = 0; } void SetStorage(std::unique_ptr &&storage) { - this->storage = std::move(storage); + m_storage = std::move(storage); } template void SetStorage(T storage, s64 offset, s64 size) { - this->sub_storage = fs::SubStorage(storage, offset, size); + m_sub_storage = fs::SubStorage(storage, offset, size); } std::unique_ptr MakeStorage() { - if (this->storage != nullptr) { - return std::move(this->storage); + if (m_storage != nullptr) { + return std::move(m_storage); } - return std::make_unique(this->sub_storage); + return std::make_unique(m_sub_storage); } std::unique_ptr GetStorage() { - return std::move(this->storage); + return std::move(m_storage); } Result GetSubStorage(fs::SubStorage *out, s64 offset, s64 size) { s64 storage_size = 0; - if (this->storage != nullptr) { - R_TRY(this->storage->GetSize(std::addressof(storage_size))); + if (m_storage != nullptr) { + R_TRY(m_storage->GetSize(std::addressof(storage_size))); R_UNLESS(offset + size <= storage_size, fs::ResultNcaBaseStorageOutOfRangeA()); - *out = fs::SubStorage(this->storage.get(), offset, size); + *out = fs::SubStorage(m_storage.get(), offset, size); } else { - R_TRY(this->sub_storage.GetSize(std::addressof(storage_size))); + R_TRY(m_sub_storage.GetSize(std::addressof(storage_size))); R_UNLESS(offset + size <= storage_size, fs::ResultNcaBaseStorageOutOfRangeA()); - *out = fs::SubStorage(std::addressof(this->sub_storage), offset, size); + *out = fs::SubStorage(std::addressof(m_sub_storage), offset, size); } return ResultSuccess(); } void SetStorageOffset(s64 offset) { - this->storage_offset = offset; + m_storage_offset = offset; } s64 GetStorageOffset() const { - return this->storage_offset; + return m_storage_offset; } void SetAesCtrUpperIv(NcaAesCtrUpperIv v) { - this->aes_ctr_upper_iv = v; + m_aes_ctr_upper_iv = v; } const NcaAesCtrUpperIv GetAesCtrUpperIv() const { - return this->aes_ctr_upper_iv; + return m_aes_ctr_upper_iv; } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system.hpp index d1c7f2d3e..f87c9a715 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system.hpp @@ -29,12 +29,12 @@ namespace ams::fssystem { class PartitionFile; class PartitionDirectory; private: - fs::IStorage *base_storage; - MetaType *meta_data; - bool initialized; - size_t meta_data_size; - std::unique_ptr unique_meta_data; - std::shared_ptr shared_storage; + fs::IStorage *m_base_storage; + MetaType *m_meta_data; + bool m_initialized; + size_t m_meta_data_size; + std::unique_ptr m_unique_meta_data; + std::shared_ptr m_shared_storage; private: Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator); public: diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp index c4ceef05d..7005e0f95 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp @@ -76,15 +76,15 @@ namespace ams::fssystem { using PartitionEntry = typename Format::PartitionEntry; protected: - bool initialized; - PartitionFileSystemHeader *header; - PartitionEntry *entries; - char *name_table; - size_t meta_data_size; - MemoryResource *allocator; - char *buffer; + bool m_initialized; + PartitionFileSystemHeader *m_header; + PartitionEntry *m_entries; + char *m_name_table; + size_t m_meta_data_size; + MemoryResource *m_allocator; + char *m_buffer; public: - PartitionFileSystemMetaCore() : initialized(false), allocator(nullptr), buffer(nullptr) { /* ... */ } + PartitionFileSystemMetaCore() : m_initialized(false), m_allocator(nullptr), m_buffer(nullptr) { /* ... */ } ~PartitionFileSystemMetaCore(); Result Initialize(fs::IStorage *storage, MemoryResource *allocator); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pooled_buffer.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pooled_buffer.hpp index d4551a9af..81b57d95b 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pooled_buffer.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pooled_buffer.hpp @@ -25,8 +25,8 @@ namespace ams::fssystem { class PooledBuffer { NON_COPYABLE(PooledBuffer); private: - char *buffer; - size_t size; + char *m_buffer; + size_t m_size; private: static size_t GetAllocatableSizeMaxCore(bool large); public: @@ -34,14 +34,14 @@ namespace ams::fssystem { static size_t GetAllocatableParticularlyLargeSizeMax() { return GetAllocatableSizeMaxCore(true); } private: void Swap(PooledBuffer &rhs) { - std::swap(this->buffer, rhs.buffer); - std::swap(this->size, rhs.size); + std::swap(m_buffer, rhs.m_buffer); + std::swap(m_size, rhs.m_size); } public: /* Constructor/Destructor. */ - constexpr PooledBuffer() : buffer(), size() { /* ... */ } + constexpr PooledBuffer() : m_buffer(), m_size() { /* ... */ } - PooledBuffer(size_t ideal_size, size_t required_size) : buffer(), size() { + PooledBuffer(size_t ideal_size, size_t required_size) : m_buffer(), m_size() { this->Allocate(ideal_size, required_size); } @@ -50,9 +50,9 @@ namespace ams::fssystem { } /* Move and assignment. */ - explicit PooledBuffer(PooledBuffer &&rhs) : buffer(rhs.buffer), size(rhs.size) { - rhs.buffer = nullptr; - rhs.size = 0; + explicit PooledBuffer(PooledBuffer &&rhs) : m_buffer(rhs.m_buffer), m_size(rhs.m_size) { + rhs.m_buffer = nullptr; + rhs.m_size = 0; } PooledBuffer &operator=(PooledBuffer &&rhs) { @@ -74,17 +74,17 @@ namespace ams::fssystem { void Deallocate() { /* Shrink the buffer to empty. */ this->Shrink(0); - AMS_ASSERT(this->buffer == nullptr); + AMS_ASSERT(m_buffer == nullptr); } char *GetBuffer() const { - AMS_ASSERT(this->buffer != nullptr); - return this->buffer; + AMS_ASSERT(m_buffer != nullptr); + return m_buffer; } size_t GetSize() const { - AMS_ASSERT(this->buffer != nullptr); - return this->size; + AMS_ASSERT(m_buffer != nullptr); + return m_size; } private: void AllocateCore(size_t ideal_size, size_t required_size, bool large); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_romfs_file_system.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_romfs_file_system.hpp index 6aabc3aad..b2a173666 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_romfs_file_system.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_romfs_file_system.hpp @@ -27,14 +27,14 @@ namespace ams::fssystem { public: using RomFileTable = fs::HierarchicalRomFileTable; private: - RomFileTable rom_file_table; - fs::IStorage *base_storage; - std::shared_ptr shared_storage; - std::unique_ptr dir_bucket_storage; - std::unique_ptr dir_entry_storage; - std::unique_ptr file_bucket_storage; - std::unique_ptr file_entry_storage; - s64 entry_size; + RomFileTable m_rom_file_table; + fs::IStorage *m_base_storage; + std::shared_ptr m_shared_storage; + std::unique_ptr m_dir_bucket_storage; + std::unique_ptr m_dir_entry_storage; + std::unique_ptr m_file_bucket_storage; + std::unique_ptr m_file_entry_storage; + s64 m_entry_size; private: Result GetFileInfo(RomFileTable::FileInfo *out, const char *path); public: diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp index b3639bde2..61c7cc0b3 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp @@ -65,9 +65,9 @@ namespace ams::fssystem { } }; private: - ZeroStorage zero_storage; + ZeroStorage m_zero_storage; public: - SparseStorage() : IndirectStorage(), zero_storage() { /* ... */ } + SparseStorage() : IndirectStorage(), m_zero_storage() { /* ... */ } virtual ~SparseStorage() { /* ... */ } using IndirectStorage::Initialize; @@ -95,7 +95,7 @@ namespace ams::fssystem { virtual Result Read(s64 offset, void *buffer, size_t size) override; private: void SetZeroStorage() { - return this->SetStorage(1, std::addressof(this->zero_storage), 0, std::numeric_limits::max()); + return this->SetStorage(1, std::addressof(m_zero_storage), 0, std::numeric_limits::max()); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp index a5851b6a9..fb48cc01e 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp @@ -24,8 +24,8 @@ namespace ams::fssystem { using PathResolutionFileSystem = impl::IPathResolutionFileSystem; friend class impl::IPathResolutionFileSystem; private: - char *base_path; - size_t base_path_len; + char *m_base_path; + size_t m_base_path_len; public: SubDirectoryFileSystem(std::shared_ptr fs, const char *bp, bool unc = false); SubDirectoryFileSystem(std::unique_ptr fs, const char *bp, bool unc = false); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_thread_priority_changer.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_thread_priority_changer.hpp index dc6c90ea8..3c19acc0d 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_thread_priority_changer.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_thread_priority_changer.hpp @@ -48,9 +48,9 @@ namespace ams::fssystem { private: static s32 GetThreadPriorityByAccessPriority(AccessMode mode); private: - ScopedThreadPriorityChanger scoped_changer; + ScopedThreadPriorityChanger m_scoped_changer; public: - ALWAYS_INLINE explicit ScopedThreadPriorityChangerByAccessPriority(AccessMode mode) : scoped_changer(GetThreadPriorityByAccessPriority(mode), ScopedThreadPriorityChanger::Mode::Absolute) { + ALWAYS_INLINE explicit ScopedThreadPriorityChangerByAccessPriority(AccessMode mode) : m_scoped_changer(GetThreadPriorityByAccessPriority(mode), ScopedThreadPriorityChanger::Mode::Absolute) { /* ... */ } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp index 76a4ecf4d..af0cec1be 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp @@ -26,24 +26,24 @@ namespace ams::fssystem::impl { class IPathResolutionFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable { NON_COPYABLE(IPathResolutionFileSystem); private: - std::shared_ptr shared_fs; - std::unique_ptr unique_fs; - bool unc_preserved; + std::shared_ptr m_shared_fs; + std::unique_ptr m_unique_fs; + bool m_unc_preserved; protected: - fs::fsa::IFileSystem * const base_fs; + fs::fsa::IFileSystem * const m_base_fs; public: - IPathResolutionFileSystem(std::shared_ptr fs, bool unc = false) : shared_fs(std::move(fs)), unc_preserved(unc), base_fs(shared_fs.get()) { + IPathResolutionFileSystem(std::shared_ptr fs, bool unc = false) : m_shared_fs(std::move(fs)), m_unc_preserved(unc), m_base_fs(m_shared_fs.get()) { /* ... */ } - IPathResolutionFileSystem(std::unique_ptr fs, bool unc = false) : unique_fs(std::move(fs)), unc_preserved(unc), base_fs(unique_fs.get()) { + IPathResolutionFileSystem(std::unique_ptr fs, bool unc = false) : m_unique_fs(std::move(fs)), m_unc_preserved(unc), m_base_fs(m_unique_fs.get()) { /* ... */ } virtual ~IPathResolutionFileSystem() { /* ... */ } protected: constexpr inline bool IsUncPreserved() const { - return this->unc_preserved; + return m_unc_preserved; } public: virtual Result DoCreateFile(const char *path, s64 size, int option) override { @@ -51,7 +51,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CreateFile(full_path, size, option); + return m_base_fs->CreateFile(full_path, size, option); } virtual Result DoDeleteFile(const char *path) override { @@ -59,7 +59,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteFile(full_path); + return m_base_fs->DeleteFile(full_path); } virtual Result DoCreateDirectory(const char *path) override { @@ -67,7 +67,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CreateDirectory(full_path); + return m_base_fs->CreateDirectory(full_path); } virtual Result DoDeleteDirectory(const char *path) override { @@ -75,7 +75,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteDirectory(full_path); + return m_base_fs->DeleteDirectory(full_path); } virtual Result DoDeleteDirectoryRecursively(const char *path) override { @@ -83,7 +83,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteDirectoryRecursively(full_path); + return m_base_fs->DeleteDirectoryRecursively(full_path); } virtual Result DoRenameFile(const char *old_path, const char *new_path) override { @@ -93,7 +93,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->RenameFile(old_full_path, new_full_path); + return m_base_fs->RenameFile(old_full_path, new_full_path); } virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override { @@ -103,7 +103,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->RenameDirectory(old_full_path, new_full_path); + return m_base_fs->RenameDirectory(old_full_path, new_full_path); } virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override { @@ -111,7 +111,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetEntryType(out, full_path); + return m_base_fs->GetEntryType(out, full_path); } virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override { @@ -119,7 +119,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->OpenFile(out_file, full_path, mode); + return m_base_fs->OpenFile(out_file, full_path, mode); } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) override { @@ -127,12 +127,12 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->OpenDirectory(out_dir, full_path, mode); + return m_base_fs->OpenDirectory(out_dir, full_path, mode); } virtual Result DoCommit() override { util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Commit(); + return m_base_fs->Commit(); } virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { @@ -140,7 +140,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetFreeSpaceSize(out, full_path); + return m_base_fs->GetFreeSpaceSize(out, full_path); } virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override { @@ -148,7 +148,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetTotalSpaceSize(out, full_path); + return m_base_fs->GetTotalSpaceSize(out, full_path); } virtual Result DoCleanDirectoryRecursively(const char *path) override { @@ -156,7 +156,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CleanDirectoryRecursively(full_path); + return m_base_fs->CleanDirectoryRecursively(full_path); } virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const char *path) override { @@ -164,7 +164,7 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetFileTimeStampRaw(out, full_path); + return m_base_fs->GetFileTimeStampRaw(out, full_path); } virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) override { @@ -172,23 +172,23 @@ namespace ams::fssystem::impl { R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path); + return m_base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path); } /* These aren't accessible as commands. */ virtual Result DoCommitProvisionally(s64 counter) override { util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CommitProvisionally(counter); + return m_base_fs->CommitProvisionally(counter); } virtual Result DoRollback() override { util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Rollback(); + return m_base_fs->Rollback(); } virtual Result DoFlush() override { util::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Flush(); + return m_base_fs->Flush(); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp index 8def5bd0c..d711165d5 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp @@ -61,19 +61,19 @@ namespace ams::fssystem::save { Flag_RealData = (1 << 10), }; private: - IBufferManager *buffer_manager; - os::SdkRecursiveMutex *mutex; - std::unique_ptr entries; - IStorage *data_storage; - Result last_result; - s64 data_size; - size_t verification_block_size; - size_t verification_block_shift; - CacheIndex invalidate_index; - s32 max_cache_entry_count; - s32 flags; - s32 buffer_level; - fs::StorageType storage_type; + IBufferManager *m_buffer_manager; + os::SdkRecursiveMutex *m_mutex; + std::unique_ptr m_entries; + IStorage *m_data_storage; + Result m_last_result; + s64 m_data_size; + size_t m_verification_block_size; + size_t m_verification_block_shift; + CacheIndex m_invalidate_index; + s32 m_max_cache_entry_count; + s32 m_flags; + s32 m_buffer_level; + fs::StorageType m_storage_type; public: BlockCacheBufferedStorage(); virtual ~BlockCacheBufferedStorage() override; @@ -96,31 +96,31 @@ namespace ams::fssystem::save { Result OnRollback(); bool IsEnabledKeepBurstMode() const { - return (this->flags & Flag_KeepBurstMode) != 0; + return (m_flags & Flag_KeepBurstMode) != 0; } bool IsRealDataCache() const { - return (this->flags & Flag_RealData) != 0; + return (m_flags & Flag_RealData) != 0; } void SetKeepBurstMode(bool en) { if (en) { - this->flags |= Flag_KeepBurstMode; + m_flags |= Flag_KeepBurstMode; } else { - this->flags &= ~Flag_KeepBurstMode; + m_flags &= ~Flag_KeepBurstMode; } } void SetRealDataCache(bool en) { if (en) { - this->flags |= Flag_RealData; + m_flags |= Flag_RealData; } else { - this->flags &= ~Flag_RealData; + m_flags &= ~Flag_RealData; } } private: s32 GetMaxCacheEntryCount() const { - return this->max_cache_entry_count; + return m_max_cache_entry_count; } Result ClearImpl(s64 offset, s64 size); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp index cc82804d8..f7367326f 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp @@ -30,16 +30,16 @@ namespace ams::fssystem::save { class UniqueCache; class SharedCache; private: - fs::SubStorage base_storage; - IBufferManager *buffer_manager; - size_t block_size; - s64 base_storage_size; - std::unique_ptr caches; - s32 cache_count; - Cache *next_acquire_cache; - Cache *next_fetch_cache; - os::SdkMutex mutex; - bool bulk_read_enabled; + fs::SubStorage m_base_storage; + IBufferManager *m_buffer_manager; + size_t m_block_size; + s64 m_base_storage_size; + std::unique_ptr m_caches; + s32 m_cache_count; + Cache *m_next_acquire_cache; + Cache *m_next_fetch_cache; + os::SdkMutex m_mutex; + bool m_bulk_read_enabled; public: BufferedStorage(); virtual ~BufferedStorage(); @@ -47,7 +47,7 @@ namespace ams::fssystem::save { Result Initialize(fs::SubStorage base_storage, IBufferManager *buffer_manager, size_t block_size, s32 buffer_count); void Finalize(); - bool IsInitialized() const { return this->caches != nullptr; } + bool IsInitialized() const { return m_caches != nullptr; } virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result Write(s64 offset, const void *buffer, size_t size) override; @@ -61,9 +61,9 @@ namespace ams::fssystem::save { void InvalidateCaches(); - IBufferManager *GetBufferManager() const { return this->buffer_manager; } + IBufferManager *GetBufferManager() const { return m_buffer_manager; } - void EnableBulkRead() { this->bulk_read_enabled = true; } + void EnableBulkRead() { m_bulk_read_enabled = true; } private: Result PrepareAllocation(); Result ControlDirtiness(); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp index 95803cdec..76d4d51f2 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp @@ -82,8 +82,8 @@ namespace ams::fssystem::save { }; static_assert(util::is_pod::value); private: - fs::SubStorage storage; - HierarchicalIntegrityVerificationMetaInformation meta; + fs::SubStorage m_storage; + HierarchicalIntegrityVerificationMetaInformation m_meta; public: static Result QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size); /* TODO Format */ @@ -94,10 +94,10 @@ namespace ams::fssystem::save { Result Initialize(fs::SubStorage meta_storage); void Finalize(); - u32 GetMasterHashSize() const { return this->meta.master_hash_size; } + u32 GetMasterHashSize() const { return m_meta.master_hash_size; } void GetLevelHashInfo(HierarchicalIntegrityVerificationInformation *out) { AMS_ASSERT(out != nullptr); - *out = this->meta.level_hash_info; + *out = m_meta.level_hash_info; } }; @@ -124,19 +124,19 @@ namespace ams::fssystem::save { DataStorage = 6, }; private: - fs::SubStorage storages[DataStorage + 1]; + fs::SubStorage m_storages[DataStorage + 1]; public: - void SetMasterHashStorage(fs::SubStorage s) { this->storages[MasterStorage] = s; } - void SetLayer1HashStorage(fs::SubStorage s) { this->storages[Layer1Storage] = s; } - void SetLayer2HashStorage(fs::SubStorage s) { this->storages[Layer2Storage] = s; } - void SetLayer3HashStorage(fs::SubStorage s) { this->storages[Layer3Storage] = s; } - void SetLayer4HashStorage(fs::SubStorage s) { this->storages[Layer4Storage] = s; } - void SetLayer5HashStorage(fs::SubStorage s) { this->storages[Layer5Storage] = s; } - void SetDataStorage(fs::SubStorage s) { this->storages[DataStorage] = s; } + void SetMasterHashStorage(fs::SubStorage s) { m_storages[MasterStorage] = s; } + void SetLayer1HashStorage(fs::SubStorage s) { m_storages[Layer1Storage] = s; } + void SetLayer2HashStorage(fs::SubStorage s) { m_storages[Layer2Storage] = s; } + void SetLayer3HashStorage(fs::SubStorage s) { m_storages[Layer3Storage] = s; } + void SetLayer4HashStorage(fs::SubStorage s) { m_storages[Layer4Storage] = s; } + void SetLayer5HashStorage(fs::SubStorage s) { m_storages[Layer5Storage] = s; } + void SetDataStorage(fs::SubStorage s) { m_storages[DataStorage] = s; } fs::SubStorage &operator[](s32 index) { AMS_ASSERT(MasterStorage <= index && index <= DataStorage); - return this->storages[index]; + return m_storages[index]; } }; private: @@ -146,15 +146,15 @@ namespace ams::fssystem::save { s_generate_random = func; } private: - FileSystemBufferManagerSet *buffers; - os::SdkRecursiveMutex *mutex; - IntegrityVerificationStorage verify_storages[MaxLayers - 1]; - BlockCacheBufferedStorage buffer_storages[MaxLayers - 1]; - s64 data_size; - s32 max_layers; - bool is_written_for_rollback; + FileSystemBufferManagerSet *m_buffers; + os::SdkRecursiveMutex *m_mutex; + IntegrityVerificationStorage m_verify_storages[MaxLayers - 1]; + BlockCacheBufferedStorage m_buffer_storages[MaxLayers - 1]; + s64 m_data_size; + s32 m_max_layers; + bool m_is_written_for_rollback; public: - HierarchicalIntegrityVerificationStorage() : buffers(nullptr), mutex(nullptr), data_size(-1), is_written_for_rollback(false) { /* ... */ } + HierarchicalIntegrityVerificationStorage() : m_buffers(nullptr), m_mutex(nullptr), m_data_size(-1), m_is_written_for_rollback(false) { /* ... */ } virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); } Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type); @@ -175,30 +175,30 @@ namespace ams::fssystem::save { Result OnRollback(); bool IsInitialized() const { - return this->data_size >= 0; + return m_data_size >= 0; } bool IsWrittenForRollback() const { - return this->is_written_for_rollback; + return m_is_written_for_rollback; } FileSystemBufferManagerSet *GetBuffers() { - return this->buffers; + return m_buffers; } void GetParameters(HierarchicalIntegrityVerificationStorageControlArea::InputParam *out) const { AMS_ASSERT(out != nullptr); - for (auto level = 0; level <= this->max_layers - 2; ++level) { - out->level_block_size[level] = static_cast(this->verify_storages[level].GetBlockSize()); + for (auto level = 0; level <= m_max_layers - 2; ++level) { + out->level_block_size[level] = static_cast(m_verify_storages[level].GetBlockSize()); } } s64 GetL1HashVerificationBlockSize() const { - return this->verify_storages[this->max_layers - 2].GetBlockSize(); + return m_verify_storages[m_max_layers - 2].GetBlockSize(); } fs::SubStorage GetL1HashStorage() { - return fs::SubStorage(std::addressof(this->buffer_storages[this->max_layers - 3]), 0, util::DivideUp(this->data_size, this->GetL1HashVerificationBlockSize())); + return fs::SubStorage(std::addressof(m_buffer_storages[m_max_layers - 3]), 0, util::DivideUp(m_data_size, this->GetL1HashVerificationBlockSize())); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp index e3d274763..0905cee51 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp @@ -37,18 +37,18 @@ namespace ams::fssystem::save { }; static_assert(util::is_pod::value); private: - fs::SubStorage hash_storage; - fs::SubStorage data_storage; - s64 verification_block_size; - s64 verification_block_order; - s64 upper_layer_verification_block_size; - s64 upper_layer_verification_block_order; - IBufferManager *buffer_manager; - fs::HashSalt salt; - bool is_real_data; - fs::StorageType storage_type; + fs::SubStorage m_hash_storage; + fs::SubStorage m_data_storage; + s64 m_verification_block_size; + s64 m_verification_block_order; + s64 m_upper_layer_verification_block_size; + s64 m_upper_layer_verification_block_order; + IBufferManager *m_buffer_manager; + fs::HashSalt m_salt; + bool m_is_real_data; + fs::StorageType m_storage_type; public: - IntegrityVerificationStorage() : verification_block_size(0), verification_block_order(0), upper_layer_verification_block_size(0), upper_layer_verification_block_order(0), buffer_manager(nullptr) { /* ... */ } + IntegrityVerificationStorage() : m_verification_block_size(0), m_verification_block_order(0), m_upper_layer_verification_block_size(0), m_upper_layer_verification_block_order(0), m_buffer_manager(nullptr) { /* ... */ } virtual ~IntegrityVerificationStorage() override { this->Finalize(); } Result Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, IBufferManager *bm, const fs::HashSalt &salt, bool is_real_data, fs::StorageType storage_type); @@ -68,7 +68,7 @@ namespace ams::fssystem::save { void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size) const; s64 GetBlockSize() const { - return this->verification_block_size; + return m_verification_block_size; } private: Result ReadBlockSignature(void *dst, size_t dst_size, s64 offset, size_t size); @@ -76,7 +76,7 @@ namespace ams::fssystem::save { Result VerifyHash(const void *buf, BlockHash *hash); void CalcBlockHash(BlockHash *out, const void *buffer) const { - return this->CalcBlockHash(out, buffer, static_cast(this->verification_block_size)); + return this->CalcBlockHash(out, buffer, static_cast(m_verification_block_size)); } Result IsCleared(bool *is_cleared, const BlockHash &hash); diff --git a/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad.hpp b/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad.hpp index c429f9965..e276f2dde 100644 --- a/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad.hpp +++ b/libraries/libstratosphere/include/stratosphere/gpio/driver/gpio_pad.hpp @@ -25,29 +25,29 @@ namespace ams::gpio::driver { NON_MOVEABLE(Pad); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::Pad, ::ams::ddsf::IDevice); private: - int pad_number; - bool is_interrupt_enabled; + int m_pad_number; + bool m_is_interrupt_enabled; public: - explicit Pad(int pad) : IDevice(true), pad_number(pad), is_interrupt_enabled(false) { /* ... */ } + explicit Pad(int pad) : IDevice(true), m_pad_number(pad), m_is_interrupt_enabled(false) { /* ... */ } Pad() : Pad(0) { /* ... */ } virtual ~Pad() { /* ... */ } int GetPadNumber() const { - return this->pad_number; + return m_pad_number; } void SetPadNumber(int p) { - this->pad_number = p; + m_pad_number = p; } bool IsInterruptEnabled() const { - return this->is_interrupt_enabled; + return m_is_interrupt_enabled; } void SetInterruptEnabled(bool en) { - this->is_interrupt_enabled = en; + m_is_interrupt_enabled = en; } bool IsInterruptRequiredForDriver() const { diff --git a/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_event_holder.hpp b/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_event_holder.hpp index 8a2969174..4f24a5fe4 100644 --- a/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_event_holder.hpp +++ b/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_event_holder.hpp @@ -23,26 +23,26 @@ namespace ams::gpio::driver::impl { NON_COPYABLE(EventHolder); NON_MOVEABLE(EventHolder); private: - os::SystemEventType *event; + os::SystemEventType *m_event; public: - constexpr EventHolder() : event(nullptr) { /* ... */ } + constexpr EventHolder() : m_event(nullptr) { /* ... */ } void AttachEvent(os::SystemEventType *event) { - this->event = event; + m_event = event; } os::SystemEventType *DetachEvent() { - auto ev = this->event; - this->event = nullptr; + auto ev = m_event; + m_event = nullptr; return ev; } os::SystemEventType *GetSystemEvent() { - return this->event; + return m_event; } bool IsBound() const { - return this->event != nullptr; + return m_event != nullptr; } }; diff --git a/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp b/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp index c0c36f7aa..752adff2e 100644 --- a/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp @@ -33,18 +33,18 @@ namespace ams::gpio::driver::impl { NON_MOVEABLE(PadSessionImpl); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::impl::PadSessionImpl, ::ams::ddsf::ISession); private: - EventHolder event_holder; + EventHolder m_event_holder; private: Result UpdateDriverInterruptEnabled(); public: - PadSessionImpl() : event_holder() { /* ... */ } + PadSessionImpl() : m_event_holder() { /* ... */ } ~PadSessionImpl() { this->Close(); } bool IsInterruptBound() const { - return this->event_holder.IsBound(); + return m_event_holder.IsBound(); } Result Open(Pad *pad, ddsf::AccessMode access_mode); diff --git a/libraries/libstratosphere/include/stratosphere/i2c/driver/i2c_i2c_device_property.hpp b/libraries/libstratosphere/include/stratosphere/i2c/driver/i2c_i2c_device_property.hpp index 79a8f7aa6..53d9bedfc 100644 --- a/libraries/libstratosphere/include/stratosphere/i2c/driver/i2c_i2c_device_property.hpp +++ b/libraries/libstratosphere/include/stratosphere/i2c/driver/i2c_i2c_device_property.hpp @@ -25,25 +25,25 @@ namespace ams::i2c::driver { NON_MOVEABLE(I2cDeviceProperty); AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::I2cDeviceProperty, ::ams::ddsf::IDevice); private: - u16 address; - AddressingMode addressing_mode; - util::IntrusiveListNode device_property_list_node; + u16 m_address; + AddressingMode m_addressing_mode; + util::IntrusiveListNode m_device_property_list_node; public: - using DevicePropertyListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::device_property_list_node>; + using DevicePropertyListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::m_device_property_list_node>; using DevicePropertyList = typename DevicePropertyListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; public: - I2cDeviceProperty() : IDevice(false), address(0), addressing_mode(AddressingMode_SevenBit), device_property_list_node() { /* ... */ } - I2cDeviceProperty(u16 addr, AddressingMode m) : IDevice(false), address(addr), addressing_mode(m), device_property_list_node() { /* ... */ } + I2cDeviceProperty() : IDevice(false), m_address(0), m_addressing_mode(AddressingMode_SevenBit), m_device_property_list_node() { /* ... */ } + I2cDeviceProperty(u16 addr, AddressingMode m) : IDevice(false), m_address(addr), m_addressing_mode(m), m_device_property_list_node() { /* ... */ } virtual ~I2cDeviceProperty() { /* ... */ } u16 GetAddress() const { - return this->address; + return m_address; } AddressingMode GetAddressingMode() const { - return this->addressing_mode; + return m_addressing_mode; } }; diff --git a/libraries/libstratosphere/include/stratosphere/i2c/driver/impl/i2c_i2c_session_impl.hpp b/libraries/libstratosphere/include/stratosphere/i2c/driver/impl/i2c_i2c_session_impl.hpp index 99177775f..47fa2b8ca 100644 --- a/libraries/libstratosphere/include/stratosphere/i2c/driver/impl/i2c_i2c_session_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/i2c/driver/impl/i2c_i2c_session_impl.hpp @@ -36,8 +36,8 @@ namespace ams::i2c::driver::impl { Receive = 1, }; private: - TimeSpan retry_interval; - int max_retry_count; + TimeSpan m_retry_interval; + int m_max_retry_count; private: Result SendHandler(const u8 **cur_cmd, u8 **cur_dst); Result ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst); @@ -45,7 +45,7 @@ namespace ams::i2c::driver::impl { Result ExecuteTransactionWithRetry(void *dst, Command command, const void *src, size_t size, TransactionOption option); public: - I2cSessionImpl(int mr, TimeSpan rt) : retry_interval(rt), max_retry_count(mr) { /* ... */ } + I2cSessionImpl(int mr, TimeSpan rt) : m_retry_interval(rt), m_max_retry_count(mr) { /* ... */ } ~I2cSessionImpl() { this->Close(); diff --git a/libraries/libstratosphere/include/stratosphere/i2c/i2c_command_list_formatter.hpp b/libraries/libstratosphere/include/stratosphere/i2c/i2c_command_list_formatter.hpp index d279d7dbb..bfab40621 100644 --- a/libraries/libstratosphere/include/stratosphere/i2c/i2c_command_list_formatter.hpp +++ b/libraries/libstratosphere/include/stratosphere/i2c/i2c_command_list_formatter.hpp @@ -28,20 +28,20 @@ namespace ams::i2c { NON_COPYABLE(CommandListFormatter); NON_MOVEABLE(CommandListFormatter); private: - size_t current_index; - size_t command_list_length; - void *command_list; + size_t m_current_index; + size_t m_command_list_length; + void *m_command_list; private: Result IsEnqueueAble(size_t sz) const; public: - CommandListFormatter(void *p, size_t sz) : current_index(0), command_list_length(sz), command_list(p) { - AMS_ABORT_UNLESS(this->command_list_length <= CommandListLengthMax); + CommandListFormatter(void *p, size_t sz) : m_current_index(0), m_command_list_length(sz), m_command_list(p) { + AMS_ABORT_UNLESS(m_command_list_length <= CommandListLengthMax); } - ~CommandListFormatter() { this->command_list = nullptr; } + ~CommandListFormatter() { m_command_list = nullptr; } - size_t GetCurrentLength() const { return this->current_index; } - const void *GetListHead() const { return this->command_list; } + size_t GetCurrentLength() const { return m_current_index; } + const void *GetListHead() const { return m_command_list; } Result EnqueueReceiveCommand(i2c::TransactionOption option, size_t size); Result EnqueueSendCommand(i2c::TransactionOption option, const void *src, size_t size); diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp index 6b141c81e..e6b2be875 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp @@ -21,10 +21,10 @@ namespace ams::kvdb { /* Functionality for parsing/generating a key value archive. */ class ArchiveReader { private: - AutoBuffer &buffer; - size_t offset; + AutoBuffer &m_buffer; + size_t m_offset; public: - ArchiveReader(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } + ArchiveReader(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ } private: Result Peek(void *dst, size_t size); Result Read(void *dst, size_t size); @@ -36,10 +36,10 @@ namespace ams::kvdb { class ArchiveWriter { private: - AutoBuffer &buffer; - size_t offset; + AutoBuffer &m_buffer; + size_t m_offset; public: - ArchiveWriter(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } + ArchiveWriter(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ } private: Result Write(const void *src, size_t size); public: @@ -49,14 +49,14 @@ namespace ams::kvdb { class ArchiveSizeHelper { private: - size_t size; + size_t m_size; public: ArchiveSizeHelper(); void AddEntry(size_t key_size, size_t value_size); size_t GetSize() const { - return this->size; + return m_size; } }; diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp index cf02739d3..e3304db45 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp @@ -21,20 +21,20 @@ namespace ams::kvdb { class AutoBuffer { NON_COPYABLE(AutoBuffer); private: - u8 *buffer; - size_t size; + u8 *m_buffer; + size_t m_size; public: - AutoBuffer() : buffer(nullptr), size(0) { /* ... */ } + AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ } ~AutoBuffer() { this->Reset(); } AutoBuffer(AutoBuffer &&rhs) { - this->buffer = rhs.buffer; - this->size = rhs.size; - rhs.buffer = nullptr; - rhs.size = 0; + m_buffer = rhs.m_buffer; + m_size = rhs.m_size; + rhs.m_buffer = nullptr; + rhs.m_size = 0; } AutoBuffer &operator=(AutoBuffer &&rhs) { @@ -43,35 +43,35 @@ namespace ams::kvdb { } void Swap(AutoBuffer &rhs) { - std::swap(this->buffer, rhs.buffer); - std::swap(this->size, rhs.size); + std::swap(m_buffer, rhs.m_buffer); + std::swap(m_size, rhs.m_size); } void Reset() { - if (this->buffer != nullptr) { - delete[] this->buffer; - this->buffer = nullptr; - this->size = 0; + if (m_buffer != nullptr) { + delete[] m_buffer; + m_buffer = nullptr; + m_size = 0; } } u8 *Get() const { - return this->buffer; + return m_buffer; } size_t GetSize() const { - return this->size; + return m_size; } Result Initialize(size_t size) { /* Check that we're not already initialized. */ - AMS_ABORT_UNLESS(this->buffer == nullptr); + AMS_ABORT_UNLESS(m_buffer == nullptr); /* Allocate a buffer. */ - this->buffer = new (std::nothrow) u8[size]; - R_UNLESS(this->buffer != nullptr, kvdb::ResultAllocationFailed()); + m_buffer = new (std::nothrow) u8[size]; + R_UNLESS(m_buffer != nullptr, kvdb::ResultAllocationFailed()); - this->size = size; + m_size = size; return ResultSuccess(); } @@ -80,7 +80,7 @@ namespace ams::kvdb { R_TRY(this->Initialize(size)); /* Copy the input data in. */ - std::memcpy(this->buffer, buf, size); + std::memcpy(m_buffer, buf, size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp index 9df6a6edf..92935c736 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp @@ -23,7 +23,7 @@ namespace ams::kvdb { class BoundedString { static_assert(N > 0, "BoundedString requires non-zero backing buffer!"); private: - char buffer[N]; + char m_buffer[N]; private: /* Utility. */ static inline void CheckLength(size_t len) { @@ -32,7 +32,7 @@ namespace ams::kvdb { public: /* Constructors. */ constexpr BoundedString() { - buffer[0] = 0; + m_buffer[0] = 0; } explicit constexpr BoundedString(const char *s) { @@ -49,8 +49,8 @@ namespace ams::kvdb { std::va_list args; va_start(args, format); - CheckLength(util::VSNPrintf(string.buffer, N, format, args)); - string.buffer[N - 1] = 0; + CheckLength(util::VSNPrintf(string.m_buffer, N, format, args)); + string.m_buffer[N - 1] = 0; va_end(args); return string; @@ -58,30 +58,30 @@ namespace ams::kvdb { /* Getters. */ size_t GetLength() const { - return util::Strnlen(this->buffer, N); + return util::Strnlen(m_buffer, N); } const char *Get() const { - return this->buffer; + return m_buffer; } operator const char *() const { - return this->buffer; + return m_buffer; } /* Setters. */ void Set(const char *s) { /* Ensure string can fit in our buffer. */ CheckLength(util::Strnlen(s, N)); - std::strncpy(this->buffer, s, N); - this->buffer[N - 1] = 0; + std::strncpy(m_buffer, s, N); + m_buffer[N - 1] = 0; } void SetFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { /* Format into the buffer, abort if too large. */ std::va_list args; va_start(args, format); - CheckLength(util::VSNPrintf(this->buffer, N, format, args)); + CheckLength(util::VSNPrintf(m_buffer, N, format, args)); va_end(args); } @@ -89,21 +89,21 @@ namespace ams::kvdb { void Append(const char *s) { const size_t length = GetLength(); CheckLength(length + util::Strnlen(s, N)); - std::strncat(this->buffer, s, N - length - 1); + std::strncat(m_buffer, s, N - length - 1); } void Append(char c) { const size_t length = GetLength(); CheckLength(length + 1); - this->buffer[length] = c; - this->buffer[length + 1] = 0; + m_buffer[length] = c; + m_buffer[length + 1] = 0; } void AppendFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { const size_t length = GetLength(); std::va_list args; va_start(args, format); - CheckLength(util::VSNPrintf(this->buffer + length, N - length, format, args) + length); + CheckLength(util::VSNPrintf(m_buffer + length, N - length, format, args) + length); va_end(args); } @@ -113,19 +113,19 @@ namespace ams::kvdb { AMS_ABORT_UNLESS(offset + length <= GetLength()); AMS_ABORT_UNLESS(dst_size > length); /* Copy substring to dst. */ - std::strncpy(dst, this->buffer + offset, length); + std::strncpy(dst, m_buffer + offset, length); dst[length] = 0; } BoundedString GetSubstring(size_t offset, size_t length) const { BoundedString string; - GetSubstring(string.buffer, N, offset, length); + GetSubstring(string.m_buffer, N, offset, length); return string; } /* Comparison. */ constexpr bool operator==(const BoundedString &rhs) const { - return std::strncmp(this->buffer, rhs.buffer, N) == 0; + return std::strncmp(m_buffer, rhs.m_buffer, N) == 0; } constexpr bool operator!=(const BoundedString &rhs) const { @@ -133,7 +133,7 @@ namespace ams::kvdb { } bool EndsWith(const char *s, size_t offset) const { - return std::strncmp(this->buffer + offset, s, N - offset) == 0; + return std::strncmp(m_buffer + offset, s, N - offset) == 0; } bool EndsWith(const char *s) const { diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp index 1731524d5..0a7be09b5 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp @@ -34,9 +34,9 @@ namespace ams::kvdb { static constexpr size_t FileSize = sizeof(LruHeader) + BufferSize; using Path = FileKeyValueStore::Path; private: - Path file_path; - Key *keys; - LruHeader header; + Path m_file_path; + Key *m_keys; + LruHeader m_header; public: static Result CreateNewList(const char *path) { /* Create new lru_list.dat. */ @@ -56,40 +56,40 @@ namespace ams::kvdb { private: void RemoveIndex(size_t i) { AMS_ABORT_UNLESS(i < this->GetCount()); - std::memmove(this->keys + i, this->keys + i + 1, sizeof(*this->keys) * (this->GetCount() - (i + 1))); + std::memmove(m_keys + i, m_keys + i + 1, sizeof(*m_keys) * (this->GetCount() - (i + 1))); this->DecrementCount(); } void IncrementCount() { - this->header.entry_count++; + m_header.entry_count++; } void DecrementCount() { - this->header.entry_count--; + m_header.entry_count--; } public: - LruList() : keys(nullptr), header({}) { /* ... */ } + LruList() : m_keys(nullptr), m_header() { /* ... */ } Result Initialize(const char *path, void *buf, size_t size) { /* Only initialize once, and ensure we have sufficient memory. */ - AMS_ABORT_UNLESS(this->keys == nullptr); + AMS_ABORT_UNLESS(m_keys == nullptr); AMS_ABORT_UNLESS(size >= BufferSize); /* Setup member variables. */ - this->keys = static_cast(buf); - this->file_path.Set(path); - std::memset(this->keys, 0, BufferSize); + m_keys = static_cast(buf); + m_file_path.Set(path); + std::memset(m_keys, 0, BufferSize); /* Open file. */ fs::FileHandle file; - R_TRY(fs::OpenFile(std::addressof(file), this->file_path, fs::OpenMode_Read)); + R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Read header. */ - R_TRY(fs::ReadFile(file, 0, std::addressof(this->header), sizeof(this->header))); + R_TRY(fs::ReadFile(file, 0, std::addressof(m_header), sizeof(m_header))); /* Read entries. */ - R_TRY(fs::ReadFile(file, sizeof(this->header), this->keys, BufferSize)); + R_TRY(fs::ReadFile(file, sizeof(m_header), m_keys, BufferSize)); return ResultSuccess(); } @@ -97,14 +97,14 @@ namespace ams::kvdb { Result Save() { /* Open file. */ fs::FileHandle file; - R_TRY(fs::OpenFile(std::addressof(file), this->file_path, fs::OpenMode_Read)); + R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Write header. */ - R_TRY(fs::WriteFile(file, 0, std::addressof(this->header), sizeof(this->header), fs::WriteOption::None)); + R_TRY(fs::WriteFile(file, 0, std::addressof(m_header), sizeof(m_header), fs::WriteOption::None)); /* Write entries. */ - R_TRY(fs::WriteFile(file, sizeof(this->header), this->keys, BufferSize, fs::WriteOption::None)); + R_TRY(fs::WriteFile(file, sizeof(m_header), m_keys, BufferSize, fs::WriteOption::None)); /* Flush. */ R_TRY(fs::FlushFile(file)); @@ -113,7 +113,7 @@ namespace ams::kvdb { } size_t GetCount() const { - return this->header.entry_count; + return m_header.entry_count; } bool IsEmpty() const { @@ -126,7 +126,7 @@ namespace ams::kvdb { Key Get(size_t i) const { AMS_ABORT_UNLESS(i < this->GetCount()); - return this->keys[i]; + return m_keys[i]; } Key Peek() const { @@ -136,7 +136,7 @@ namespace ams::kvdb { void Push(const Key &key) { AMS_ABORT_UNLESS(!this->IsFull()); - this->keys[this->GetCount()] = key; + m_keys[this->GetCount()] = key; this->IncrementCount(); } @@ -150,7 +150,7 @@ namespace ams::kvdb { /* Iterate over the list, removing the last entry that matches the key. */ for (size_t i = 0; i < count; i++) { - if (this->keys[count - 1 - i] == key) { + if (m_keys[count - 1 - i] == key) { this->RemoveIndex(count - 1 - i); return true; } @@ -164,7 +164,7 @@ namespace ams::kvdb { /* Iterate over the list, checking to see if we have the key. */ for (size_t i = 0; i < count; i++) { - if (this->keys[count - 1 - i] == key) { + if (m_keys[count - 1 - i] == key) { return true; } } @@ -196,8 +196,8 @@ namespace ams::kvdb { /* as FileKeyValueStore paths are limited to 0x100 anyway. */ using Path = typename LeastRecentlyUsedList::Path; private: - FileKeyValueStore kvs; - LeastRecentlyUsedList lru_list; + FileKeyValueStore m_kvs; + LeastRecentlyUsedList m_lru_list; private: static constexpr Path GetLeastRecentlyUsedListPath(const char *dir) { return Path::MakeFormat("%s/%s", dir, "lru_list.dat"); @@ -258,14 +258,14 @@ namespace ams::kvdb { } private: void RemoveOldestKey() { - const Key &oldest_key = this->lru_list.Peek(); - this->lru_list.Pop(); - this->kvs.Remove(oldest_key); + const Key &oldest_key = m_lru_list.Peek(); + m_lru_list.Pop(); + m_kvs.Remove(oldest_key); } public: Result Initialize(const char *dir, void *buf, size_t size) { /* Initialize list. */ - R_TRY(this->lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size)); + R_TRY(m_lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size)); /* Initialize kvs. */ /* NOTE: Despite creating the kvs folder and returning an error if it does not exist, */ @@ -274,13 +274,13 @@ namespace ams::kvdb { /* instead of in the same directory as a folder containing the store's .val files. */ /* This is probably a Nintendo bug, but because system saves contain data in the wrong */ /* layout it can't really be fixed without breaking existing devices... */ - R_TRY(this->kvs.Initialize(dir)); + R_TRY(m_kvs.Initialize(dir)); return ResultSuccess(); } size_t GetCount() const { - return this->lru_list.GetCount(); + return m_lru_list.GetCount(); } size_t GetCapacity() const { @@ -288,53 +288,53 @@ namespace ams::kvdb { } Key GetKey(size_t i) const { - return this->lru_list.Get(i); + return m_lru_list.Get(i); } bool Contains(const Key &key) const { - return this->lru_list.Contains(key); + return m_lru_list.Contains(key); } Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { /* Note that we accessed the key. */ - this->lru_list.Update(key); - return this->kvs.Get(out_size, out_value, max_out_size, key); + m_lru_list.Update(key); + return m_kvs.Get(out_size, out_value, max_out_size, key); } template Result Get(Value *out_value, const Key &key) { /* Note that we accessed the key. */ - this->lru_list.Update(key); - return this->kvs.Get(out_value, key); + m_lru_list.Update(key); + return m_kvs.Get(out_value, key); } Result GetSize(size_t *out_size, const Key &key) { - return this->kvs.GetSize(out_size, key); + return m_kvs.GetSize(out_size, key); } Result Set(const Key &key, const void *value, size_t value_size) { - if (this->lru_list.Update(key)) { + if (m_lru_list.Update(key)) { /* If an entry for the key exists, delete the existing value file. */ - this->kvs.Remove(key); + m_kvs.Remove(key); } else { /* If the list is full, we need to remove the oldest key. */ - if (this->lru_list.IsFull()) { + if (m_lru_list.IsFull()) { this->RemoveOldestKey(); } /* Add the key to the list. */ - this->lru_list.Push(key); + m_lru_list.Push(key); } /* Loop, trying to save the new value to disk. */ while (true) { /* Try to set the key. */ - R_TRY_CATCH(this->kvs.Set(key, value, value_size)) { + R_TRY_CATCH(m_kvs.Set(key, value, value_size)) { R_CATCH(fs::ResultNotEnoughFreeSpace) { /* If our entry is the only thing in the Lru list, remove it. */ - if (this->lru_list.GetCount() == 1) { - this->lru_list.Pop(); - R_TRY(this->lru_list.Save()); + if (m_lru_list.GetCount() == 1) { + m_lru_list.Pop(); + R_TRY(m_lru_list.Save()); return fs::ResultNotEnoughFreeSpace(); } @@ -349,7 +349,7 @@ namespace ams::kvdb { } /* Save the list. */ - R_TRY(this->lru_list.Save()); + R_TRY(m_lru_list.Save()); return ResultSuccess(); } @@ -361,19 +361,19 @@ namespace ams::kvdb { Result Remove(const Key &key) { /* Remove the key. */ - this->lru_list.Remove(key); - R_TRY(this->kvs.Remove(key)); - R_TRY(this->lru_list.Save()); + m_lru_list.Remove(key); + R_TRY(m_kvs.Remove(key)); + R_TRY(m_lru_list.Save()); return ResultSuccess(); } Result RemoveAll() { /* TODO: Nintendo doesn't check errors here. Should we? */ - while (!this->lru_list.IsEmpty()) { + while (!m_lru_list.IsEmpty()) { this->RemoveOldestKey(); } - R_TRY(this->lru_list.Save()); + R_TRY(m_lru_list.Save()); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp index 5ac396272..f2bd37148 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp @@ -42,17 +42,17 @@ namespace ams::kvdb { class Cache { private: - u8 *backing_buffer = nullptr; - size_t backing_buffer_size = 0; - size_t backing_buffer_free_offset = 0; - Entry *entries = nullptr; - size_t count = 0; - size_t capacity = 0; + u8 *m_backing_buffer = nullptr; + size_t m_backing_buffer_size = 0; + size_t m_backing_buffer_free_offset = 0; + Entry *m_entries = nullptr; + size_t m_count = 0; + size_t m_capacity = 0; private: void *Allocate(size_t size); bool HasEntries() const { - return this->entries != nullptr && this->capacity != 0; + return m_entries != nullptr && m_capacity != 0; } public: Result Initialize(void *buffer, size_t buffer_size, size_t capacity); @@ -63,14 +63,14 @@ namespace ams::kvdb { bool Contains(const void *key, size_t key_size); }; private: - os::SdkMutex lock; - Path dir_path; - Cache cache; + os::SdkMutex m_lock; + Path m_dir_path; + Cache m_cache; private: Path GetPath(const void *key, size_t key_size); Result GetKey(size_t *out_size, void *out_key, size_t max_out_size, const FileName &file_name); public: - FileKeyValueStore() : lock() { /* ... */ } + FileKeyValueStore() : m_lock() { /* ... */ } /* Basic accessors. */ Result Initialize(const char *dir); diff --git a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp index 2bce9b83c..07835329c 100644 --- a/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ b/libraries/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp @@ -33,36 +33,36 @@ namespace ams::kvdb { /* Subtypes. */ class Entry { private: - Key key; - void *value; - size_t value_size; + Key m_key; + void *m_value; + size_t m_value_size; public: - constexpr Entry(const Key &k, void *v, size_t s) : key(k), value(v), value_size(s) { /* ... */ } + constexpr Entry(const Key &k, void *v, size_t s) : m_key(k), m_value(v), m_value_size(s) { /* ... */ } const Key &GetKey() const { - return this->key; + return m_key; } template Value *GetValuePointer() { /* Size check. Note: Nintendo does not size check. */ if constexpr (!std::is_same::value) { - AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size); + AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size); /* Ensure we only get pod. */ static_assert(util::is_pod::value, "KeyValueStore Values must be pod"); } - return reinterpret_cast(this->value); + return reinterpret_cast(m_value); } template const Value *GetValuePointer() const { /* Size check. Note: Nintendo does not size check. */ if constexpr (!std::is_same::value) { - AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size); + AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size); /* Ensure we only get pod. */ static_assert(util::is_pod::value, "KeyValueStore Values must be pod"); } - return reinterpret_cast(this->value); + return reinterpret_cast(m_value); } template @@ -76,55 +76,55 @@ namespace ams::kvdb { } size_t GetValueSize() const { - return this->value_size; + return m_value_size; } constexpr inline bool operator<(const Key &rhs) const { - return key < rhs; + return m_key < rhs; } constexpr inline bool operator==(const Key &rhs) const { - return key == rhs; + return m_key == rhs; } }; class Index { private: - size_t count; - size_t capacity; - Entry *entries; - MemoryResource *memory_resource; + size_t m_count; + size_t m_capacity; + Entry *m_entries; + MemoryResource *m_memory_resource; public: - Index() : count(0), capacity(0), entries(nullptr), memory_resource(nullptr) { /* ... */ } + Index() : m_count(0), m_capacity(0), m_entries(nullptr), m_memory_resource(nullptr) { /* ... */ } ~Index() { - if (this->entries != nullptr) { + if (m_entries != nullptr) { this->ResetEntries(); - this->memory_resource->Deallocate(this->entries, sizeof(Entry) * this->capacity); - this->entries = nullptr; + m_memory_resource->Deallocate(m_entries, sizeof(Entry) * m_capacity); + m_entries = nullptr; } } size_t GetCount() const { - return this->count; + return m_count; } size_t GetCapacity() const { - return this->capacity; + return m_capacity; } void ResetEntries() { - for (size_t i = 0; i < this->count; i++) { - this->memory_resource->Deallocate(this->entries[i].GetValuePointer(), this->entries[i].GetValueSize()); + for (size_t i = 0; i < m_count; i++) { + m_memory_resource->Deallocate(m_entries[i].GetValuePointer(), m_entries[i].GetValueSize()); } - this->count = 0; + m_count = 0; } Result Initialize(size_t capacity, MemoryResource *mr) { - this->entries = reinterpret_cast(mr->Allocate(sizeof(Entry) * capacity)); - R_UNLESS(this->entries != nullptr, kvdb::ResultAllocationFailed()); - this->capacity = capacity; - this->memory_resource = mr; + m_entries = reinterpret_cast(mr->Allocate(sizeof(Entry) * capacity)); + R_UNLESS(m_entries != nullptr, kvdb::ResultAllocationFailed()); + m_capacity = capacity; + m_memory_resource = mr; return ResultSuccess(); } @@ -133,16 +133,16 @@ namespace ams::kvdb { Entry *it = this->lower_bound(key); if (it != this->end() && it->GetKey() == key) { /* Entry already exists. Free old value. */ - this->memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); + m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); } else { /* We need to add a new entry. Check we have room, move future keys forward. */ - R_UNLESS(this->count < this->capacity, kvdb::ResultOutOfKeyResource()); + R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource()); std::memmove(it + 1, it, sizeof(*it) * (this->end() - it)); - this->count++; + m_count++; } /* Allocate new value. */ - void *new_value = this->memory_resource->Allocate(value_size); + void *new_value = m_memory_resource->Allocate(value_size); R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed()); std::memcpy(new_value, value, value_size); @@ -152,9 +152,9 @@ namespace ams::kvdb { } Result AddUnsafe(const Key &key, void *value, size_t value_size) { - R_UNLESS(this->count < this->capacity, kvdb::ResultOutOfKeyResource()); + R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource()); - this->entries[this->count++] = Entry(key, value, value_size); + m_entries[m_count++] = Entry(key, value, value_size); return ResultSuccess(); } @@ -164,9 +164,9 @@ namespace ams::kvdb { R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound()); /* Free the value, move entries back. */ - this->memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); + m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize()); std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1))); - this->count--; + m_count--; return ResultSuccess(); } @@ -211,19 +211,19 @@ namespace ams::kvdb { } private: Entry *GetBegin() { - return this->entries; + return m_entries; } const Entry *GetBegin() const { - return this->entries; + return m_entries; } Entry *GetEnd() { - return this->GetBegin() + this->count; + return this->GetBegin() + m_count; } const Entry *GetEnd() const { - return this->GetBegin() + this->count; + return this->GetBegin() + m_count; } Entry *GetLowerBound(const Key &key) { @@ -255,10 +255,10 @@ namespace ams::kvdb { private: using Path = kvdb::BoundedString; private: - Index index; - Path path; - Path temp_path; - MemoryResource *memory_resource; + Index m_index; + Path m_path; + Path m_temp_path; + MemoryResource *m_memory_resource; public: MemoryKeyValueStore() { /* ... */ } @@ -269,12 +269,12 @@ namespace ams::kvdb { R_UNLESS(entry_type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound()); /* Set paths. */ - this->path.SetFormat("%s%s", dir, "/imkvdb.arc"); - this->temp_path.SetFormat("%s%s", dir, "/imkvdb.tmp"); + m_path.SetFormat("%s%s", dir, "/imkvdb.arc"); + m_temp_path.SetFormat("%s%s", dir, "/imkvdb.tmp"); /* Initialize our index. */ - R_TRY(this->index.Initialize(capacity, mr)); - this->memory_resource = mr; + R_TRY(m_index.Initialize(capacity, mr)); + m_memory_resource = mr; return ResultSuccess(); } @@ -282,26 +282,26 @@ namespace ams::kvdb { Result Initialize(size_t capacity, MemoryResource *mr) { /* This initializes without an archive file. */ /* A store initialized this way cannot have its contents loaded from or flushed to disk. */ - this->path.Set(""); - this->temp_path.Set(""); + m_path.Set(""); + m_temp_path.Set(""); /* Initialize our index. */ - R_TRY(this->index.Initialize(capacity, mr)); - this->memory_resource = mr; + R_TRY(m_index.Initialize(capacity, mr)); + m_memory_resource = mr; return ResultSuccess(); } size_t GetCount() const { - return this->index.GetCount(); + return m_index.GetCount(); } size_t GetCapacity() const { - return this->index.GetCapacity(); + return m_index.GetCapacity(); } Result Load() { /* Reset any existing entries. */ - this->index.ResetEntries(); + m_index.ResetEntries(); /* Try to read the archive -- note, path not found is a success condition. */ /* This is because no archive file = no entries, so we're in the right state. */ @@ -323,14 +323,14 @@ namespace ams::kvdb { R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size))); /* Allocate memory for value. */ - void *new_value = this->memory_resource->Allocate(value_size); + void *new_value = m_memory_resource->Allocate(value_size); R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed()); - auto value_guard = SCOPE_GUARD { this->memory_resource->Deallocate(new_value, value_size); }; + auto value_guard = SCOPE_GUARD { m_memory_resource->Deallocate(new_value, value_size); }; /* Read key and value. */ Key key; R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size)); - R_TRY(this->index.AddUnsafe(key, new_value, value_size)); + R_TRY(m_index.AddUnsafe(key, new_value, value_size)); /* We succeeded, so cancel the value guard to prevent deallocation. */ value_guard.Cancel(); @@ -349,7 +349,7 @@ namespace ams::kvdb { { ArchiveWriter writer(buffer); writer.WriteHeader(this->GetCount()); - for (const auto &it : this->index) { + for (const auto &it : m_index) { const auto &key = it.GetKey(); writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize()); } @@ -360,7 +360,7 @@ namespace ams::kvdb { } Result Set(const Key &key, const void *value, size_t value_size) { - return this->index.Set(key, value, value_size); + return m_index.Set(key, value, value_size); } template @@ -428,47 +428,47 @@ namespace ams::kvdb { } Result Remove(const Key &key) { - return this->index.Remove(key); + return m_index.Remove(key); } Entry *begin() { - return this->index.begin(); + return m_index.begin(); } const Entry *begin() const { - return this->index.begin(); + return m_index.begin(); } Entry *end() { - return this->index.end(); + return m_index.end(); } const Entry *end() const { - return this->index.end(); + return m_index.end(); } const Entry *cbegin() const { - return this->index.cbegin(); + return m_index.cbegin(); } const Entry *cend() const { - return this->index.cend(); + return m_index.cend(); } Entry *lower_bound(const Key &key) { - return this->index.lower_bound(key); + return m_index.lower_bound(key); } const Entry *lower_bound(const Key &key) const { - return this->index.lower_bound(key); + return m_index.lower_bound(key); } Entry *find(const Key &key) { - return this->index.find(key); + return m_index.find(key); } const Entry *find(const Key &key) const { - return this->index.find(key); + return m_index.find(key); } private: Result SaveArchiveToFile(const char *path, const void *buf, size_t size) { @@ -492,16 +492,16 @@ namespace ams::kvdb { Result Commit(const AutoBuffer &buffer, bool destructive) { if (destructive) { /* Delete and save to the real archive. */ - R_TRY(SaveArchiveToFile(this->path.Get(), buffer.Get(), buffer.GetSize())); + R_TRY(SaveArchiveToFile(m_path.Get(), buffer.Get(), buffer.GetSize())); } else { /* Delete and save to a temporary archive. */ - R_TRY(SaveArchiveToFile(this->temp_path.Get(), buffer.Get(), buffer.GetSize())); + R_TRY(SaveArchiveToFile(m_temp_path.Get(), buffer.Get(), buffer.GetSize())); /* Try to delete the saved archive, but allow deletion failure. */ - fs::DeleteFile(this->path.Get()); + fs::DeleteFile(m_path.Get()); /* Rename the path. */ - R_TRY(fs::RenameFile(this->temp_path.Get(), this->path.Get())); + R_TRY(fs::RenameFile(m_temp_path.Get(), m_path.Get())); } return ResultSuccess(); @@ -510,7 +510,7 @@ namespace ams::kvdb { size_t GetArchiveSize() const { ArchiveSizeHelper size_helper; - for (const auto &it : this->index) { + for (const auto &it : m_index) { size_helper.AddEntry(sizeof(Key), it.GetValueSize()); } @@ -520,7 +520,7 @@ namespace ams::kvdb { Result ReadArchiveFile(AutoBuffer *dst) const { /* Open the file. */ fs::FileHandle file; - R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Read)); + R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Get the archive file size. */ diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp index 995348221..18e4f686e 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_add_on_content_location_resolver.hpp @@ -23,13 +23,13 @@ namespace ams::lr { class AddOnContentLocationResolver { NON_COPYABLE(AddOnContentLocationResolver); private: - sf::SharedPointer interface; + sf::SharedPointer m_interface; public: AddOnContentLocationResolver() { /* ... */ } - explicit AddOnContentLocationResolver(sf::SharedPointer intf) : interface(intf) { /* ... */ } + explicit AddOnContentLocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } AddOnContentLocationResolver(AddOnContentLocationResolver &&rhs) { - this->interface = std::move(rhs.interface); + m_interface = std::move(rhs.m_interface); } AddOnContentLocationResolver &operator=(AddOnContentLocationResolver &&rhs) { @@ -38,37 +38,37 @@ namespace ams::lr { } void Swap(AddOnContentLocationResolver &rhs) { - std::swap(this->interface, rhs.interface); + std::swap(m_interface, rhs.m_interface); } public: /* Actual commands. */ Result ResolveAddOnContentPath(Path *out, ncm::DataId id) { - AMS_ASSERT(this->interface); - return this->interface->ResolveAddOnContentPath(out, id); + AMS_ASSERT(m_interface); + return m_interface->ResolveAddOnContentPath(out, id); } Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) { - AMS_ASSERT(this->interface); + AMS_ASSERT(m_interface); if (hos::GetVersion() >= hos::Version_9_0_0) { - return this->interface->RegisterAddOnContentStorage(id, application_id, storage_id); + return m_interface->RegisterAddOnContentStorage(id, application_id, storage_id); } else { - return this->interface->RegisterAddOnContentStorageDeprecated(id, storage_id); + return m_interface->RegisterAddOnContentStorageDeprecated(id, storage_id); } } Result UnregisterAllAddOnContentPath() { - AMS_ASSERT(this->interface); - return this->interface->UnregisterAllAddOnContentPath(); + AMS_ASSERT(m_interface); + return m_interface->UnregisterAllAddOnContentPath(); } Result RefreshApplicationAddOnContent(const ncm::ApplicationId *ids, size_t num_ids) { - AMS_ASSERT(this->interface); - return this->interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids)); + AMS_ASSERT(m_interface); + return m_interface->RefreshApplicationAddOnContent(sf::InArray(ids, num_ids)); } Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) { - AMS_ASSERT(this->interface); - return this->interface->UnregisterApplicationAddOnContent(id); + AMS_ASSERT(m_interface); + return m_interface->UnregisterApplicationAddOnContent(id); } }; diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp index 05ee11276..e6790dd3d 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver.hpp @@ -23,13 +23,13 @@ namespace ams::lr { class LocationResolver { NON_COPYABLE(LocationResolver); private: - sf::SharedPointer interface; + sf::SharedPointer m_interface; public: LocationResolver() { /* ... */ } - explicit LocationResolver(sf::SharedPointer intf) : interface(intf) { /* ... */ } + explicit LocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } LocationResolver(LocationResolver &&rhs) { - this->interface = std::move(rhs.interface); + m_interface = std::move(rhs.m_interface); } LocationResolver &operator=(LocationResolver &&rhs) { @@ -38,137 +38,137 @@ namespace ams::lr { } void swap(LocationResolver &rhs) { - std::swap(this->interface, rhs.interface); + std::swap(m_interface, rhs.m_interface); } public: Result ResolveProgramPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveProgramPath(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveProgramPath(out, id); } void RedirectProgramPath(const Path &path, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - R_ABORT_UNLESS(this->interface->RedirectProgramPath(path, id)); + AMS_ASSERT(m_interface != nullptr); + R_ABORT_UNLESS(m_interface->RedirectProgramPath(path, id)); } Result ResolveApplicationControlPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveApplicationControlPath(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveApplicationControlPath(out, id); } Result ResolveApplicationHtmlDocumentPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveApplicationHtmlDocumentPath(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveApplicationHtmlDocumentPath(out, id); } Result ResolveDataPath(Path *out, ncm::DataId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveDataPath(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveDataPath(out, id); } void RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectApplicationControlPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationControlPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectApplicationControlPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationControlPathDeprecated(path, id)); } } void RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectApplicationHtmlDocumentPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationHtmlDocumentPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectApplicationHtmlDocumentPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationHtmlDocumentPathDeprecated(path, id)); } } Result ResolveApplicationLegalInformationPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveApplicationLegalInformationPath(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveApplicationLegalInformationPath(out, id); } void RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectApplicationLegalInformationPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationLegalInformationPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectApplicationLegalInformationPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationLegalInformationPathDeprecated(path, id)); } } Result Refresh() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Refresh(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Refresh(); } void RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathDeprecated(path, id)); } } Result ClearApplicationRedirection() { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); AMS_ASSERT(hos::GetVersion() < hos::Version_9_0_0); return this->ClearApplicationRedirection(nullptr, 0); } Result ClearApplicationRedirection(const ncm::ProgramId *excluding_ids, size_t num_ids) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - return this->interface->ClearApplicationRedirection(sf::InArray(excluding_ids, num_ids)); + return m_interface->ClearApplicationRedirection(sf::InArray(excluding_ids, num_ids)); } else { - return this->interface->ClearApplicationRedirectionDeprecated(); + return m_interface->ClearApplicationRedirectionDeprecated(); } } Result EraseProgramRedirection(ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->EraseProgramRedirection(id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->EraseProgramRedirection(id); } Result EraseApplicationControlRedirection(ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->EraseApplicationControlRedirection(id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->EraseApplicationControlRedirection(id); } Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->EraseApplicationHtmlDocumentRedirection(id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->EraseApplicationHtmlDocumentRedirection(id); } Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->EraseApplicationLegalInformationRedirection(id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->EraseApplicationLegalInformationRedirection(id); } Result ResolveProgramPathForDebug(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ResolveProgramPathForDebug(out, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ResolveProgramPathForDebug(out, id); } void RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - R_ABORT_UNLESS(this->interface->RedirectProgramPathForDebug(path, id)); + AMS_ASSERT(m_interface != nullptr); + R_ABORT_UNLESS(m_interface->RedirectProgramPathForDebug(path, id)); } void RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathForDebug(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathForDebug(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathForDebugDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathForDebugDeprecated(path, id)); } } Result EraseProgramRedirectionForDebug(ncm::ProgramId id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->EraseProgramRedirectionForDebug(id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->EraseProgramRedirectionForDebug(id); } }; diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp index 640edb867..5d488eae3 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_location_resolver_manager_impl.hpp @@ -24,11 +24,11 @@ namespace ams::lr { class LocationResolverManagerImpl { private: /* Resolver storage. */ - ncm::BoundedMap, 5> location_resolvers; - sf::SharedPointer registered_location_resolver = nullptr; - sf::SharedPointer add_on_content_location_resolver = nullptr; + ncm::BoundedMap, 5> m_location_resolvers{}; + sf::SharedPointer m_registered_location_resolver = nullptr; + sf::SharedPointer m_add_on_content_location_resolver = nullptr; - os::SdkMutex mutex{}; + os::SdkMutex m_mutex{}; public: /* Actual commands. */ Result OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id); diff --git a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp index 0a998d79d..127056fb7 100644 --- a/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp +++ b/libraries/libstratosphere/include/stratosphere/lr/lr_registered_location_resolver.hpp @@ -23,13 +23,13 @@ namespace ams::lr { class RegisteredLocationResolver { NON_COPYABLE(RegisteredLocationResolver); private: - sf::SharedPointer interface; + sf::SharedPointer m_interface; public: RegisteredLocationResolver() { /* ... */ } - explicit RegisteredLocationResolver(sf::SharedPointer intf) : interface(intf) { /* ... */ } + explicit RegisteredLocationResolver(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } RegisteredLocationResolver(RegisteredLocationResolver &&rhs) { - this->interface = std::move(rhs.interface); + m_interface = std::move(rhs.m_interface); } RegisteredLocationResolver &operator=(RegisteredLocationResolver &&rhs) { @@ -38,74 +38,74 @@ namespace ams::lr { } void Swap(RegisteredLocationResolver &rhs) { - std::swap(this->interface, rhs.interface); + std::swap(m_interface, rhs.m_interface); } public: /* Actual commands. */ Result ResolveProgramPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface); - return this->interface->ResolveProgramPath(out, id); + AMS_ASSERT(m_interface); + return m_interface->ResolveProgramPath(out, id); } Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface); + AMS_ASSERT(m_interface); if (hos::GetVersion() >= hos::Version_9_0_0) { - return this->interface->RegisterProgramPath(path, id, owner_id); + return m_interface->RegisterProgramPath(path, id, owner_id); } else { - return this->interface->RegisterProgramPathDeprecated(path, id); + return m_interface->RegisterProgramPathDeprecated(path, id); } } Result UnregisterProgramPath(ncm::ProgramId id) { - AMS_ASSERT(this->interface); - return this->interface->UnregisterProgramPath(id); + AMS_ASSERT(m_interface); + return m_interface->UnregisterProgramPath(id); } void RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface); + AMS_ASSERT(m_interface); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectProgramPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectProgramPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectProgramPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectProgramPathDeprecated(path, id)); } } Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) { - AMS_ASSERT(this->interface); - return this->interface->ResolveHtmlDocumentPath(out, id); + AMS_ASSERT(m_interface); + return m_interface->ResolveHtmlDocumentPath(out, id); } Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface); + AMS_ASSERT(m_interface); if (hos::GetVersion() >= hos::Version_9_0_0) { - return this->interface->RegisterHtmlDocumentPath(path, id, owner_id); + return m_interface->RegisterHtmlDocumentPath(path, id, owner_id); } else { - return this->interface->RegisterHtmlDocumentPathDeprecated(path, id); + return m_interface->RegisterHtmlDocumentPathDeprecated(path, id); } } Result UnregisterHtmlDocumentPath(ncm::ProgramId id) { - AMS_ASSERT(this->interface); - return this->interface->UnregisterHtmlDocumentPath(id); + AMS_ASSERT(m_interface); + return m_interface->UnregisterHtmlDocumentPath(id); } void RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - AMS_ASSERT(this->interface); + AMS_ASSERT(m_interface); if (hos::GetVersion() >= hos::Version_9_0_0) { - R_ABORT_UNLESS(this->interface->RedirectHtmlDocumentPath(path, id, owner_id)); + R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPath(path, id, owner_id)); } else { - R_ABORT_UNLESS(this->interface->RedirectHtmlDocumentPathDeprecated(path, id)); + R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPathDeprecated(path, id)); } } Result Refresh() { - AMS_ASSERT(this->interface); - return this->interface->Refresh(); + AMS_ASSERT(m_interface); + return m_interface->Refresh(); } Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) { - AMS_ASSERT(this->interface); - return this->interface->RefreshExcluding(sf::InArray(excluding_ids, num_ids)); + AMS_ASSERT(m_interface); + return m_interface->RefreshExcluding(sf::InArray(excluding_ids, num_ids)); } }; diff --git a/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp b/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp index 3178b394e..ce7ad6c31 100644 --- a/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp +++ b/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_cached_heap.hpp @@ -24,18 +24,18 @@ namespace ams::mem::impl::heap { class CachedHeap final { NON_COPYABLE(CachedHeap); private: - TlsHeapCache *tls_heap_cache; + TlsHeapCache *m_tls_heap_cache; public: - constexpr CachedHeap() : tls_heap_cache() { /* ... */ } + constexpr CachedHeap() : m_tls_heap_cache() { /* ... */ } ~CachedHeap() { this->Finalize(); } - ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : tls_heap_cache(rhs.tls_heap_cache) { - rhs.tls_heap_cache = nullptr; + ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : m_tls_heap_cache(rhs.m_tls_heap_cache) { + rhs.m_tls_heap_cache = nullptr; } ALWAYS_INLINE CachedHeap &operator=(CachedHeap &&rhs) { this->Reset(); - this->tls_heap_cache = rhs.tls_heap_cache; - rhs.tls_heap_cache = nullptr; + m_tls_heap_cache = rhs.m_tls_heap_cache; + rhs.m_tls_heap_cache = nullptr; return *this; } @@ -57,7 +57,7 @@ namespace ams::mem::impl::heap { void Reset(TlsHeapCache *thc); TlsHeapCache *Release(); - constexpr explicit ALWAYS_INLINE operator bool() const { return this->tls_heap_cache != nullptr; } + constexpr explicit ALWAYS_INLINE operator bool() const { return m_tls_heap_cache != nullptr; } }; } diff --git a/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp b/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp index bd7e61745..0a8b46a49 100644 --- a/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp +++ b/libraries/libstratosphere/include/stratosphere/mem/impl/heap/mem_impl_heap_central_heap.hpp @@ -33,13 +33,13 @@ namespace ams::mem::impl::heap { static constexpr size_t MinimumAlignment = alignof(u64); using DestructorHandler = void (*)(void *start, void *end); private: - TlsHeapCentral *tls_heap_central; - bool use_virtual_memory; - u32 option; - u8 *start; - u8 *end; + TlsHeapCentral *m_tls_heap_central; + bool m_use_virtual_memory; + u32 m_option; + u8 *m_start; + u8 *m_end; public: - constexpr CentralHeap() : tls_heap_central(), use_virtual_memory(), option(), start(), end() { /* ... */ } + constexpr CentralHeap() : m_tls_heap_central(), m_use_virtual_memory(), m_option(), m_start(), m_end() { /* ... */ } ~CentralHeap() { this->Finalize(); } errno_t Initialize(void *start, size_t size, u32 option); diff --git a/libraries/libstratosphere/include/stratosphere/mem/mem_standard_allocator.hpp b/libraries/libstratosphere/include/stratosphere/mem/mem_standard_allocator.hpp index 864e26d10..a74a0e294 100644 --- a/libraries/libstratosphere/include/stratosphere/mem/mem_standard_allocator.hpp +++ b/libraries/libstratosphere/include/stratosphere/mem/mem_standard_allocator.hpp @@ -31,18 +31,18 @@ namespace ams::mem { size_t hash; }; private: - bool initialized; - bool enable_thread_cache; - uintptr_t unused; - os::TlsSlot tls_slot; - impl::InternalCentralHeapStorage central_heap_storage; + bool m_initialized; + bool m_enable_thread_cache; + uintptr_t m_unused; + os::TlsSlot m_tls_slot; + impl::InternalCentralHeapStorage m_central_heap_storage; public: StandardAllocator(); StandardAllocator(void *mem, size_t size); StandardAllocator(void *mem, size_t size, bool enable_cache); ~StandardAllocator() { - if (this->initialized) { + if (m_initialized) { this->Finalize(); } } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_auto_buffer.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_auto_buffer.hpp index 768eaf32b..f74c5f921 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_auto_buffer.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_auto_buffer.hpp @@ -21,20 +21,20 @@ namespace ams::ncm { class AutoBuffer { NON_COPYABLE(AutoBuffer); private: - u8 *buffer; - size_t size; + u8 *m_buffer; + size_t m_size; public: - AutoBuffer() : buffer(nullptr), size(0) { /* ... */ } + AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ } ~AutoBuffer() { this->Reset(); } AutoBuffer(AutoBuffer &&rhs) { - this->buffer = rhs.buffer; - this->size = rhs.size; - rhs.buffer = nullptr; - rhs.size = 0; + m_buffer = rhs.m_buffer; + m_size = rhs.m_size; + rhs.m_buffer = nullptr; + rhs.m_size = 0; } AutoBuffer &operator=(AutoBuffer &&rhs) { @@ -43,35 +43,35 @@ namespace ams::ncm { } void Swap(AutoBuffer &rhs) { - std::swap(this->buffer, rhs.buffer); - std::swap(this->size, rhs.size); + std::swap(m_buffer, rhs.m_buffer); + std::swap(m_size, rhs.m_size); } void Reset() { - if (this->buffer != nullptr) { - delete[] this->buffer; - this->buffer = nullptr; - this->size = 0; + if (m_buffer != nullptr) { + delete[] m_buffer; + m_buffer = nullptr; + m_size = 0; } } u8 *Get() const { - return this->buffer; + return m_buffer; } size_t GetSize() const { - return this->size; + return m_size; } Result Initialize(size_t size) { /* Check that we're not already initialized. */ - AMS_ABORT_UNLESS(this->buffer == nullptr); + AMS_ABORT_UNLESS(m_buffer == nullptr); /* Allocate a buffer. */ - this->buffer = new (std::nothrow) u8[size]; - R_UNLESS(this->buffer != nullptr, ncm::ResultAllocationFailed()); + m_buffer = new (std::nothrow) u8[size]; + R_UNLESS(m_buffer != nullptr, ncm::ResultAllocationFailed()); - this->size = size; + m_size = size; return ResultSuccess(); } @@ -80,7 +80,7 @@ namespace ams::ncm { R_TRY(this->Initialize(size)); /* Copy the input data in. */ - std::memcpy(this->buffer, buf, size); + std::memcpy(m_buffer, buf, size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_management_utils.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_management_utils.hpp index 566372038..07954b259 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_management_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_management_utils.hpp @@ -22,11 +22,11 @@ namespace ams::ncm { class ContentMetaDatabaseBuilder { private: - ContentMetaDatabase *db; + ContentMetaDatabase *m_db; private: Result BuildFromPackageContentMeta(void *buf, size_t size, const ContentInfo &meta_info); public: - explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : db(d) { /* ... */ } + explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : m_db(d) { /* ... */ } Result BuildFromStorage(ContentStorage *storage); Result BuildFromPackage(const char *package_root_path); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp index 4cb037f80..ed5f69e14 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_manager_impl.hpp @@ -33,26 +33,26 @@ namespace ams::ncm { class ContentMetaMemoryResource : public MemoryResource { private: - mem::StandardAllocator allocator; - size_t peak_total_alloc_size; - size_t peak_alloc_size; + mem::StandardAllocator m_allocator; + size_t m_peak_total_alloc_size; + size_t m_peak_alloc_size; public: - explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : allocator(heap, heap_size) { /* ... */ } + explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : m_allocator(heap, heap_size), m_peak_alloc_size(0), m_peak_total_alloc_size(0) { /* ... */ } - mem::StandardAllocator *GetAllocator() { return std::addressof(this->allocator); } - size_t GetPeakTotalAllocationSize() const { return this->peak_total_alloc_size; } - size_t GetPeakAllocationSize() const { return this->peak_alloc_size; } + mem::StandardAllocator *GetAllocator() { return std::addressof(m_allocator); } + size_t GetPeakTotalAllocationSize() const { return m_peak_total_alloc_size; } + size_t GetPeakAllocationSize() const { return m_peak_alloc_size; } private: virtual void *AllocateImpl(size_t size, size_t alignment) override { - void *mem = this->allocator.Allocate(size, alignment); - this->peak_total_alloc_size = std::max(this->allocator.Hash().allocated_size, this->peak_total_alloc_size); - this->peak_alloc_size = std::max(size, this->peak_alloc_size); + void *mem = m_allocator.Allocate(size, alignment); + m_peak_total_alloc_size = std::max(m_allocator.Hash().allocated_size, m_peak_total_alloc_size); + m_peak_alloc_size = std::max(size, m_peak_alloc_size); return mem; } virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override { AMS_UNUSED(size, alignment); - return this->allocator.Free(buffer); + return m_allocator.Free(buffer); } virtual bool IsEqualImpl(const MemoryResource &resource) const override { @@ -103,16 +103,16 @@ namespace ams::ncm { ContentMetaDatabaseRoot() { /* ... */ } }; private: - os::SdkRecursiveMutex mutex; - bool initialized; - ContentStorageRoot content_storage_roots[MaxContentStorageRoots]; - ContentMetaDatabaseRoot content_meta_database_roots[MaxContentMetaDatabaseRoots]; - u32 num_content_storage_entries; - u32 num_content_meta_entries; - RightsIdCache rights_id_cache; - RegisteredHostContent registered_host_content; + os::SdkRecursiveMutex m_mutex; + bool m_initialized; + ContentStorageRoot m_content_storage_roots[MaxContentStorageRoots]; + ContentMetaDatabaseRoot m_content_meta_database_roots[MaxContentMetaDatabaseRoots]; + u32 m_num_content_storage_entries; + u32 m_num_content_meta_entries; + RightsIdCache m_rights_id_cache; + RegisteredHostContent m_registered_host_content; public: - ContentManagerImpl() : mutex(), initialized(false), num_content_storage_entries(0), num_content_meta_entries(0), rights_id_cache(), registered_host_content() { + ContentManagerImpl() : m_mutex(), m_initialized(false), m_content_storage_roots(), m_content_meta_database_roots(), m_num_content_storage_entries(0), m_num_content_meta_entries(0), m_rights_id_cache(), m_registered_host_content() { /* ... */ }; ~ContentManagerImpl(); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp index bfb936f6e..d447697bc 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp @@ -118,9 +118,9 @@ namespace ams::ncm { using HeaderType = ContentMetaHeaderType; using InfoType = ContentInfoType; private: - void *data; - const size_t size; - bool is_header_valid; + void *m_data; + const size_t m_size; + bool m_is_header_valid; private: static size_t GetExtendedHeaderSize(ContentMetaType type) { switch (type) { @@ -132,8 +132,8 @@ namespace ams::ncm { } } protected: - constexpr ContentMetaAccessor(const void *d, size_t sz) : data(const_cast(d)), size(sz), is_header_valid(true) { /* ... */ } - constexpr ContentMetaAccessor(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ } + constexpr ContentMetaAccessor(const void *d, size_t sz) : m_data(const_cast(d)), m_size(sz), m_is_header_valid(true) { /* ... */ } + constexpr ContentMetaAccessor(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ } template static constexpr size_t CalculateSizeImpl(size_t ext_header_size, size_t content_count, size_t content_meta_count, size_t extended_data_size, bool has_digest) { @@ -145,7 +145,7 @@ namespace ams::ncm { } uintptr_t GetExtendedHeaderAddress() const { - return reinterpret_cast(this->data) + sizeof(HeaderType); + return reinterpret_cast(m_data) + sizeof(HeaderType); } uintptr_t GetContentInfoStartAddress() const { @@ -214,21 +214,21 @@ namespace ams::ncm { public: const void *GetData() const { - return this->data; + return m_data; } size_t GetSize() const { - return this->size; + return m_size; } HeaderType *GetWritableHeader() const { - AMS_ABORT_UNLESS(this->is_header_valid); - return reinterpret_cast(this->data); + AMS_ABORT_UNLESS(m_is_header_valid); + return reinterpret_cast(m_data); } const HeaderType *GetHeader() const { - AMS_ABORT_UNLESS(this->is_header_valid); - return static_cast(this->data); + AMS_ABORT_UNLESS(m_is_header_valid); + return static_cast(m_data); } ContentMetaKey GetKey() const { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp index 5a3c7436b..32393f746 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp @@ -26,13 +26,13 @@ namespace ams::ncm { s32 total; }; private: - sf::SharedPointer interface; + sf::SharedPointer m_interface; public: ContentMetaDatabase() { /* ... */ } - explicit ContentMetaDatabase(sf::SharedPointer intf) : interface(intf) { /* ... */ } + explicit ContentMetaDatabase(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } ContentMetaDatabase(ContentMetaDatabase &&rhs) { - this->interface = std::move(rhs.interface); + m_interface = std::move(rhs.m_interface); } ContentMetaDatabase &operator=(ContentMetaDatabase &&rhs) { @@ -41,18 +41,18 @@ namespace ams::ncm { } void swap(ContentMetaDatabase &rhs) { - std::swap(this->interface, rhs.interface); + std::swap(m_interface, rhs.m_interface); } public: Result Set(const ContentMetaKey &key, const void *buf, size_t size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Set(key, sf::InBuffer(buf, size)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Set(key, sf::InBuffer(buf, size)); } Result Get(size_t *out_size, void *dst, size_t dst_size, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); u64 size; - R_TRY(this->interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size))); + R_TRY(m_interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size))); *out_size = size; return ResultSuccess(); @@ -60,13 +60,13 @@ namespace ams::ncm { #define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \ Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \ - return this->interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \ + return m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \ } \ \ Result GetLatest##Kind(ContentId *out, IdType##Id id) { \ ContentMetaKey latest_key; \ - R_TRY(this->interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \ - return this->interface->GetContentIdByType(out, latest_key, ContentType::Kind); \ + R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \ + return m_interface->GetContentIdByType(out, latest_key, ContentType::Kind); \ } AMS_NCM_DEFINE_GETTERS(Program, Program) @@ -78,8 +78,8 @@ namespace ams::ncm { #undef AMS_NCM_DEFINE_GETTERS Result Remove(const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Remove(key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Remove(key); } Result Remove(SystemProgramId id, u32 version) { @@ -95,99 +95,99 @@ namespace ams::ncm { } Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetContentIdByType(out_content_id, key, type); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetContentIdByType(out_content_id, key, type); } Result GetContentIdByTypeAndIdOffset(ContentId *out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset); } ListCount ListApplication(ApplicationContentMetaKey *dst, size_t dst_size) { ListCount lc = {}; - R_ABORT_UNLESS(this->interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray(dst, dst_size), ContentMetaType::Unknown)); + R_ABORT_UNLESS(m_interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray(dst, dst_size), ContentMetaType::Unknown)); return lc; } ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type = ContentMetaType::Unknown, ApplicationId app_id = InvalidApplicationId, u64 min = std::numeric_limits::min(), u64 max = std::numeric_limits::max(), ContentInstallType install_type = ContentInstallType::Full) { ListCount lc = {}; - R_ABORT_UNLESS(this->interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray(dst, dst_size), type, app_id, min, max, install_type)); + R_ABORT_UNLESS(m_interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray(dst, dst_size), type, app_id, min, max, install_type)); return lc; } Result GetLatest(ContentMetaKey *out_key, u64 id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetLatestContentMetaKey(out_key, id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetLatestContentMetaKey(out_key, id); } Result ListContentInfo(s32 *out_count, ContentInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ListContentInfo(out_count, sf::OutArray(dst, dst_size), key, offset); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ListContentInfo(out_count, sf::OutArray(dst, dst_size), key, offset); } Result ListContentMetaInfo(s32 *out_count, ContentMetaInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ListContentMetaInfo(out_count, sf::OutArray(dst, dst_size), key, offset); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ListContentMetaInfo(out_count, sf::OutArray(dst, dst_size), key, offset); } Result Has(bool *out, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Has(out, key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Has(out, key); } Result HasAll(bool *out, const ContentMetaKey *keys, size_t num_keys) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->HasAll(out, sf::InArray(keys, num_keys)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->HasAll(out, sf::InArray(keys, num_keys)); } Result HasContent(bool *out, const ContentMetaKey &key, const ContentId &content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->HasContent(out, key, content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->HasContent(out, key, content_id); } Result GetSize(size_t *out_size, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); u64 size; - R_TRY(this->interface->GetSize(std::addressof(size), key)); + R_TRY(m_interface->GetSize(std::addressof(size), key)); *out_size = size; return ResultSuccess(); } Result GetRequiredSystemVersion(u32 *out_version, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetRequiredSystemVersion(out_version, key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetRequiredSystemVersion(out_version, key); } Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetPatchId(out_patch_id, key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetPatchId(out_patch_id, key); } Result DisableForcibly() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->DisableForcibly(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->DisableForcibly(); } Result LookupOrphanContent(bool *out_orphaned, ContentId *content_list, size_t count) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->LookupOrphanContent(sf::OutArray(out_orphaned, count), sf::InArray(content_list, count)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->LookupOrphanContent(sf::OutArray(out_orphaned, count), sf::InArray(content_list, count)); } Result Commit() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Commit(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Commit(); } Result GetAttributes(u8 *out_attributes, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetAttributes(out_attributes, key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetAttributes(out_attributes, key); } Result GetRequiredApplicationVersion(u32 *out_version, const ContentMetaKey &key) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetRequiredApplicationVersion(out_version, key); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetRequiredApplicationVersion(out_version, key); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp index 0cfa88759..505d9e6b9 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_extended_data.hpp @@ -112,10 +112,10 @@ namespace ams::ncm { template class PatchMetaExtendedDataReaderWriterBase { private: - MemberTypePointer data; - const size_t size; + MemberTypePointer m_data; + const size_t m_size; public: - PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : data(d), size(sz) { /* ... */ } + PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : m_data(d), m_size(sz) { /* ... */ } protected: s32 CountFragmentSet(s32 delta_index) const { auto delta_header = this->GetPatchDeltaHeader(0); @@ -154,7 +154,7 @@ namespace ams::ncm { } DataTypePointer GetHeaderAddress() const { - return reinterpret_cast(this->data); + return reinterpret_cast(m_data); } DataTypePointer GetPatchHistoryHeaderAddress(s32 index) const { @@ -307,15 +307,15 @@ namespace ams::ncm { class SystemUpdateMetaExtendedDataReaderWriterBase { private: - void *data; - const size_t size; - bool is_header_valid; + void *m_data; + const size_t m_size; + bool m_is_header_valid; protected: - constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : data(const_cast(d)), size(sz), is_header_valid(true) { /* ... */ } - constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ } + constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : m_data(const_cast(d)), m_size(sz), m_is_header_valid(true) { /* ... */ } + constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ } uintptr_t GetHeaderAddress() const { - return reinterpret_cast(this->data); + return reinterpret_cast(m_data); } uintptr_t GetFirmwareVariationIdStartAddress() const { @@ -343,7 +343,7 @@ namespace ams::ncm { } public: const SystemUpdateMetaExtendedDataHeader *GetHeader() const { - AMS_ABORT_UNLESS(this->is_header_valid); + AMS_ABORT_UNLESS(m_is_header_valid); return reinterpret_cast(this->GetHeaderAddress()); } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp index bcf4bff8c..43d207c7c 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp @@ -21,13 +21,13 @@ namespace ams::ncm { class ContentStorage { NON_COPYABLE(ContentStorage); private: - sf::SharedPointer interface; + sf::SharedPointer m_interface; public: ContentStorage() { /* ... */ } - explicit ContentStorage(sf::SharedPointer intf) : interface(intf) { /* ... */ } + explicit ContentStorage(sf::SharedPointer intf) : m_interface(intf) { /* ... */ } ContentStorage(ContentStorage &&rhs) { - this->interface = std::move(rhs.interface); + m_interface = std::move(rhs.m_interface); } ContentStorage &operator=(ContentStorage &&rhs) { @@ -36,166 +36,166 @@ namespace ams::ncm { } void swap(ContentStorage &rhs) { - std::swap(this->interface, rhs.interface); + std::swap(m_interface, rhs.m_interface); } public: PlaceHolderId GeneratePlaceHolderId() { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); PlaceHolderId id; - R_ABORT_UNLESS(this->interface->GeneratePlaceHolderId(std::addressof(id))); + R_ABORT_UNLESS(m_interface->GeneratePlaceHolderId(std::addressof(id))); return id; } Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->CreatePlaceHolder(placeholder_id, content_id, size); + AMS_ASSERT(m_interface != nullptr); + return m_interface->CreatePlaceHolder(placeholder_id, content_id, size); } Result DeletePlaceHolder(PlaceHolderId placeholder_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->DeletePlaceHolder(placeholder_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->DeletePlaceHolder(placeholder_id); } Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->HasPlaceHolder(out, placeholder_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->HasPlaceHolder(out, placeholder_id); } Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size)); } Result Register(PlaceHolderId placeholder_id, ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Register(placeholder_id, content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Register(placeholder_id, content_id); } Result Delete(ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Delete(content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Delete(content_id); } Result Has(bool *out, ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->Has(out, content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->Has(out, content_id); } void GetPath(Path *out, ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); - R_ABORT_UNLESS(this->interface->GetPath(out, content_id)); + AMS_ASSERT(m_interface != nullptr); + R_ABORT_UNLESS(m_interface->GetPath(out, content_id)); } void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) { - AMS_ASSERT(this->interface != nullptr); - R_ABORT_UNLESS(this->interface->GetPlaceHolderPath(out, placeholder_id)); + AMS_ASSERT(m_interface != nullptr); + R_ABORT_UNLESS(m_interface->GetPlaceHolderPath(out, placeholder_id)); } Result CleanupAllPlaceHolder() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->CleanupAllPlaceHolder(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->CleanupAllPlaceHolder(); } Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ListPlaceHolder(out_count, sf::OutArray(out_list, out_list_size)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ListPlaceHolder(out_count, sf::OutArray(out_list, out_list_size)); } Result GetContentCount(s32 *out_count) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetContentCount(out_count); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetContentCount(out_count); } Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ListContentId(out_count, sf::OutArray(out_list, out_list_size), offset); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ListContentId(out_count, sf::OutArray(out_list, out_list_size), offset); } Result GetSize(s64 *out_size, ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetSizeFromContentId(out_size, content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetSizeFromContentId(out_size, content_id); } Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetSizeFromPlaceHolderId(out_size, placeholder_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id); } Result DisableForcibly() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->DisableForcibly(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->DisableForcibly(); } Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id); } Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->SetPlaceHolderSize(placeholder_id, size); + AMS_ASSERT(m_interface != nullptr); + return m_interface->SetPlaceHolderSize(placeholder_id, size); } Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset); + AMS_ASSERT(m_interface != nullptr); + return m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset); } Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); const auto vers = hos::GetVersion(); if (vers >= hos::Version_3_0_0) { - return this->interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id); + return m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; - return this->interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id); + return m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id); } } Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id) { - AMS_ASSERT(this->interface != nullptr); + AMS_ASSERT(m_interface != nullptr); const auto vers = hos::GetVersion(); if (vers >= hos::Version_3_0_0) { - return this->interface->GetRightsIdFromContentId(out_rights_id, content_id); + return m_interface->GetRightsIdFromContentId(out_rights_id, content_id); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; - return this->interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id); + return m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id); } } Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size)); + AMS_ASSERT(m_interface != nullptr); + return m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size)); } Result GetFreeSpaceSize(s64 *out_size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetFreeSpaceSize(out_size); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetFreeSpaceSize(out_size); } Result GetTotalSpaceSize(s64 *out_size) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetTotalSpaceSize(out_size); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetTotalSpaceSize(out_size); } Result FlushPlaceHolder() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->FlushPlaceHolder(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->FlushPlaceHolder(); } Result RepairInvalidFileAttribute() { - AMS_ASSERT(this->interface != nullptr); - return this->interface->RepairInvalidFileAttribute(); + AMS_ASSERT(m_interface != nullptr); + return m_interface->RepairInvalidFileAttribute(); } Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { - AMS_ASSERT(this->interface != nullptr); - return this->interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id); + AMS_ASSERT(m_interface != nullptr); + return m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id); } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index 029ed4a59..4689f6c8e 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -82,18 +82,18 @@ namespace ams::ncm { NON_COPYABLE(InstallTaskBase); NON_MOVEABLE(InstallTaskBase); private: - crypto::Sha256Generator sha256_generator; - StorageId install_storage; - InstallTaskDataBase *data; - InstallProgress progress; - os::SdkMutex progress_mutex; - u32 config; - os::SdkMutex cancel_mutex; - bool cancel_requested; - InstallThroughput throughput; - TimeSpan throughput_start_time; - os::SdkMutex throughput_mutex; - FirmwareVariationId firmware_variation_id; + crypto::Sha256Generator m_sha256_generator; + StorageId m_install_storage; + InstallTaskDataBase *m_data; + InstallProgress m_progress; + os::SdkMutex m_progress_mutex; + u32 m_config; + os::SdkMutex m_cancel_mutex; + bool m_cancel_requested; + InstallThroughput m_throughput; + TimeSpan m_throughput_start_time; + os::SdkMutex m_throughput_mutex; + FirmwareVariationId m_firmware_variation_id; private: ALWAYS_INLINE Result SetLastResultOnFailure(Result result) { if (R_FAILED(result)) { @@ -102,7 +102,7 @@ namespace ams::ncm { return result; } public: - InstallTaskBase() : data(), progress(), progress_mutex(), cancel_mutex(), cancel_requested(), throughput_mutex() { /* ... */ } + InstallTaskBase() : m_data(), m_progress(), m_progress_mutex(), m_cancel_mutex(), m_cancel_requested(), m_throughput_mutex() { /* ... */ } virtual ~InstallTaskBase() { /* ... */ }; public: virtual void Cancel(); @@ -144,10 +144,10 @@ namespace ams::ncm { virtual Result PrepareDependency(); Result PrepareSystemUpdateDependency(); virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */ - u32 GetConfig() const { return this->config; } + u32 GetConfig() const { return m_config; } Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional is_temporary); - StorageId GetInstallStorage() const { return this->install_storage; } + StorageId GetInstallStorage() const { return m_install_storage; } virtual Result OnPrepareComplete() { return ResultSuccess(); } @@ -196,7 +196,7 @@ namespace ams::ncm { public: virtual Result CheckInstallable() { return ResultSuccess(); } - void SetFirmwareVariationId(FirmwareVariationId id) { this->firmware_variation_id = id; } + void SetFirmwareVariationId(FirmwareVariationId id) { m_firmware_variation_id = id; } Result ListRightsIds(s32 *out_count, Span out_span, const ContentMetaKey &key, s32 offset); }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp index 427d720c2..a016257ce 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_data.hpp @@ -59,12 +59,12 @@ namespace ams::ncm { struct DataHolder : public InstallContentMeta, public util::IntrusiveListBaseNode{}; using DataList = util::IntrusiveListBaseTraits::ListType; private: - DataList data_list; - InstallProgressState state; - Result last_result; - SystemUpdateTaskApplyInfo system_update_task_apply_info; + DataList m_data_list; + InstallProgressState m_state; + Result m_last_result; + SystemUpdateTaskApplyInfo m_system_update_task_apply_info; public: - MemoryInstallTaskData() : state(InstallProgressState::NotPrepared), last_result(ResultSuccess()) { /* ... */ }; + MemoryInstallTaskData() : m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()) { /* ... */ }; ~MemoryInstallTaskData() { this->Cleanup(); } @@ -104,8 +104,8 @@ namespace ams::ncm { static_assert(sizeof(EntryInfo) == 0x10); private: - Header header; - char path[64]; + Header m_header; + char m_path[64]; private: static constexpr Header MakeInitialHeader(s32 max_entries) { return { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp index d0bdc2e16..a54eaa100 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_memory_report.hpp @@ -40,13 +40,13 @@ namespace ams::ncm { class HeapState { private: - os::SdkMutex mutex; - lmem::HeapHandle heap_handle; - size_t total_alloc_size; - size_t peak_total_alloc_size; - size_t peak_alloc_size; + os::SdkMutex m_mutex; + lmem::HeapHandle m_heap_handle; + size_t m_total_alloc_size; + size_t m_peak_total_alloc_size; + size_t m_peak_alloc_size; public: - constexpr HeapState() : mutex(), heap_handle(nullptr), total_alloc_size(0), peak_total_alloc_size(0), peak_alloc_size(0) { /* ... */ } + constexpr HeapState() : m_mutex(), m_heap_handle(nullptr), m_total_alloc_size(0), m_peak_total_alloc_size(0), m_peak_alloc_size(0) { /* ... */ } void Initialize(lmem::HeapHandle heap_handle); void Allocate(size_t size); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp index afc0d9048..b69e26908 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task.hpp @@ -20,7 +20,7 @@ namespace ams::ncm { class PackageInstallTask : public PackageInstallTaskBase { private: - MemoryInstallTaskData data; + MemoryInstallTaskData m_data; public: Result Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket); protected: diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp index 7971de35b..9434c924b 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_install_task_base.hpp @@ -23,16 +23,16 @@ namespace ams::ncm { private: using PackagePath = kvdb::BoundedString<256>; private: - PackagePath package_root; - void *buffer; - size_t buffer_size; + PackagePath m_package_root; + void *m_buffer; + size_t m_buffer_size; public: - PackageInstallTaskBase() : package_root() { /* ... */ } + PackageInstallTaskBase() : m_package_root() { /* ... */ } Result Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config); protected: const char *GetPackageRootPath() { - return this->package_root.Get(); + return m_package_root.Get(); } private: virtual Result OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) override; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp index 3d6d90311..c03c4234a 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_package_system_update_task.hpp @@ -22,10 +22,10 @@ namespace ams::ncm { private: using PackagePath = kvdb::BoundedString<0x100>; private: - PackagePath context_path; - FileInstallTaskData data; - ContentMetaDatabase package_db; - bool gamecard_content_meta_database_active; + PackagePath m_context_path; + FileInstallTaskData m_data; + ContentMetaDatabase m_package_db; + bool m_gamecard_content_meta_database_active; public: ~PackageSystemUpdateTask(); @@ -35,7 +35,7 @@ namespace ams::ncm { protected: virtual Result PrepareInstallContentMetaData() override; virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) override; - InstallTaskDataBase &GetInstallData() { return this->data; } /* Atmosphere extension. */ + InstallTaskDataBase &GetInstallData() { return m_data; } /* Atmosphere extension. */ private: virtual Result PrepareDependency() override; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_registered_host_content.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_registered_host_content.hpp index 48034ac70..5270b1eaa 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_registered_host_content.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_registered_host_content.hpp @@ -28,10 +28,10 @@ namespace ams::ncm { private: using RegisteredPathList = ams::util::IntrusiveListBaseTraits::ListType; private: - os::SdkMutex mutex; - RegisteredPathList path_list; + os::SdkMutex m_mutex; + RegisteredPathList m_path_list; public: - RegisteredHostContent() : mutex(), path_list() { /* ... */ } + RegisteredHostContent() : m_mutex(), m_path_list() { /* ... */ } ~RegisteredHostContent(); Result RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp index 381789b1b..7cdac9693 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_rights_id_cache.hpp @@ -33,28 +33,28 @@ namespace ams::ncm { u64 last_accessed; }; private: - Entry entries[MaxEntries]; - u64 counter; - os::SdkMutex mutex; + Entry m_entries[MaxEntries]; + u64 m_counter; + os::SdkMutex m_mutex; public: - RightsIdCache() : mutex() { + RightsIdCache() : m_mutex() { this->Invalidate(); } void Invalidate() { - this->counter = 2; + m_counter = 2; for (size_t i = 0; i < MaxEntries; i++) { - this->entries[i].last_accessed = 1; + m_entries[i].last_accessed = 1; } } void Store(ContentId content_id, ncm::RightsId rights_id) { - std::scoped_lock lk(this->mutex); - Entry *eviction_candidate = std::addressof(this->entries[0]); + std::scoped_lock lk(m_mutex); + Entry *eviction_candidate = std::addressof(m_entries[0]); /* Find a suitable existing entry to store our new one at. */ for (size_t i = 1; i < MaxEntries; i++) { - Entry *entry = std::addressof(this->entries[i]); + Entry *entry = std::addressof(m_entries[i]); /* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */ if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) { @@ -65,19 +65,19 @@ namespace ams::ncm { /* Update the cache. */ eviction_candidate->uuid = content_id.uuid; eviction_candidate->rights_id = rights_id; - eviction_candidate->last_accessed = this->counter++; + eviction_candidate->last_accessed = m_counter++; } bool Find(ncm::RightsId *out_rights_id, ContentId content_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Attempt to locate the content id in the cache. */ for (size_t i = 0; i < MaxEntries; i++) { - Entry *entry = std::addressof(this->entries[i]); + Entry *entry = std::addressof(m_entries[i]); if (entry->last_accessed != 1 && content_id == entry->uuid) { - entry->last_accessed = this->counter; - this->counter++; + entry->last_accessed = m_counter; + m_counter++; *out_rights_id = entry->rights_id; return true; } diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_utils.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_utils.hpp index 605c44818..3264cbf4d 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_storage_utils.hpp @@ -23,30 +23,30 @@ namespace ams::ncm { public: static constexpr s32 MaxCount = 10; private: - StorageId ids[MaxCount]; - s32 count; + StorageId m_ids[MaxCount]; + s32 m_count; public: - constexpr StorageList() : ids(), count() { /* ... */ } + constexpr StorageList() : m_ids(), m_count() { /* ... */ } void Push(StorageId storage_id) { - AMS_ABORT_UNLESS(this->count < MaxCount); + AMS_ABORT_UNLESS(m_count < MaxCount); for (s32 i = 0; i < MaxCount; i++) { - if (this->ids[i] == storage_id) { + if (m_ids[i] == storage_id) { return; } } - this->ids[this->count++] = storage_id; + m_ids[m_count++] = storage_id; } s32 Count() const { - return this->count; + return m_count; } StorageId operator[](s32 i) const { - AMS_ABORT_UNLESS(i < this->count); - return this->ids[i]; + AMS_ABORT_UNLESS(i < m_count); + return m_ids[i]; } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_submission_package_install_task.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_submission_package_install_task.hpp index c1a5762c3..8f94d3a45 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_submission_package_install_task.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_submission_package_install_task.hpp @@ -23,7 +23,7 @@ namespace ams::ncm { private: class Impl; private: - std::unique_ptr impl; + std::unique_ptr m_impl; public: SubmissionPackageInstallTask(); virtual ~SubmissionPackageInstallTask() override; diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp index 674d9f6a9..bfd3f462f 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable.hpp @@ -28,28 +28,28 @@ namespace ams::os::impl { class InternalConditionVariable { private: - InternalConditionVariableImpl impl; + InternalConditionVariableImpl m_impl; public: - constexpr InternalConditionVariable() : impl() { /* ... */ } + constexpr InternalConditionVariable() : m_impl() { /* ... */ } constexpr void Initialize() { - this->impl.Initialize(); + m_impl.Initialize(); } void Signal() { - this->impl.Signal(); + m_impl.Signal(); } void Broadcast() { - this->impl.Broadcast(); + m_impl.Broadcast(); } void Wait(InternalCriticalSection *cs) { - this->impl.Wait(cs); + m_impl.Wait(cs); } ConditionVariableStatus TimedWait(InternalCriticalSection *cs, const TimeoutHelper &timeout_helper) { - return this->impl.TimedWait(cs, timeout_helper); + return m_impl.TimedWait(cs, timeout_helper); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable_impl.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable_impl.os.horizon.hpp index 860fd8ed5..2ea11557d 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable_impl.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_condition_variable_impl.os.horizon.hpp @@ -25,12 +25,12 @@ namespace ams::os::impl { class InternalConditionVariableImpl { private: - u32 value; + u32 m_value; public: - constexpr InternalConditionVariableImpl() : value(0) { /* ... */ } + constexpr InternalConditionVariableImpl() : m_value(0) { /* ... */ } constexpr void Initialize() { - this->value = 0; + m_value = 0; } void Signal(); diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp index 2c0c7fadc..89688a913 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section.hpp @@ -27,18 +27,18 @@ namespace ams::os::impl { class InternalCriticalSection { private: - InternalCriticalSectionImpl impl; + InternalCriticalSectionImpl m_impl; public: - constexpr InternalCriticalSection() : impl() { /* ... */ } + constexpr InternalCriticalSection() : m_impl() { /* ... */ } - constexpr void Initialize() { this->impl.Initialize(); } - constexpr void Finalize() { this->impl.Finalize(); } + constexpr void Initialize() { m_impl.Initialize(); } + constexpr void Finalize() { m_impl.Finalize(); } - void Enter() { return this->impl.Enter(); } - bool TryEnter() { return this->impl.TryEnter(); } - void Leave() { return this->impl.Leave(); } + void Enter() { return m_impl.Enter(); } + bool TryEnter() { return m_impl.TryEnter(); } + void Leave() { return m_impl.Leave(); } - bool IsLockedByCurrentThread() const { return this->impl.IsLockedByCurrentThread(); } + bool IsLockedByCurrentThread() const { return m_impl.IsLockedByCurrentThread(); } ALWAYS_INLINE void Lock() { return this->Enter(); } ALWAYS_INLINE bool TryLock() { return this->TryEnter(); } @@ -49,11 +49,11 @@ namespace ams::os::impl { ALWAYS_INLINE void unlock() { return this->Unlock(); } InternalCriticalSectionImpl *Get() { - return std::addressof(this->impl); + return std::addressof(m_impl); } const InternalCriticalSectionImpl *Get() const { - return std::addressof(this->impl); + return std::addressof(m_impl); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp index 7232c50a4..e9f49d219 100644 --- a/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/impl/os_internal_critical_section_impl.os.horizon.hpp @@ -33,11 +33,11 @@ namespace ams::os::impl { friend class InternalConditionVariableImpl; private: - u32 thread_handle; + u32 m_thread_handle; public: - constexpr InternalCriticalSectionImpl() : thread_handle(svc::InvalidHandle) { /* ... */ } + constexpr InternalCriticalSectionImpl() : m_thread_handle(svc::InvalidHandle) { /* ... */ } - constexpr void Initialize() { this->thread_handle = svc::InvalidHandle; } + constexpr void Initialize() { m_thread_handle = svc::InvalidHandle; } constexpr void Finalize() { /* ... */ } void Enter(); diff --git a/libraries/libstratosphere/include/stratosphere/os/os_condition_variable.hpp b/libraries/libstratosphere/include/stratosphere/os/os_condition_variable.hpp index 24aa6f1e8..038e2abe4 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_condition_variable.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_condition_variable.hpp @@ -27,38 +27,38 @@ namespace ams::os { NON_COPYABLE(ConditionVariable); NON_MOVEABLE(ConditionVariable); private: - ConditionVariableType cv; + ConditionVariableType m_cv; public: - constexpr ConditionVariable() : cv{::ams::os::ConditionVariableType::State_Initialized, {{0}}} { /* ... */ } + constexpr ConditionVariable() : m_cv{::ams::os::ConditionVariableType::State_Initialized, {{0}}} { /* ... */ } - ~ConditionVariable() { FinalizeConditionVariable(std::addressof(this->cv)); } + ~ConditionVariable() { FinalizeConditionVariable(std::addressof(m_cv)); } void Signal() { - SignalConditionVariable(std::addressof(this->cv)); + SignalConditionVariable(std::addressof(m_cv)); } void Broadcast() { - BroadcastConditionVariable(std::addressof(this->cv)); + BroadcastConditionVariable(std::addressof(m_cv)); } void Wait(ams::os::MutexType &mutex) { - WaitConditionVariable(std::addressof(this->cv), std::addressof(mutex)); + WaitConditionVariable(std::addressof(m_cv), std::addressof(mutex)); } ConditionVariableStatus TimedWait(ams::os::MutexType &mutex, TimeSpan timeout) { - return TimedWaitConditionVariable(std::addressof(this->cv), std::addressof(mutex), timeout); + return TimedWaitConditionVariable(std::addressof(m_cv), std::addressof(mutex), timeout); } operator ConditionVariableType &() { - return this->cv; + return m_cv; } operator const ConditionVariableType &() const { - return this->cv; + return m_cv; } ConditionVariableType *GetBase() { - return std::addressof(this->cv); + return std::addressof(m_cv); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_event.hpp b/libraries/libstratosphere/include/stratosphere/os/os_event.hpp index 5ba40cceb..4c4108daf 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_event.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_event.hpp @@ -26,46 +26,46 @@ namespace ams::os { NON_COPYABLE(Event); NON_MOVEABLE(Event); private: - EventType event; + EventType m_event; public: explicit Event(EventClearMode clear_mode) { - InitializeEvent(std::addressof(this->event), false, clear_mode); + InitializeEvent(std::addressof(m_event), false, clear_mode); } ~Event() { - FinalizeEvent(std::addressof(this->event)); + FinalizeEvent(std::addressof(m_event)); } void Wait() { - return WaitEvent(std::addressof(this->event)); + return WaitEvent(std::addressof(m_event)); } bool TryWait() { - return TryWaitEvent(std::addressof(this->event)); + return TryWaitEvent(std::addressof(m_event)); } bool TimedWait(TimeSpan timeout) { - return TimedWaitEvent(std::addressof(this->event), timeout); + return TimedWaitEvent(std::addressof(m_event), timeout); } void Signal() { - return SignalEvent(std::addressof(this->event)); + return SignalEvent(std::addressof(m_event)); } void Clear() { - return ClearEvent(std::addressof(this->event)); + return ClearEvent(std::addressof(m_event)); } operator EventType &() { - return this->event; + return m_event; } operator const EventType &() const { - return this->event; + return m_event; } EventType *GetBase() { - return std::addressof(this->event); + return std::addressof(m_event); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp b/libraries/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp index 319a2414b..1ffa24e9b 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp @@ -27,42 +27,42 @@ namespace ams::os { NON_COPYABLE(InterruptEvent); NON_MOVEABLE(InterruptEvent); private: - InterruptEventType event; + InterruptEventType m_event; public: explicit InterruptEvent(InterruptName name, EventClearMode clear_mode) { - InitializeInterruptEvent(std::addressof(this->event), name, clear_mode); + InitializeInterruptEvent(std::addressof(m_event), name, clear_mode); } ~InterruptEvent() { - FinalizeInterruptEvent(std::addressof(this->event)); + FinalizeInterruptEvent(std::addressof(m_event)); } void Wait() { - return WaitInterruptEvent(std::addressof(this->event)); + return WaitInterruptEvent(std::addressof(m_event)); } bool TryWait() { - return TryWaitInterruptEvent(std::addressof(this->event)); + return TryWaitInterruptEvent(std::addressof(m_event)); } bool TimedWait(TimeSpan timeout) { - return TimedWaitInterruptEvent(std::addressof(this->event), timeout); + return TimedWaitInterruptEvent(std::addressof(m_event), timeout); } void Clear() { - return ClearInterruptEvent(std::addressof(this->event)); + return ClearInterruptEvent(std::addressof(m_event)); } operator InterruptEventType &() { - return this->event; + return m_event; } operator const InterruptEventType &() const { - return this->event; + return m_event; } InterruptEventType *GetBase() { - return std::addressof(this->event); + return std::addressof(m_event); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_message_queue.hpp b/libraries/libstratosphere/include/stratosphere/os/os_message_queue.hpp index 6bd71a870..ff0994a2a 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_message_queue.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_message_queue.hpp @@ -25,76 +25,76 @@ namespace ams::os { NON_COPYABLE(MessageQueue); NON_MOVEABLE(MessageQueue); private: - MessageQueueType mq; + MessageQueueType m_mq; public: explicit MessageQueue(uintptr_t *buf, size_t count) { - InitializeMessageQueue(std::addressof(this->mq), buf, count); + InitializeMessageQueue(std::addressof(m_mq), buf, count); } - ~MessageQueue() { FinalizeMessageQueue(std::addressof(this->mq)); } + ~MessageQueue() { FinalizeMessageQueue(std::addressof(m_mq)); } /* Sending (FIFO functionality) */ void Send(uintptr_t data) { - return SendMessageQueue(std::addressof(this->mq), data); + return SendMessageQueue(std::addressof(m_mq), data); } bool TrySend(uintptr_t data) { - return TrySendMessageQueue(std::addressof(this->mq), data); + return TrySendMessageQueue(std::addressof(m_mq), data); } bool TimedSend(uintptr_t data, TimeSpan timeout) { - return TimedSendMessageQueue(std::addressof(this->mq), data, timeout); + return TimedSendMessageQueue(std::addressof(m_mq), data, timeout); } /* Jamming (LIFO functionality) */ void Jam(uintptr_t data) { - return JamMessageQueue(std::addressof(this->mq), data); + return JamMessageQueue(std::addressof(m_mq), data); } bool TryJam(uintptr_t data) { - return TryJamMessageQueue(std::addressof(this->mq), data); + return TryJamMessageQueue(std::addressof(m_mq), data); } bool TimedJam(uintptr_t data, TimeSpan timeout) { - return TimedJamMessageQueue(std::addressof(this->mq), data, timeout); + return TimedJamMessageQueue(std::addressof(m_mq), data, timeout); } /* Receive functionality */ void Receive(uintptr_t *out) { - return ReceiveMessageQueue(out, std::addressof(this->mq)); + return ReceiveMessageQueue(out, std::addressof(m_mq)); } bool TryReceive(uintptr_t *out) { - return TryReceiveMessageQueue(out, std::addressof(this->mq)); + return TryReceiveMessageQueue(out, std::addressof(m_mq)); } bool TimedReceive(uintptr_t *out, TimeSpan timeout) { - return TimedReceiveMessageQueue(out, std::addressof(this->mq), timeout); + return TimedReceiveMessageQueue(out, std::addressof(m_mq), timeout); } /* Peek functionality */ void Peek(uintptr_t *out) const { - return PeekMessageQueue(out, std::addressof(this->mq)); + return PeekMessageQueue(out, std::addressof(m_mq)); } bool TryPeek(uintptr_t *out) const { - return TryPeekMessageQueue(out, std::addressof(this->mq)); + return TryPeekMessageQueue(out, std::addressof(m_mq)); } bool TimedPeek(uintptr_t *out, TimeSpan timeout) const { - return TimedPeekMessageQueue(out, std::addressof(this->mq), timeout); + return TimedPeekMessageQueue(out, std::addressof(m_mq), timeout); } operator MessageQueueType &() { - return this->mq; + return m_mq; } operator const MessageQueueType &() const { - return this->mq; + return m_mq; } MessageQueueType *GetBase() { - return std::addressof(this->mq); + return std::addressof(m_mq); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_mutex.hpp b/libraries/libstratosphere/include/stratosphere/os/os_mutex.hpp index 744243323..8842b1c56 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_mutex.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_mutex.hpp @@ -25,26 +25,26 @@ namespace ams::os { NON_COPYABLE(Mutex); NON_MOVEABLE(Mutex); private: - MutexType mutex; + MutexType m_mutex; public: - constexpr explicit Mutex(bool recursive) : mutex{::ams::os::MutexType::State_Initialized, recursive, 0, 0, nullptr, {{0}}} { /* ... */ } + constexpr explicit Mutex(bool recursive) : m_mutex{::ams::os::MutexType::State_Initialized, recursive, 0, 0, nullptr, {{0}}} { /* ... */ } - ~Mutex() { FinalizeMutex(std::addressof(this->mutex)); } + ~Mutex() { FinalizeMutex(std::addressof(m_mutex)); } void lock() { - return LockMutex(std::addressof(this->mutex)); + return LockMutex(std::addressof(m_mutex)); } void unlock() { - return UnlockMutex(std::addressof(this->mutex)); + return UnlockMutex(std::addressof(m_mutex)); } bool try_lock() { - return TryLockMutex(std::addressof(this->mutex)); + return TryLockMutex(std::addressof(m_mutex)); } bool IsLockedByCurrentThread() const { - return IsMutexLockedByCurrentThread(std::addressof(this->mutex)); + return IsMutexLockedByCurrentThread(std::addressof(m_mutex)); } ALWAYS_INLINE void Lock() { @@ -60,15 +60,15 @@ namespace ams::os { } operator MutexType &() { - return this->mutex; + return m_mutex; } operator const MutexType &() const { - return this->mutex; + return m_mutex; } MutexType *GetBase() { - return std::addressof(this->mutex); + return std::addressof(m_mutex); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp index e37f432d5..e36af0cb4 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_rw_lock.hpp @@ -25,46 +25,46 @@ namespace ams::os { NON_COPYABLE(ReaderWriterLock); NON_MOVEABLE(ReaderWriterLock); private: - ReaderWriterLockType rw_lock; + ReaderWriterLockType m_rw_lock; public: - constexpr explicit ReaderWriterLock() : rw_lock{{}, 0, ::ams::os::ReaderWriterLockType::State_Initialized, nullptr, 0, {}, {}} { /* ... */ } + constexpr explicit ReaderWriterLock() : m_rw_lock{{}, 0, ::ams::os::ReaderWriterLockType::State_Initialized, nullptr, 0, {}, {}} { /* ... */ } - ~ReaderWriterLock() { os::FinalizeReaderWriterLock(std::addressof(this->rw_lock)); } + ~ReaderWriterLock() { os::FinalizeReaderWriterLock(std::addressof(m_rw_lock)); } void AcquireReadLock() { - return os::AcquireReadLock(std::addressof(this->rw_lock)); + return os::AcquireReadLock(std::addressof(m_rw_lock)); } bool TryAcquireReadLock() { - return os::TryAcquireReadLock(std::addressof(this->rw_lock)); + return os::TryAcquireReadLock(std::addressof(m_rw_lock)); } void ReleaseReadLock() { - return os::ReleaseReadLock(std::addressof(this->rw_lock)); + return os::ReleaseReadLock(std::addressof(m_rw_lock)); } void AcquireWriteLock() { - return os::AcquireWriteLock(std::addressof(this->rw_lock)); + return os::AcquireWriteLock(std::addressof(m_rw_lock)); } bool TryAcquireWriteLock() { - return os::TryAcquireWriteLock(std::addressof(this->rw_lock)); + return os::TryAcquireWriteLock(std::addressof(m_rw_lock)); } void ReleaseWriteLock() { - return os::ReleaseWriteLock(std::addressof(this->rw_lock)); + return os::ReleaseWriteLock(std::addressof(m_rw_lock)); } bool IsReadLockHeld() const { - return os::IsReadLockHeld(std::addressof(this->rw_lock)); + return os::IsReadLockHeld(std::addressof(m_rw_lock)); } bool IsWriteLockHeldByCurrentThread() const { - return os::IsWriteLockHeldByCurrentThread(std::addressof(this->rw_lock)); + return os::IsWriteLockHeldByCurrentThread(std::addressof(m_rw_lock)); } bool IsLockOwner() const { - return os::IsReaderWriterLockOwnerThread(std::addressof(this->rw_lock)); + return os::IsReaderWriterLockOwnerThread(std::addressof(m_rw_lock)); } void lock_shared() { @@ -92,15 +92,15 @@ namespace ams::os { } operator ReaderWriterLockType &() { - return this->rw_lock; + return m_rw_lock; } operator const ReaderWriterLockType &() const { - return this->rw_lock; + return m_rw_lock; } ReaderWriterLockType *GetBase() { - return std::addressof(this->rw_lock); + return std::addressof(m_rw_lock); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_sdk_thread_local_storage.hpp b/libraries/libstratosphere/include/stratosphere/os/os_sdk_thread_local_storage.hpp index e1bf72887..7e9c357e2 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_sdk_thread_local_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_sdk_thread_local_storage.hpp @@ -24,24 +24,24 @@ namespace ams::os { NON_COPYABLE(SdkThreadLocalStorage); NON_MOVEABLE(SdkThreadLocalStorage); private: - TlsSlot tls_slot; + TlsSlot m_tls_slot; public: SdkThreadLocalStorage() { - R_ABORT_UNLESS(os::SdkAllocateTlsSlot(std::addressof(this->tls_slot), nullptr)); + R_ABORT_UNLESS(os::SdkAllocateTlsSlot(std::addressof(m_tls_slot), nullptr)); } explicit SdkThreadLocalStorage(TlsDestructor destructor) { - R_ABORT_UNLESS(os::SdkAllocateTlsSlot(std::addressof(this->tls_slot), destructor)); + R_ABORT_UNLESS(os::SdkAllocateTlsSlot(std::addressof(m_tls_slot), destructor)); } ~SdkThreadLocalStorage() { - os::FreeTlsSlot(this->tls_slot); + os::FreeTlsSlot(m_tls_slot); } - uintptr_t GetValue() const { return os::GetTlsValue(this->tls_slot); } - void SetValue(uintptr_t value) { return os::SetTlsValue(this->tls_slot, value); } + uintptr_t GetValue() const { return os::GetTlsValue(m_tls_slot); } + void SetValue(uintptr_t value) { return os::SetTlsValue(m_tls_slot, value); } - TlsSlot GetTlsSlot() const { return this->tls_slot; } + TlsSlot GetTlsSlot() const { return m_tls_slot; } }; } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_semaphore.hpp b/libraries/libstratosphere/include/stratosphere/os/os_semaphore.hpp index 8dca1b39b..5c7fd03f0 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_semaphore.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_semaphore.hpp @@ -23,48 +23,48 @@ namespace ams::os { NON_COPYABLE(Semaphore); NON_MOVEABLE(Semaphore); private: - SemaphoreType sema; + SemaphoreType m_sema; public: explicit Semaphore(s32 count, s32 max_count) { - InitializeSemaphore(std::addressof(this->sema), count, max_count); + InitializeSemaphore(std::addressof(m_sema), count, max_count); } - ~Semaphore() { FinalizeSemaphore(std::addressof(this->sema)); } + ~Semaphore() { FinalizeSemaphore(std::addressof(m_sema)); } void Acquire() { - return os::AcquireSemaphore(std::addressof(this->sema)); + return os::AcquireSemaphore(std::addressof(m_sema)); } bool TryAcquire() { - return os::TryAcquireSemaphore(std::addressof(this->sema)); + return os::TryAcquireSemaphore(std::addressof(m_sema)); } bool TimedAcquire(TimeSpan timeout) { - return os::TimedAcquireSemaphore(std::addressof(this->sema), timeout); + return os::TimedAcquireSemaphore(std::addressof(m_sema), timeout); } void Release() { - return os::ReleaseSemaphore(std::addressof(this->sema)); + return os::ReleaseSemaphore(std::addressof(m_sema)); } void Release(s32 count) { - return os::ReleaseSemaphore(std::addressof(this->sema), count); + return os::ReleaseSemaphore(std::addressof(m_sema), count); } s32 GetCurrentCount() const { - return os::GetCurrentSemaphoreCount(std::addressof(this->sema)); + return os::GetCurrentSemaphoreCount(std::addressof(m_sema)); } operator SemaphoreType &() { - return this->sema; + return m_sema; } operator const SemaphoreType &() const { - return this->sema; + return m_sema; } SemaphoreType *GetBase() { - return std::addressof(this->sema); + return std::addressof(m_sema); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_system_event.hpp b/libraries/libstratosphere/include/stratosphere/os/os_system_event.hpp index f79e81c81..9a5e3136e 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_system_event.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_system_event.hpp @@ -25,88 +25,88 @@ namespace ams::os { NON_COPYABLE(SystemEvent); NON_MOVEABLE(SystemEvent); private: - SystemEventType system_event; + SystemEventType m_system_event; public: SystemEvent() { - this->system_event.state = SystemEventType::State_NotInitialized; + m_system_event.state = SystemEventType::State_NotInitialized; } explicit SystemEvent(EventClearMode clear_mode, bool inter_process) { - R_ABORT_UNLESS(CreateSystemEvent(std::addressof(this->system_event), clear_mode, inter_process)); + R_ABORT_UNLESS(CreateSystemEvent(std::addressof(m_system_event), clear_mode, inter_process)); } explicit SystemEvent(NativeHandle read_handle, bool manage_read_handle, NativeHandle write_handle, bool manage_write_handle, EventClearMode clear_mode) { - AttachSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode); + AttachSystemEvent(std::addressof(m_system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode); } ~SystemEvent() { - if (this->system_event.state == SystemEventType::State_NotInitialized) { + if (m_system_event.state == SystemEventType::State_NotInitialized) { return; } - DestroySystemEvent(std::addressof(this->system_event)); + DestroySystemEvent(std::addressof(m_system_event)); } void Attach(NativeHandle read_handle, bool manage_read_handle, NativeHandle write_handle, bool manage_write_handle, EventClearMode clear_mode) { - AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized); - return AttachSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode); + AMS_ABORT_UNLESS(m_system_event.state == SystemEventType::State_NotInitialized); + return AttachSystemEvent(std::addressof(m_system_event), read_handle, manage_read_handle, write_handle, manage_write_handle, clear_mode); } void AttachReadableHandle(NativeHandle read_handle, bool manage_read_handle, EventClearMode clear_mode) { - AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized); - return AttachReadableHandleToSystemEvent(std::addressof(this->system_event), read_handle, manage_read_handle, clear_mode); + AMS_ABORT_UNLESS(m_system_event.state == SystemEventType::State_NotInitialized); + return AttachReadableHandleToSystemEvent(std::addressof(m_system_event), read_handle, manage_read_handle, clear_mode); } void AttachWritableHandle(NativeHandle write_handle, bool manage_write_handle, EventClearMode clear_mode) { - AMS_ABORT_UNLESS(this->system_event.state == SystemEventType::State_NotInitialized); - return AttachWritableHandleToSystemEvent(std::addressof(this->system_event), write_handle, manage_write_handle, clear_mode); + AMS_ABORT_UNLESS(m_system_event.state == SystemEventType::State_NotInitialized); + return AttachWritableHandleToSystemEvent(std::addressof(m_system_event), write_handle, manage_write_handle, clear_mode); } NativeHandle DetachReadableHandle() { - return DetachReadableHandleOfSystemEvent(std::addressof(this->system_event)); + return DetachReadableHandleOfSystemEvent(std::addressof(m_system_event)); } NativeHandle DetachWritableHandle() { - return DetachWritableHandleOfSystemEvent(std::addressof(this->system_event)); + return DetachWritableHandleOfSystemEvent(std::addressof(m_system_event)); } void Wait() { - return WaitSystemEvent(std::addressof(this->system_event)); + return WaitSystemEvent(std::addressof(m_system_event)); } bool TryWait() { - return TryWaitSystemEvent(std::addressof(this->system_event)); + return TryWaitSystemEvent(std::addressof(m_system_event)); } bool TimedWait(TimeSpan timeout) { - return TimedWaitSystemEvent(std::addressof(this->system_event), timeout); + return TimedWaitSystemEvent(std::addressof(m_system_event), timeout); } void Signal() { - return SignalSystemEvent(std::addressof(this->system_event)); + return SignalSystemEvent(std::addressof(m_system_event)); } void Clear() { - return ClearSystemEvent(std::addressof(this->system_event)); + return ClearSystemEvent(std::addressof(m_system_event)); } NativeHandle GetReadableHandle() const { - return GetReadableHandleOfSystemEvent(std::addressof(this->system_event)); + return GetReadableHandleOfSystemEvent(std::addressof(m_system_event)); } NativeHandle GetWritableHandle() const { - return GetWritableHandleOfSystemEvent(std::addressof(this->system_event)); + return GetWritableHandleOfSystemEvent(std::addressof(m_system_event)); } operator SystemEventType &() { - return this->system_event; + return m_system_event; } operator const SystemEventType &() const { - return this->system_event; + return m_system_event; } SystemEventType *GetBase() { - return std::addressof(this->system_event); + return std::addressof(m_system_event); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_thread_local_storage.hpp b/libraries/libstratosphere/include/stratosphere/os/os_thread_local_storage.hpp index fda35637a..6cdd4c038 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_thread_local_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_thread_local_storage.hpp @@ -24,24 +24,24 @@ namespace ams::os { NON_COPYABLE(ThreadLocalStorage); NON_MOVEABLE(ThreadLocalStorage); private: - TlsSlot tls_slot; + TlsSlot m_tls_slot; public: ThreadLocalStorage() { - R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(this->tls_slot), nullptr)); + R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(m_tls_slot), nullptr)); } explicit ThreadLocalStorage(TlsDestructor destructor) { - R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(this->tls_slot), destructor)); + R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(m_tls_slot), destructor)); } ~ThreadLocalStorage() { - os::FreeTlsSlot(this->tls_slot); + os::FreeTlsSlot(m_tls_slot); } - uintptr_t GetValue() const { return os::GetTlsValue(this->tls_slot); } - void SetValue(uintptr_t value) { return os::SetTlsValue(this->tls_slot, value); } + uintptr_t GetValue() const { return os::GetTlsValue(m_tls_slot); } + void SetValue(uintptr_t value) { return os::SetTlsValue(m_tls_slot, value); } - TlsSlot GetTlsSlot() const { return this->tls_slot; } + TlsSlot GetTlsSlot() const { return m_tls_slot; } }; } diff --git a/libraries/libstratosphere/include/stratosphere/os/os_tick.hpp b/libraries/libstratosphere/include/stratosphere/os/os_tick.hpp index d86218cfe..be96de5dc 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_tick.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_tick.hpp @@ -29,22 +29,22 @@ namespace ams::os { class Tick { private: - s64 tick; + s64 m_tick; public: - constexpr explicit Tick(s64 t = 0) : tick(t) { /* ... */ } - Tick(TimeSpan ts) : tick(ConvertToTick(ts).GetInt64Value()) { /* ... */ } + constexpr explicit Tick(s64 t = 0) : m_tick(t) { /* ... */ } + Tick(TimeSpan ts) : m_tick(ConvertToTick(ts).GetInt64Value()) { /* ... */ } public: - constexpr s64 GetInt64Value() const { return this->tick; } + constexpr s64 GetInt64Value() const { return m_tick; } TimeSpan ToTimeSpan() const { return ConvertToTimeSpan(*this); } /* Tick arithmetic. */ - constexpr Tick &operator+=(Tick rhs) { this->tick += rhs.tick; return *this; } - constexpr Tick &operator-=(Tick rhs) { this->tick -= rhs.tick; return *this; } + constexpr Tick &operator+=(Tick rhs) { m_tick += rhs.m_tick; return *this; } + constexpr Tick &operator-=(Tick rhs) { m_tick -= rhs.m_tick; return *this; } constexpr Tick operator+(Tick rhs) const { Tick r(*this); return r += rhs; } constexpr Tick operator-(Tick rhs) const { Tick r(*this); return r -= rhs; } constexpr bool operator==(const Tick &rhs) const { - return this->tick == rhs.tick; + return m_tick == rhs.m_tick; } constexpr bool operator!=(const Tick &rhs) const { @@ -52,7 +52,7 @@ namespace ams::os { } constexpr bool operator<(const Tick &rhs) const { - return this->tick < rhs.tick; + return m_tick < rhs.m_tick; } constexpr bool operator>=(const Tick &rhs) const { @@ -60,7 +60,7 @@ namespace ams::os { } constexpr bool operator>(const Tick &rhs) const { - return this->tick > rhs.tick; + return m_tick > rhs.m_tick; } constexpr bool operator<=(const Tick &rhs) const { diff --git a/libraries/libstratosphere/include/stratosphere/os/os_timer_event.hpp b/libraries/libstratosphere/include/stratosphere/os/os_timer_event.hpp index 9e3f73380..8c0d3fa19 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_timer_event.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_timer_event.hpp @@ -25,54 +25,54 @@ namespace ams::os { NON_COPYABLE(TimerEvent); NON_MOVEABLE(TimerEvent); private: - TimerEventType event; + TimerEventType m_event; public: explicit TimerEvent(EventClearMode clear_mode) { - InitializeTimerEvent(std::addressof(this->event), clear_mode); + InitializeTimerEvent(std::addressof(m_event), clear_mode); } ~TimerEvent() { - FinalizeTimerEvent(std::addressof(this->event)); + FinalizeTimerEvent(std::addressof(m_event)); } void StartOneShot(TimeSpan first_time) { - return StartOneShotTimerEvent(std::addressof(this->event), first_time); + return StartOneShotTimerEvent(std::addressof(m_event), first_time); } void StartPeriodic(TimeSpan first_time, TimeSpan interval) { - return StartPeriodicTimerEvent(std::addressof(this->event), first_time, interval); + return StartPeriodicTimerEvent(std::addressof(m_event), first_time, interval); } void Stop() { - return StopTimerEvent(std::addressof(this->event)); + return StopTimerEvent(std::addressof(m_event)); } void Wait() { - return WaitTimerEvent(std::addressof(this->event)); + return WaitTimerEvent(std::addressof(m_event)); } bool TryWait() { - return TryWaitTimerEvent(std::addressof(this->event)); + return TryWaitTimerEvent(std::addressof(m_event)); } void Signal() { - return SignalTimerEvent(std::addressof(this->event)); + return SignalTimerEvent(std::addressof(m_event)); } void Clear() { - return ClearTimerEvent(std::addressof(this->event)); + return ClearTimerEvent(std::addressof(m_event)); } operator TimerEventType &() { - return this->event; + return m_event; } operator const TimerEventType &() const { - return this->event; + return m_event; } TimerEventType *GetBase() { - return std::addressof(this->event); + return std::addressof(m_event); } }; diff --git a/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp b/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp index 062bcdd3f..d177a8145 100644 --- a/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp +++ b/libraries/libstratosphere/include/stratosphere/os/os_transfer_memory.hpp @@ -25,14 +25,14 @@ namespace ams::os { NON_COPYABLE(TransferMemory); NON_MOVEABLE(TransferMemory); private: - TransferMemoryType tmem; + TransferMemoryType m_tmem; public: - constexpr TransferMemory() : tmem{ .state = TransferMemoryType::State_NotInitialized } { + constexpr TransferMemory() : m_tmem{ .state = TransferMemoryType::State_NotInitialized } { /* ... */ } TransferMemory(void *address, size_t size, MemoryPermission perm) { - R_ABORT_UNLESS(CreateTransferMemory(std::addressof(this->tmem), address, size, perm)); + R_ABORT_UNLESS(CreateTransferMemory(std::addressof(m_tmem), address, size, perm)); } TransferMemory(size_t size, NativeHandle handle, bool managed) { @@ -40,38 +40,38 @@ namespace ams::os { } ~TransferMemory() { - if (this->tmem.state == TransferMemoryType::State_NotInitialized) { + if (m_tmem.state == TransferMemoryType::State_NotInitialized) { return; } - DestroyTransferMemory(std::addressof(this->tmem)); + DestroyTransferMemory(std::addressof(m_tmem)); } void Attach(size_t size, NativeHandle handle, bool managed) { - AttachTransferMemory(std::addressof(this->tmem), size, handle, managed); + AttachTransferMemory(std::addressof(m_tmem), size, handle, managed); } NativeHandle Detach() { - return DetachTransferMemory(std::addressof(this->tmem)); + return DetachTransferMemory(std::addressof(m_tmem)); } Result Map(void **out, MemoryPermission owner_perm) { - return MapTransferMemory(out, std::addressof(this->tmem), owner_perm); + return MapTransferMemory(out, std::addressof(m_tmem), owner_perm); } void Unmap() { - UnmapTransferMemory(std::addressof(this->tmem)); + UnmapTransferMemory(std::addressof(m_tmem)); } operator TransferMemoryType &() { - return this->tmem; + return m_tmem; } operator const TransferMemoryType &() const { - return this->tmem; + return m_tmem; } TransferMemoryType *GetBase() { - return std::addressof(this->tmem); + return std::addressof(m_tmem); } }; diff --git a/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp b/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp index 5e1e6636d..636fa3a33 100644 --- a/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp +++ b/libraries/libstratosphere/include/stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp @@ -22,17 +22,17 @@ namespace ams::powctl::driver::impl { class ChargeArbiter { private: - const ChargeParametersRule *rules; - size_t num_rules; - int charge_voltage_limit; - BatteryTemperatureLevel temperature_level; - int avg_v_cell; - int open_circuit_voltage; - bool has_battery_done_current; - int battery_done_current; - PowerState power_state; - const ChargeParametersRule *selected_rule; - bool check_battery_done_current; + const ChargeParametersRule *m_rules; + size_t m_num_rules; + int m_charge_voltage_limit; + BatteryTemperatureLevel m_temperature_level; + int m_avg_v_cell; + int m_open_circuit_voltage; + bool m_has_battery_done_current; + int m_battery_done_current; + PowerState m_power_state; + const ChargeParametersRule *m_selected_rule; + bool m_check_battery_done_current; private: static constexpr bool IsInRange(int value, int min, int max) { if (!(min <= value)) { @@ -48,7 +48,7 @@ namespace ams::powctl::driver::impl { bool IsAcceptablePowerState(const PowerState *acceptable, size_t num_acceptable) const { for (size_t i = 0; i < num_acceptable; ++i) { - if (this->power_state == acceptable[i]) { + if (m_power_state == acceptable[i]) { return true; } } @@ -56,41 +56,41 @@ namespace ams::powctl::driver::impl { } public: ChargeArbiter(const ChargeParametersRule *r, size_t nr, int cvl) - : rules(r), num_rules(nr), charge_voltage_limit(cvl), temperature_level(BatteryTemperatureLevel::Medium), - avg_v_cell(4080), open_circuit_voltage(4001), has_battery_done_current(false), battery_done_current(0), - power_state(PowerState::FullAwake), selected_rule(nullptr), check_battery_done_current(false) + : m_rules(r), m_num_rules(nr), m_charge_voltage_limit(cvl), m_temperature_level(BatteryTemperatureLevel::Medium), + m_avg_v_cell(4080), m_open_circuit_voltage(4001), m_has_battery_done_current(false), m_battery_done_current(0), + m_power_state(PowerState::FullAwake), m_selected_rule(nullptr), m_check_battery_done_current(false) { this->UpdateSelectedRule(); } void SetBatteryTemperatureLevel(BatteryTemperatureLevel btl) { - this->temperature_level = btl; + m_temperature_level = btl; this->UpdateSelectedRule(); } void SetBatteryAverageVCell(int avg) { - this->avg_v_cell = avg; + m_avg_v_cell = avg; this->UpdateSelectedRule(); } void SetBatteryOpenCircuitVoltage(int ocv) { - this->open_circuit_voltage = ocv; + m_open_circuit_voltage = ocv; this->UpdateSelectedRule(); } void SetBatteryDoneCurrent(int current) { - this->battery_done_current = current; - this->has_battery_done_current = true; + m_battery_done_current = current; + m_has_battery_done_current = true; this->UpdateSelectedRule(); } void SetPowerState(PowerState ps) { - this->power_state = ps; + m_power_state = ps; this->UpdateSelectedRule(); } int GetChargeVoltageLimit() const { - return this->charge_voltage_limit; + return m_charge_voltage_limit; } bool IsBatteryDoneCurrentAcceptable(int current) const { @@ -101,28 +101,28 @@ namespace ams::powctl::driver::impl { } const ChargeParametersRule *GetSelectedRule() const { - return this->selected_rule; + return m_selected_rule; } void UpdateSelectedRule() { /* Try to find an entry that fits our current requirements. */ const ChargeParametersRule *best_rule = nullptr; - for (size_t i = 0; i < this->num_rules; ++i) { + for (size_t i = 0; i < m_num_rules; ++i) { /* Get the current rule. */ - const ChargeParametersRule &cur_rule = this->rules[i]; + const ChargeParametersRule &cur_rule = m_rules[i]; /* Check the temperature level. */ - if (this->temperature_level != cur_rule.temperature_level) { + if (m_temperature_level != cur_rule.temperature_level) { continue; } /* Check that average voltage is in range. */ - if (!IsInRange(this->avg_v_cell, cur_rule.min_avg_v_cell, cur_rule.max_avg_v_cell)) { + if (!IsInRange(m_avg_v_cell, cur_rule.min_avg_v_cell, cur_rule.max_avg_v_cell)) { continue; } /* Check that open circuit voltage is in range. */ - if (!IsInRange(this->open_circuit_voltage, cur_rule.min_open_circuit_voltage, cur_rule.max_open_circuit_voltage)) { + if (!IsInRange(m_open_circuit_voltage, cur_rule.min_open_circuit_voltage, cur_rule.max_open_circuit_voltage)) { continue; } @@ -132,18 +132,18 @@ namespace ams::powctl::driver::impl { } /* The limit is probably acceptable. */ - if (this->selected_rule != std::addressof(cur_rule)) { + if (m_selected_rule != std::addressof(cur_rule)) { /* We're selecting a new rule. Check if our need to deal with battery current is acceptable. */ - if (cur_rule.check_battery_current && this->check_battery_done_current) { + if (cur_rule.check_battery_current && m_check_battery_done_current) { continue; } /* Set whether we need to check the battery done current. */ - this->has_battery_done_current = false; - this->check_battery_done_current |= cur_rule.check_battery_current; + m_has_battery_done_current = false; + m_check_battery_done_current |= cur_rule.check_battery_current; } else { /* We're selecting the currently selected rule. Make sure the battery done current is acceptable if we have one. */ - if (this->has_battery_done_current && !IsInRange(this->battery_done_current, cur_rule.min_battery_done_current, cur_rule.max_battery_done_current)) { + if (m_has_battery_done_current && !IsInRange(m_battery_done_current, cur_rule.min_battery_done_current, cur_rule.max_battery_done_current)) { continue; } } @@ -154,7 +154,7 @@ namespace ams::powctl::driver::impl { } /* Update our selected rule. */ - this->selected_rule = best_rule; + m_selected_rule = best_rule; } }; diff --git a/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.horizon.hpp b/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.horizon.hpp index 0778fbd6f..a780c4d5e 100644 --- a/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.horizon.hpp +++ b/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.horizon.hpp @@ -26,11 +26,11 @@ namespace ams::psc { NON_COPYABLE(PmModule); NON_MOVEABLE(PmModule); private: - ams::sf::SharedPointer intf; - os::SystemEvent system_event; - bool initialized; - PmModuleId module_id; - uintptr_t reserved; + ams::sf::SharedPointer m_intf; + os::SystemEvent m_system_event; + bool m_initialized; + PmModuleId m_module_id; + uintptr_t m_reserved; public: PmModule(); ~PmModule(); @@ -38,7 +38,7 @@ namespace ams::psc { Result Initialize(const PmModuleId mid, const PmModuleId *dependencies, u32 dependency_count, os::EventClearMode clear_mode); Result Finalize(); - constexpr PmModuleId GetId() const { return this->module_id; } + constexpr PmModuleId GetId() const { return m_module_id; } Result GetRequest(PmState *out_state, PmFlagSet *out_flags); Result Acknowledge(PmState state, Result res); diff --git a/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_device.hpp b/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_device.hpp index a6b206588..3ae612b49 100644 --- a/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_device.hpp +++ b/libraries/libstratosphere/include/stratosphere/pwm/driver/pwm_i_pwm_device.hpp @@ -25,12 +25,12 @@ namespace ams::pwm::driver { NON_MOVEABLE(IPwmDevice); AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::IPwmDevice, ::ams::ddsf::IDevice); private: - int channel_index; + int m_channel_index; public: - IPwmDevice(int id) : IDevice(false), channel_index(id) { /* ... */ } + IPwmDevice(int id) : IDevice(false), m_channel_index(id) { /* ... */ } virtual ~IPwmDevice() { /* ... */ } - constexpr int GetChannelIndex() const { return this->channel_index; } + constexpr int GetChannelIndex() const { return m_channel_index; } }; } diff --git a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp index 057258c97..060625b8f 100644 --- a/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/ro/ro_types.hpp @@ -48,47 +48,47 @@ namespace ams::ro { public: static constexpr u32 Magic = util::FourCC<'N','R','R','0'>::Code; private: - u32 magic; - u32 key_generation; - u8 reserved_08[0x08]; - NrrCertification certification; - u8 signature[0x100]; - ncm::ProgramId program_id; - u32 size; - u8 nrr_kind; /* 7.0.0+ */ - u8 reserved_33D[3]; - u32 hashes_offset; - u32 num_hashes; - u8 reserved_348[8]; + u32 m_magic; + u32 m_key_generation; + u8 m_reserved_08[0x08]; + NrrCertification m_certification; + u8 m_signature[0x100]; + ncm::ProgramId m_program_id; + u32 m_size; + u8 m_nrr_kind; /* 7.0.0+ */ + u8 m_reserved_33D[3]; + u32 m_hashes_offset; + u32 m_num_hashes; + u8 m_reserved_348[8]; public: bool IsMagicValid() const { - return this->magic == Magic; + return m_magic == Magic; } bool IsProgramIdValid() const { - return (static_cast(this->program_id) & this->certification.program_id_mask) == this->certification.program_id_pattern; + return (static_cast(m_program_id) & m_certification.program_id_mask) == m_certification.program_id_pattern; } NrrKind GetNrrKind() const { - const NrrKind kind = static_cast(this->nrr_kind); + const NrrKind kind = static_cast(m_nrr_kind); AMS_ABORT_UNLESS(kind < NrrKind_Count); return kind; } ncm::ProgramId GetProgramId() const { - return this->program_id; + return m_program_id; } u32 GetSize() const { - return this->size; + return m_size; } u32 GetNumHashes() const { - return this->num_hashes; + return m_num_hashes; } size_t GetHashesOffset() const { - return this->hashes_offset; + return m_hashes_offset; } uintptr_t GetHashes() const { @@ -96,31 +96,31 @@ namespace ams::ro { } u32 GetKeyGeneration() const { - return this->key_generation; + return m_key_generation; } const u8 *GetCertificationSignature() const { - return this->certification.signature; + return m_certification.signature; } const u8 *GetCertificationSignedArea() const { - return reinterpret_cast(std::addressof(this->certification)); + return reinterpret_cast(std::addressof(m_certification)); } const u8 *GetCertificationModulus() const { - return this->certification.modulus; + return m_certification.modulus; } const u8 *GetSignature() const { - return this->signature; + return m_signature; } const u8 *GetSignedArea() const { - return reinterpret_cast(std::addressof(this->program_id)); + return reinterpret_cast(std::addressof(m_program_id)); } size_t GetSignedAreaSize() const { - return this->size - GetSignedAreaOffset(); + return m_size - GetSignedAreaOffset(); } static constexpr size_t GetSignedAreaOffset(); @@ -128,69 +128,69 @@ namespace ams::ro { static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader definition!"); constexpr size_t NrrHeader::GetSignedAreaOffset() { - return OFFSETOF(NrrHeader, program_id); + return OFFSETOF(NrrHeader, m_program_id); } class NroHeader { public: static constexpr u32 Magic = util::FourCC<'N','R','O','0'>::Code; private: - u32 entrypoint_insn; - u32 mod_offset; - u8 reserved_08[0x8]; - u32 magic; - u8 reserved_14[0x4]; - u32 size; - u8 reserved_1C[0x4]; - u32 text_offset; - u32 text_size; - u32 ro_offset; - u32 ro_size; - u32 rw_offset; - u32 rw_size; - u32 bss_size; - u8 reserved_3C[0x4]; - ModuleId module_id; - u8 reserved_60[0x20]; + u32 m_entrypoint_insn; + u32 m_mod_offset; + u8 m_reserved_08[0x8]; + u32 m_magic; + u8 m_reserved_14[0x4]; + u32 m_size; + u8 m_reserved_1C[0x4]; + u32 m_text_offset; + u32 m_text_size; + u32 m_ro_offset; + u32 m_ro_size; + u32 m_rw_offset; + u32 m_rw_size; + u32 m_bss_size; + u8 m_reserved_3C[0x4]; + ModuleId m_module_id; + u8 m_reserved_60[0x20]; public: bool IsMagicValid() const { - return this->magic == Magic; + return m_magic == Magic; } u32 GetSize() const { - return this->size; + return m_size; } u32 GetTextOffset() const { - return this->text_offset; + return m_text_offset; } u32 GetTextSize() const { - return this->text_size; + return m_text_size; } u32 GetRoOffset() const { - return this->ro_offset; + return m_ro_offset; } u32 GetRoSize() const { - return this->ro_size; + return m_ro_size; } u32 GetRwOffset() const { - return this->rw_offset; + return m_rw_offset; } u32 GetRwSize() const { - return this->rw_size; + return m_rw_size; } u32 GetBssSize() const { - return this->bss_size; + return m_bss_size; } const ModuleId *GetModuleId() const { - return std::addressof(this->module_id); + return std::addressof(m_module_id); } }; static_assert(sizeof(NroHeader) == 0x80, "NroHeader definition!"); diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp index eea9a7b47..b1b687af3 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp @@ -46,10 +46,10 @@ namespace ams::sf::cmif { private: using EntryList = typename util::IntrusiveListMemberTraits<&Entry::domain_list_node>::ListType; private: - ServerDomainManager *manager; - EntryList entries; + ServerDomainManager *m_manager; + EntryList m_entries; public: - explicit Domain(ServerDomainManager *m) : manager(m) { /* ... */ } + explicit Domain(ServerDomainManager *m) : m_manager(m) { /* ... */ } ~Domain(); void DisposeImpl(); @@ -84,10 +84,10 @@ namespace ams::sf::cmif { private: using EntryList = typename util::IntrusiveListMemberTraits<&Entry::free_list_node>::ListType; private: - os::SdkMutex lock; - EntryList free_list; - Entry *entries; - size_t num_entries; + os::SdkMutex m_lock; + EntryList m_free_list; + Entry *m_entries; + size_t m_num_entries; public: EntryManager(DomainEntryStorage *entry_storage, size_t entry_count); ~EntryManager(); @@ -97,8 +97,8 @@ namespace ams::sf::cmif { void AllocateSpecificEntries(const DomainObjectId *ids, size_t count); inline DomainObjectId GetId(Entry *e) { - const size_t index = e - this->entries; - AMS_ABORT_UNLESS(index < this->num_entries); + const size_t index = e - m_entries; + AMS_ABORT_UNLESS(index < m_num_entries); return DomainObjectId{ u32(index + 1) }; } @@ -107,20 +107,20 @@ namespace ams::sf::cmif { return nullptr; } const size_t index = id.value - 1; - if (!(index < this->num_entries)) { + if (!(index < m_num_entries)) { return nullptr; } - return this->entries + index; + return m_entries + index; } }; private: - os::SdkMutex entry_owner_lock; - EntryManager entry_manager; + os::SdkMutex m_entry_owner_lock; + EntryManager m_entry_manager; private: virtual void *AllocateDomain() = 0; virtual void FreeDomain(void *) = 0; protected: - ServerDomainManager(DomainEntryStorage *entry_storage, size_t entry_count) : entry_owner_lock(), entry_manager(entry_storage, entry_count) { /* ... */ } + ServerDomainManager(DomainEntryStorage *entry_storage, size_t entry_count) : m_entry_owner_lock(), m_entry_manager(entry_storage, entry_count) { /* ... */ } inline DomainServiceObject *AllocateDomainServiceObject() { void *storage = this->AllocateDomain(); diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp index 120d84997..d2396502f 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp @@ -33,50 +33,50 @@ namespace ams::sf::cmif { class DomainServiceObjectProcessor : public ServerMessageProcessor { private: - ServerMessageProcessor *impl_processor; - ServerDomainBase *domain; - DomainObjectId *in_object_ids; - DomainObjectId *out_object_ids; - size_t num_in_objects; - ServerMessageRuntimeMetadata impl_metadata; + ServerMessageProcessor *m_impl_processor; + ServerDomainBase *m_domain; + DomainObjectId *m_in_object_ids; + DomainObjectId *m_out_object_ids; + size_t m_num_in_objects; + ServerMessageRuntimeMetadata m_impl_metadata; public: - DomainServiceObjectProcessor(ServerDomainBase *d, DomainObjectId *in_obj_ids, size_t num_in_objs) : domain(d), in_object_ids(in_obj_ids), num_in_objects(num_in_objs) { - AMS_ABORT_UNLESS(this->domain != nullptr); - AMS_ABORT_UNLESS(this->in_object_ids != nullptr); - this->impl_processor = nullptr; - this->out_object_ids = nullptr; - this->impl_metadata = {}; + DomainServiceObjectProcessor(ServerDomainBase *d, DomainObjectId *in_obj_ids, size_t num_in_objs) : m_domain(d), m_in_object_ids(in_obj_ids), m_num_in_objects(num_in_objs) { + AMS_ABORT_UNLESS(m_domain != nullptr); + AMS_ABORT_UNLESS(m_in_object_ids != nullptr); + m_impl_processor = nullptr; + m_out_object_ids = nullptr; + m_impl_metadata = {}; } constexpr size_t GetInObjectCount() const { - return this->num_in_objects; + return m_num_in_objects; } constexpr size_t GetOutObjectCount() const { - return this->impl_metadata.GetOutObjectCount(); + return m_impl_metadata.GetOutObjectCount(); } constexpr size_t GetImplOutHeadersSize() const { - return this->impl_metadata.GetOutHeadersSize(); + return m_impl_metadata.GetOutHeadersSize(); } constexpr size_t GetImplOutDataTotalSize() const { - return this->impl_metadata.GetOutDataSize() + this->impl_metadata.GetOutHeadersSize(); + return m_impl_metadata.GetOutDataSize() + m_impl_metadata.GetOutHeadersSize(); } public: /* Used to enabled templated message processors. */ virtual void SetImplementationProcessor(ServerMessageProcessor *impl) override final { - if (this->impl_processor == nullptr) { - this->impl_processor = impl; + if (m_impl_processor == nullptr) { + m_impl_processor = impl; } else { - this->impl_processor->SetImplementationProcessor(impl); + m_impl_processor->SetImplementationProcessor(impl); } - this->impl_metadata = this->impl_processor->GetRuntimeMetadata(); + m_impl_metadata = m_impl_processor->GetRuntimeMetadata(); } virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const override final { - const auto runtime_metadata = this->impl_processor->GetRuntimeMetadata(); + const auto runtime_metadata = m_impl_processor->GetRuntimeMetadata(); return ServerMessageRuntimeMetadata { .in_data_size = static_cast(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)), diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_inline_context.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_inline_context.hpp index cf268d859..c88380266 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_inline_context.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_inline_context.hpp @@ -26,10 +26,10 @@ namespace ams::sf::cmif { class ScopedInlineContextChanger { private: - InlineContext prev_ctx; + InlineContext m_prev_ctx; public: - ALWAYS_INLINE explicit ScopedInlineContextChanger(InlineContext new_ctx) : prev_ctx(SetInlineContext(new_ctx)) { /* ... */ } - ~ScopedInlineContextChanger() { SetInlineContext(this->prev_ctx); } + ALWAYS_INLINE explicit ScopedInlineContextChanger(InlineContext new_ctx) : m_prev_ctx(SetInlineContext(new_ctx)) { /* ... */ } + ~ScopedInlineContextChanger() { SetInlineContext(m_prev_ctx); } }; } diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp index 1d3fec53d..9037a3bde 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp @@ -21,23 +21,23 @@ namespace ams::sf::cmif { class PointerAndSize { private: - uintptr_t pointer; - size_t size; + uintptr_t m_pointer; + size_t m_size; public: - constexpr PointerAndSize() : pointer(0), size(0) { /* ... */ } - constexpr PointerAndSize(uintptr_t ptr, size_t sz) : pointer(ptr), size(sz) { /* ... */ } + constexpr PointerAndSize() : m_pointer(0), m_size(0) { /* ... */ } + constexpr PointerAndSize(uintptr_t ptr, size_t sz) : m_pointer(ptr), m_size(sz) { /* ... */ } constexpr PointerAndSize(void *ptr, size_t sz) : PointerAndSize(reinterpret_cast(ptr), sz) { /* ... */ } constexpr void *GetPointer() const { - return reinterpret_cast(this->pointer); + return reinterpret_cast(m_pointer); } constexpr uintptr_t GetAddress() const { - return this->pointer; + return m_pointer; } constexpr size_t GetSize() const { - return this->size; + return m_size; } }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp index e984d7347..ca90235e6 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp @@ -35,27 +35,27 @@ namespace ams::sf::cmif { u8 out_object_count; constexpr size_t GetInDataSize() const { - return size_t(this->in_data_size); + return static_cast(this->in_data_size); } constexpr size_t GetOutDataSize() const { - return size_t(this->out_data_size); + return static_cast(this->out_data_size); } constexpr size_t GetInHeadersSize() const { - return size_t(this->in_headers_size); + return static_cast(this->in_headers_size); } constexpr size_t GetOutHeadersSize() const { - return size_t(this->out_headers_size); + return static_cast(this->out_headers_size); } constexpr size_t GetInObjectCount() const { - return size_t(this->in_object_count); + return static_cast(this->in_object_count); } constexpr size_t GetOutObjectCount() const { - return size_t(this->out_object_count); + return static_cast(this->out_object_count); } constexpr size_t GetUnfixedOutPointerSizeOffset() const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp index cf0408ab8..dd9e9e25e 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp @@ -92,20 +92,20 @@ namespace ams::sf::cmif { public: static constexpr size_t NumEntries = N; private: - const std::array entries; + const std::array m_entries; public: - explicit constexpr ServiceDispatchTableImpl(const std::array &e) : entries{e} { /* ... */ } + explicit constexpr ServiceDispatchTableImpl(const std::array &e) : m_entries{e} { /* ... */ } Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageImpl(ctx, in_raw_data, this->entries.data(), this->entries.size()); + return this->ProcessMessageImpl(ctx, in_raw_data, m_entries.data(), m_entries.size()); } Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageForMitmImpl(ctx, in_raw_data, this->entries.data(), this->entries.size()); + return this->ProcessMessageForMitmImpl(ctx, in_raw_data, m_entries.data(), m_entries.size()); } constexpr const std::array &GetEntries() const { - return this->entries; + return m_entries; } }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp index ffd685ac6..078ddef27 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp @@ -22,29 +22,29 @@ namespace ams::sf::cmif { class ServiceObjectHolder { private: - SharedPointer srv; - const ServiceDispatchMeta *dispatch_meta; + SharedPointer m_srv; + const ServiceDispatchMeta *m_dispatch_meta; private: /* Copy constructor. */ - ServiceObjectHolder(const ServiceObjectHolder &o) : srv(o.srv), dispatch_meta(o.dispatch_meta) { /* ... */ } + ServiceObjectHolder(const ServiceObjectHolder &o) : m_srv(o.m_srv), m_dispatch_meta(o.m_dispatch_meta) { /* ... */ } ServiceObjectHolder &operator=(const ServiceObjectHolder &o) = delete; public: /* Default constructor, null all members. */ - ServiceObjectHolder() : srv(nullptr, false), dispatch_meta(nullptr) { /* ... */ } + ServiceObjectHolder() : m_srv(nullptr, false), m_dispatch_meta(nullptr) { /* ... */ } ~ServiceObjectHolder() { - this->dispatch_meta = nullptr; + m_dispatch_meta = nullptr; } /* Ensure correct type id at runtime through template constructor. */ template - constexpr explicit ServiceObjectHolder(SharedPointer &&s) : srv(std::move(s)), dispatch_meta(GetServiceDispatchMeta()) { + constexpr explicit ServiceObjectHolder(SharedPointer &&s) : m_srv(std::move(s)), m_dispatch_meta(GetServiceDispatchMeta()) { /* ... */ } /* Move constructor, assignment operator. */ - ServiceObjectHolder(ServiceObjectHolder &&o) : srv(std::move(o.srv)), dispatch_meta(std::move(o.dispatch_meta)) { - o.dispatch_meta = nullptr; + ServiceObjectHolder(ServiceObjectHolder &&o) : m_srv(std::move(o.m_srv)), m_dispatch_meta(std::move(o.m_dispatch_meta)) { + o.m_dispatch_meta = nullptr; } ServiceObjectHolder &operator=(ServiceObjectHolder &&o) { @@ -55,13 +55,13 @@ namespace ams::sf::cmif { /* State management. */ void swap(ServiceObjectHolder &o) { - this->srv.swap(o.srv); - std::swap(this->dispatch_meta, o.dispatch_meta); + m_srv.swap(o.m_srv); + std::swap(m_dispatch_meta, o.m_dispatch_meta); } void Reset() { - this->srv = nullptr; - this->dispatch_meta = nullptr; + m_srv = nullptr; + m_dispatch_meta = nullptr; } ServiceObjectHolder Clone() const { @@ -70,17 +70,17 @@ namespace ams::sf::cmif { /* Boolean operators. */ explicit constexpr operator bool() const { - return this->srv != nullptr; + return m_srv != nullptr; } constexpr bool operator!() const { - return this->srv == nullptr; + return m_srv == nullptr; } /* Getters. */ constexpr uintptr_t GetServiceId() const { - if (this->dispatch_meta) { - return this->dispatch_meta->GetServiceId(); + if (m_dispatch_meta) { + return m_dispatch_meta->GetServiceId(); } return 0; } @@ -93,13 +93,13 @@ namespace ams::sf::cmif { template inline Interface *GetServiceObject() const { if (this->GetServiceId() == GetServiceDispatchMeta()->GetServiceId()) { - return static_cast(this->srv.Get()); + return static_cast(m_srv.Get()); } return nullptr; } inline sf::IServiceObject *GetServiceObjectUnsafe() const { - return static_cast(this->srv.Get()); + return static_cast(m_srv.Get()); } /* Processing. */ diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp index 8f15dc04c..9d29fed2c 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp @@ -54,36 +54,36 @@ namespace ams::sf::hipc { NON_COPYABLE(Server); NON_MOVEABLE(Server); private: - cmif::ServiceObjectHolder static_object; - os::NativeHandle port_handle; - sm::ServiceName service_name; - int index; - bool service_managed; - bool is_mitm_server; + cmif::ServiceObjectHolder m_static_object; + os::NativeHandle m_port_handle; + sm::ServiceName m_service_name; + int m_index; + bool m_service_managed; + bool m_is_mitm_server; public: void AcknowledgeMitmSession(std::shared_ptr<::Service> *out_fsrv, sm::MitmProcessInfo *out_client_info) { /* Check mitm server. */ - AMS_ABORT_UNLESS(this->is_mitm_server); + AMS_ABORT_UNLESS(m_is_mitm_server); /* Create forward service. */ *out_fsrv = ServerSession::CreateForwardService(); /* Get client info. */ - R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, this->service_name)); + R_ABORT_UNLESS(sm::mitm::AcknowledgeSession(out_fsrv->get(), out_client_info, m_service_name)); } }; private: /* Multiple wait management. */ - os::MultiWaitType multi_wait; - os::Event request_stop_event; - os::MultiWaitHolderType request_stop_event_holder; - os::Event notify_event; - os::MultiWaitHolderType notify_event_holder; + os::MultiWaitType m_multi_wait; + os::Event m_request_stop_event; + os::MultiWaitHolderType m_request_stop_event_holder; + os::Event m_notify_event; + os::MultiWaitHolderType m_notify_event_holder; - os::SdkMutex selection_mutex; + os::SdkMutex m_selection_mutex; - os::SdkMutex deferred_list_mutex; - os::MultiWaitType deferred_list; + os::SdkMutex m_deferred_list_mutex; + os::MultiWaitType m_deferred_list; private: virtual void RegisterServerSessionToWait(ServerSession *session) override final; void LinkToDeferredList(os::MultiWaitHolderType *holder); @@ -96,10 +96,10 @@ namespace ams::sf::hipc { Result ProcessForSession(os::MultiWaitHolderType *holder); void RegisterServerImpl(Server *server, os::NativeHandle port_handle, bool is_mitm_server) { - server->port_handle = port_handle; + server->m_port_handle = port_handle; hipc::AttachMultiWaitHolderForAccept(server, port_handle); - server->is_mitm_server = is_mitm_server; + server->m_is_mitm_server = is_mitm_server; if (is_mitm_server) { /* Mitm server. */ os::SetMultiWaitHolderUserData(server, static_cast(UserDataTag::MitmServer)); @@ -108,19 +108,19 @@ namespace ams::sf::hipc { os::SetMultiWaitHolderUserData(server, static_cast(UserDataTag::Server)); } - os::LinkMultiWaitHolder(std::addressof(this->multi_wait), server); + os::LinkMultiWaitHolder(std::addressof(m_multi_wait), server); } void RegisterServerImpl(int index, cmif::ServiceObjectHolder &&static_holder, os::NativeHandle port_handle, bool is_mitm_server) { /* Allocate server memory. */ auto *server = this->AllocateServer(); AMS_ABORT_UNLESS(server != nullptr); - server->service_managed = false; + server->m_service_managed = false; if (static_holder) { - server->static_object = std::move(static_holder); + server->m_static_object = std::move(static_holder); } else { - server->index = index; + server->m_index = index; } this->RegisterServerImpl(server, port_handle, is_mitm_server); @@ -134,13 +134,13 @@ namespace ams::sf::hipc { /* Allocate server memory. */ auto *server = this->AllocateServer(); AMS_ABORT_UNLESS(server != nullptr); - server->service_managed = true; - server->service_name = service_name; + server->m_service_managed = true; + server->m_service_name = service_name; if (static_holder) { - server->static_object = std::move(static_holder); + server->m_static_object = std::move(static_holder); } else { - server->index = index; + server->m_index = index; } this->RegisterServerImpl(server, port_handle, false); @@ -157,13 +157,13 @@ namespace ams::sf::hipc { /* Allocate server memory. */ auto *server = this->AllocateServer(); AMS_ABORT_UNLESS(server != nullptr); - server->service_managed = true; - server->service_name = service_name; + server->m_service_managed = true; + server->m_service_name = service_name; if (static_holder) { - server->static_object = std::move(static_holder); + server->m_static_object = std::move(static_holder); } else { - server->index = index; + server->m_index = index; } this->RegisterServerImpl(server, port_handle, true); @@ -182,27 +182,27 @@ namespace ams::sf::hipc { template Result AcceptImpl(Server *server, SharedPointer p) { - return ServerSessionManager::AcceptSession(server->port_handle, std::move(p)); + return ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p)); } template Result AcceptMitmImpl(Server *server, SharedPointer p, std::shared_ptr<::Service> forward_service) { - return ServerSessionManager::AcceptMitmSession(server->port_handle, std::move(p), std::move(forward_service)); + return ServerSessionManager::AcceptMitmSession(server->m_port_handle, std::move(p), std::move(forward_service)); } public: ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) : ServerDomainSessionManager(entry_storage, entry_count), - request_stop_event(os::EventClearMode_ManualClear), notify_event(os::EventClearMode_ManualClear), - selection_mutex(), deferred_list_mutex() + m_request_stop_event(os::EventClearMode_ManualClear), m_notify_event(os::EventClearMode_ManualClear), + m_selection_mutex(), m_deferred_list_mutex() { /* Link multi-wait holders. */ - os::InitializeMultiWait(std::addressof(this->multi_wait)); - os::InitializeMultiWaitHolder(std::addressof(this->request_stop_event_holder), this->request_stop_event.GetBase()); - os::LinkMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->request_stop_event_holder)); - os::InitializeMultiWaitHolder(std::addressof(this->notify_event_holder), this->notify_event.GetBase()); - os::LinkMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->notify_event_holder)); + os::InitializeMultiWait(std::addressof(m_multi_wait)); + os::InitializeMultiWaitHolder(std::addressof(m_request_stop_event_holder), m_request_stop_event.GetBase()); + os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_request_stop_event_holder)); + os::InitializeMultiWaitHolder(std::addressof(m_notify_event_holder), m_notify_event.GetBase()); + os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_notify_event_holder)); - os::InitializeMultiWait(std::addressof(this->deferred_list)); + os::InitializeMultiWait(std::addressof(m_deferred_list)); } template @@ -261,29 +261,29 @@ namespace ams::sf::hipc { using ServerManagerBase::DomainStorage; private: /* Resource storage. */ - os::SdkMutex resource_mutex; - util::TypedStorage server_storages[MaxServers]; - bool server_allocated[MaxServers]; - util::TypedStorage session_storages[MaxSessions]; - bool session_allocated[MaxSessions]; - u8 pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)]; - u8 saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)]; - uintptr_t pointer_buffers_start; - uintptr_t saved_messages_start; + os::SdkMutex m_resource_mutex; + util::TypedStorage m_server_storages[MaxServers]; + bool m_server_allocated[MaxServers]; + util::TypedStorage m_session_storages[MaxSessions]; + bool m_session_allocated[MaxSessions]; + u8 m_pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)]; + u8 m_saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)]; + uintptr_t m_pointer_buffers_start; + uintptr_t m_saved_messages_start; /* Domain resources. */ - DomainStorage domain_storages[ManagerOptions::MaxDomains]; - bool domain_allocated[ManagerOptions::MaxDomains]; - DomainEntryStorage domain_entry_storages[ManagerOptions::MaxDomainObjects]; + DomainStorage m_domain_storages[ManagerOptions::MaxDomains]; + bool m_domain_allocated[ManagerOptions::MaxDomains]; + DomainEntryStorage m_domain_entry_storages[ManagerOptions::MaxDomainObjects]; private: constexpr inline size_t GetServerIndex(const Server *server) const { - const size_t i = server - GetPointer(this->server_storages[0]); + const size_t i = server - GetPointer(m_server_storages[0]); AMS_ABORT_UNLESS(i < MaxServers); return i; } constexpr inline size_t GetSessionIndex(const ServerSession *session) const { - const size_t i = session - GetPointer(this->session_storages[0]); + const size_t i = session - GetPointer(m_session_storages[0]); AMS_ABORT_UNLESS(i < MaxSessions); return i; } @@ -294,12 +294,12 @@ namespace ams::sf::hipc { protected: virtual ServerSession *AllocateSession() override final { if constexpr (MaxSessions > 0) { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); for (size_t i = 0; i < MaxSessions; i++) { - if (!this->session_allocated[i]) { - this->session_allocated[i] = true; - return GetPointer(this->session_storages[i]); + if (!m_session_allocated[i]) { + m_session_allocated[i] = true; + return GetPointer(m_session_storages[i]); } } } @@ -308,20 +308,20 @@ namespace ams::sf::hipc { } virtual void FreeSession(ServerSession *session) override final { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); const size_t index = this->GetSessionIndex(session); - AMS_ABORT_UNLESS(this->session_allocated[index]); - this->session_allocated[index] = false; + AMS_ABORT_UNLESS(m_session_allocated[index]); + m_session_allocated[index] = false; } virtual Server *AllocateServer() override final { if constexpr (MaxServers > 0) { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); for (size_t i = 0; i < MaxServers; i++) { - if (!this->server_allocated[i]) { - this->server_allocated[i] = true; - return GetPointer(this->server_storages[i]); + if (!m_server_allocated[i]) { + m_server_allocated[i] = true; + return GetPointer(m_server_storages[i]); } } } @@ -330,79 +330,79 @@ namespace ams::sf::hipc { } virtual void DestroyServer(Server *server) override final { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); const size_t index = this->GetServerIndex(server); - AMS_ABORT_UNLESS(this->server_allocated[index]); + AMS_ABORT_UNLESS(m_server_allocated[index]); { os::UnlinkMultiWaitHolder(server); os::FinalizeMultiWaitHolder(server); - if (server->service_managed) { - if (server->is_mitm_server) { - R_ABORT_UNLESS(sm::mitm::UninstallMitm(server->service_name)); + if (server->m_service_managed) { + if (server->m_is_mitm_server) { + R_ABORT_UNLESS(sm::mitm::UninstallMitm(server->m_service_name)); } else { - R_ABORT_UNLESS(sm::UnregisterService(server->service_name)); + R_ABORT_UNLESS(sm::UnregisterService(server->m_service_name)); } - R_ABORT_UNLESS(svc::CloseHandle(server->port_handle)); + R_ABORT_UNLESS(svc::CloseHandle(server->m_port_handle)); } } - this->server_allocated[index] = false; + m_server_allocated[index] = false; } virtual void *AllocateDomain() override final { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); for (size_t i = 0; i < ManagerOptions::MaxDomains; i++) { - if (!this->domain_allocated[i]) { - this->domain_allocated[i] = true; - return GetPointer(this->domain_storages[i]); + if (!m_domain_allocated[i]) { + m_domain_allocated[i] = true; + return GetPointer(m_domain_storages[i]); } } return nullptr; } virtual void FreeDomain(void *domain) override final { - std::scoped_lock lk(this->resource_mutex); + std::scoped_lock lk(m_resource_mutex); DomainStorage *ptr = static_cast(domain); - const size_t index = ptr - this->domain_storages; + const size_t index = ptr - m_domain_storages; AMS_ABORT_UNLESS(index < ManagerOptions::MaxDomains); - AMS_ABORT_UNLESS(this->domain_allocated[index]); - this->domain_allocated[index] = false; + AMS_ABORT_UNLESS(m_domain_allocated[index]); + m_domain_allocated[index] = false; } virtual cmif::PointerAndSize GetSessionPointerBuffer(const ServerSession *session) const override final { if constexpr (ManagerOptions::PointerBufferSize > 0) { - return this->GetObjectBySessionIndex(session, this->pointer_buffers_start, ManagerOptions::PointerBufferSize); + return this->GetObjectBySessionIndex(session, m_pointer_buffers_start, ManagerOptions::PointerBufferSize); } else { return cmif::PointerAndSize(); } } virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const override final { - return this->GetObjectBySessionIndex(session, this->saved_messages_start, hipc::TlsMessageBufferSize); + return this->GetObjectBySessionIndex(session, m_saved_messages_start, hipc::TlsMessageBufferSize); } public: - ServerManager() : ServerManagerBase(this->domain_entry_storages, ManagerOptions::MaxDomainObjects), resource_mutex() { + ServerManager() : ServerManagerBase(m_domain_entry_storages, ManagerOptions::MaxDomainObjects), m_resource_mutex() { /* Clear storages. */ #define SF_SM_MEMCLEAR(obj) if constexpr (sizeof(obj) > 0) { std::memset(obj, 0, sizeof(obj)); } - SF_SM_MEMCLEAR(this->server_storages); - SF_SM_MEMCLEAR(this->server_allocated); - SF_SM_MEMCLEAR(this->session_storages); - SF_SM_MEMCLEAR(this->session_allocated); - SF_SM_MEMCLEAR(this->pointer_buffer_storage); - SF_SM_MEMCLEAR(this->saved_message_storage); - SF_SM_MEMCLEAR(this->domain_allocated); + SF_SM_MEMCLEAR(m_server_storages); + SF_SM_MEMCLEAR(m_server_allocated); + SF_SM_MEMCLEAR(m_session_storages); + SF_SM_MEMCLEAR(m_session_allocated); + SF_SM_MEMCLEAR(m_pointer_buffer_storage); + SF_SM_MEMCLEAR(m_saved_message_storage); + SF_SM_MEMCLEAR(m_domain_allocated); #undef SF_SM_MEMCLEAR /* Set resource starts. */ - this->pointer_buffers_start = util::AlignUp(reinterpret_cast(this->pointer_buffer_storage), 0x10); - this->saved_messages_start = util::AlignUp(reinterpret_cast(this->saved_message_storage), 0x10); + m_pointer_buffers_start = util::AlignUp(reinterpret_cast(m_pointer_buffer_storage), 0x10); + m_saved_messages_start = util::AlignUp(reinterpret_cast(m_saved_message_storage), 0x10); } ~ServerManager() { /* Close all sessions. */ if constexpr (MaxSessions > 0) { for (size_t i = 0; i < MaxSessions; i++) { - if (this->session_allocated[i]) { - this->CloseSessionImpl(GetPointer(this->session_storages[i])); + if (m_session_allocated[i]) { + this->CloseSessionImpl(GetPointer(m_session_storages[i])); } } } @@ -410,8 +410,8 @@ namespace ams::sf::hipc { /* Close all servers. */ if constexpr (MaxServers > 0) { for (size_t i = 0; i < MaxServers; i++) { - if (this->server_allocated[i]) { - this->DestroyServer(GetPointer(this->server_storages[i])); + if (m_server_allocated[i]) { + this->DestroyServer(GetPointer(m_server_storages[i])); } } } diff --git a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp index ada9a68da..cecaeb822 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp @@ -45,32 +45,32 @@ namespace ams::sf::hipc { NON_COPYABLE(ServerSession); NON_MOVEABLE(ServerSession); private: - cmif::ServiceObjectHolder srv_obj_holder; - cmif::PointerAndSize pointer_buffer; - cmif::PointerAndSize saved_message; - std::shared_ptr<::Service> forward_service; - os::NativeHandle session_handle; - bool is_closed; - bool has_received; + cmif::ServiceObjectHolder m_srv_obj_holder; + cmif::PointerAndSize m_pointer_buffer; + cmif::PointerAndSize m_saved_message; + std::shared_ptr<::Service> m_forward_service; + os::NativeHandle m_session_handle; + bool m_is_closed; + bool m_has_received; public: - ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj) : srv_obj_holder(std::move(obj)), session_handle(h) { + ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj) : m_srv_obj_holder(std::move(obj)), m_session_handle(h) { hipc::AttachMultiWaitHolderForReply(this, h); - this->is_closed = false; - this->has_received = false; - this->forward_service = nullptr; + m_is_closed = false; + m_has_received = false; + m_forward_service = nullptr; AMS_ABORT_UNLESS(!this->IsMitmSession()); } - ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : srv_obj_holder(std::move(obj)), session_handle(h) { + ServerSession(os::NativeHandle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : m_srv_obj_holder(std::move(obj)), m_session_handle(h) { hipc::AttachMultiWaitHolderForReply(this, h); - this->is_closed = false; - this->has_received = false; - this->forward_service = std::move(fsrv); + m_is_closed = false; + m_has_received = false; + m_forward_service = std::move(fsrv); AMS_ABORT_UNLESS(this->IsMitmSession()); } bool IsMitmSession() const { - return this->forward_service != nullptr; + return m_forward_service != nullptr; } Result ForwardRequest(const cmif::ServiceDispatchContext &ctx) const; diff --git a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp index eeeb21a90..942f6a038 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp @@ -476,7 +476,7 @@ namespace ams::sf::impl { if constexpr (std::tuple_size::value) { return alignof(typename std::tuple_element<0, OutDatas>::type); } - return size_t(); + return static_cast(0); }(); /* Handle marshalling. */ @@ -608,21 +608,21 @@ namespace ams::sf::impl { static constexpr size_t Size = _Size; static constexpr size_t Align = _Align ? _Align : alignof(u8); private: - alignas(Align) u8 data[Size]; + alignas(Align) u8 m_data[Size]; public: - constexpr OutRawHolder() : data() { /* ... */ } + constexpr OutRawHolder() : m_data() { /* ... */ } template constexpr inline uintptr_t GetAddress() const { static_assert(Offset <= Size, "Offset <= Size"); static_assert(TypeSize <= Size, "TypeSize <= Size"); static_assert(Offset + TypeSize <= Size, "Offset + TypeSize <= Size"); - return reinterpret_cast(std::addressof(data[Offset])); + return reinterpret_cast(std::addressof(m_data[Offset])); } constexpr inline void CopyTo(void *dst) const { if constexpr (Size > 0) { - std::memcpy(dst, data, Size); + std::memcpy(dst, m_data, Size); } } }; @@ -633,23 +633,23 @@ namespace ams::sf::impl { static constexpr size_t NumMove = _NumMove; static constexpr size_t NumCopy = _NumCopy; private: - MoveHandle move_handles[NumMove]; - CopyHandle copy_handles[NumCopy]; + MoveHandle m_move_handles[NumMove]; + CopyHandle m_copy_handles[NumCopy]; public: - constexpr InHandleHolder() : move_handles(), copy_handles() { /* ... */ } + constexpr InHandleHolder() : m_move_handles(), m_copy_handles() { /* ... */ } template constexpr inline MoveHandle &SetMoveHandle(os::NativeHandle os_handle) { static_assert(Index < NumMove); - move_handles[Index] = sf::NativeHandle(os_handle, true); - return move_handles[Index]; + m_move_handles[Index] = sf::NativeHandle(os_handle, true); + return m_move_handles[Index]; } template constexpr inline CopyHandle &SetCopyHandle(os::NativeHandle os_handle) { static_assert(Index < NumCopy); - copy_handles[Index] = sf::NativeHandle(os_handle, true); - return copy_handles[Index]; + m_copy_handles[Index] = sf::NativeHandle(os_handle, true); + return m_copy_handles[Index]; } }; @@ -659,26 +659,26 @@ namespace ams::sf::impl { static constexpr size_t NumMove = _NumMove; static constexpr size_t NumCopy = _NumCopy; private: - NativeHandle move_handles[NumMove]; - NativeHandle copy_handles[NumCopy]; + NativeHandle m_move_handles[NumMove]; + NativeHandle m_copy_handles[NumCopy]; public: - constexpr OutHandleHolder() : move_handles(), copy_handles() { /* ... */ } + constexpr OutHandleHolder() : m_move_handles(), m_copy_handles() { /* ... */ } template constexpr inline NativeHandle *GetMoveHandlePointer() { static_assert(Index < NumMove, "Index < NumMove"); - return move_handles + Index; + return m_move_handles + Index; } template constexpr inline NativeHandle *GetCopyHandlePointer() { static_assert(Index < NumCopy, "Index < NumCopy"); - return copy_handles + Index; + return m_copy_handles + Index; } constexpr inline void CopyTo(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, const size_t num_out_object_handles) { ctx.handles_to_close->num_handles = 0; - #define _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { const auto handle = copy_handles[n].GetOsHandle(); response.copy_handles[n] = handle; if (copy_handles[n].IsManaged()) { ctx.handles_to_close->handles[ctx.handles_to_close->num_handles++] = handle; } copy_handles[n].Detach(); } } while (0) + #define _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(n) do { if constexpr (NumCopy > n) { const auto handle = m_copy_handles[n].GetOsHandle(); response.copy_handles[n] = handle; if (m_copy_handles[n].IsManaged()) { ctx.handles_to_close->handles[ctx.handles_to_close->num_handles++] = handle; } m_copy_handles[n].Detach(); } } while (0) _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(0); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(1); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(2); @@ -688,7 +688,7 @@ namespace ams::sf::impl { _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(6); _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE(7); #undef _SF_OUT_HANDLE_HOLDER_WRITE_COPY_HANDLE - #define _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { response.move_handles[n + num_out_object_handles] = move_handles[n].GetOsHandle(); move_handles[n].Detach(); } } while (0) + #define _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(n) do { if constexpr (NumMove > n) { response.move_handles[n + num_out_object_handles] = m_move_handles[n].GetOsHandle(); m_move_handles[n].Detach(); } } while (0) _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(0); _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(1); _SF_OUT_HANDLE_HOLDER_WRITE_MOVE_HANDLE(2); @@ -704,13 +704,13 @@ namespace ams::sf::impl { template class InOutObjectHolder { private: - std::array in_object_holders; - std::array out_object_holders; - std::array>, NumOutObjects> out_shared_pointers; - std::array out_object_ids; + std::array m_in_object_holders; + std::array m_out_object_holders; + std::array>, NumOutObjects> m_out_shared_pointers; + std::array m_out_object_ids; public: - constexpr InOutObjectHolder() : in_object_holders(), out_object_holders() { - #define _SF_IN_OUT_HOLDER_INITIALIZE_OBJECT_ID(n) if constexpr (NumOutObjects > n) { this->out_object_ids[n] = cmif::InvalidDomainObjectId; } + constexpr InOutObjectHolder() : m_in_object_holders(), m_out_object_holders() { + #define _SF_IN_OUT_HOLDER_INITIALIZE_OBJECT_ID(n) if constexpr (NumOutObjects > n) { m_out_object_ids[n] = cmif::InvalidDomainObjectId; } _SF_IN_OUT_HOLDER_INITIALIZE_OBJECT_ID(0) _SF_IN_OUT_HOLDER_INITIALIZE_OBJECT_ID(1) _SF_IN_OUT_HOLDER_INITIALIZE_OBJECT_ID(2) @@ -724,7 +724,7 @@ namespace ams::sf::impl { Result GetInObjects(const sf::cmif::ServerMessageProcessor *processor) { if constexpr (NumInObjects > 0) { - R_TRY(processor->GetInObjects(this->in_object_holders.data())); + R_TRY(processor->GetInObjects(m_in_object_holders.data())); } return ResultSuccess(); } @@ -736,7 +736,7 @@ namespace ams::sf::impl { if constexpr (NumInObjects > n) { \ using SharedPointerType = typename std::tuple_element::type; \ using ServiceImplType = typename SharedPointerType::Interface; \ - R_UNLESS((this->in_object_holders[n].template IsServiceObjectValid()), sf::cmif::ResultInvalidInObject()); \ + R_UNLESS((m_in_object_holders[n].template IsServiceObjectValid()), sf::cmif::ResultInvalidInObject()); \ } \ } while (0) _SF_IN_OUT_HOLDER_VALIDATE_IN_OBJECT(0); @@ -754,23 +754,23 @@ namespace ams::sf::impl { template SharedPointer *GetOutObjectSharedPointer() { static_assert(sizeof(SharedPointer) == sizeof(SharedPointer)); - return static_cast *>(static_cast(GetPointer(out_shared_pointers[Index]))); + return static_cast *>(static_cast(GetPointer(m_out_shared_pointers[Index]))); } template Out> GetOutObject() { auto sp = std::construct_at(GetOutObjectSharedPointer()); - return Out>(sp, std::addressof(this->out_object_ids[Index])); + return Out>(sp, std::addressof(m_out_object_ids[Index])); } template void SetOutObject() { - this->out_object_holders[Index] = cmif::ServiceObjectHolder(std::move(*GetOutObjectSharedPointer())); + m_out_object_holders[Index] = cmif::ServiceObjectHolder(std::move(*GetOutObjectSharedPointer())); } constexpr void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response) { if constexpr (NumOutObjects > 0) { - ctx.processor->SetOutObjects(ctx, response, this->out_object_holders.data(), this->out_object_ids.data()); + ctx.processor->SetOutObjects(ctx, response, m_out_object_holders.data(), m_out_object_ids.data()); } } }; @@ -934,7 +934,7 @@ namespace ams::sf::impl { buffer = cmif::PointerAndSize(pointer_buffer_head, size); } else { const u16 *recv_pointer_sizes = reinterpret_cast(reinterpret_cast(ctx.request.data.data_words) + runtime_metadata.GetUnfixedOutPointerSizeOffset()); - const size_t size = size_t(recv_pointer_sizes[Info.unfixed_recv_pointer_index]); + const size_t size = static_cast(recv_pointer_sizes[Info.unfixed_recv_pointer_index]); pointer_buffer_head = util::AlignDown(pointer_buffer_head - size, 0x10); buffer = cmif::PointerAndSize(pointer_buffer_head, size); } @@ -970,7 +970,7 @@ namespace ams::sf::impl { buffer = cmif::PointerAndSize(pointer_buffer_head, size); } else { const u16 *recv_pointer_sizes = reinterpret_cast(reinterpret_cast(ctx.request.data.data_words) + runtime_metadata.GetUnfixedOutPointerSizeOffset()); - const size_t size = size_t(recv_pointer_sizes[Info.unfixed_recv_pointer_index]); + const size_t size = static_cast(recv_pointer_sizes[Info.unfixed_recv_pointer_index]); pointer_buffer_head = util::AlignDown(pointer_buffer_head - size, 0x10); buffer = cmif::PointerAndSize(pointer_buffer_head, size); } diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp index 0bcfceada..a5e58a5f5 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_buffers.hpp @@ -90,20 +90,20 @@ namespace ams::sf { public: static constexpr u32 AdditionalAttributes = 0; private: - const cmif::PointerAndSize pas; + const cmif::PointerAndSize m_pas; protected: constexpr uintptr_t GetAddressImpl() const { - return this->pas.GetAddress(); + return m_pas.GetAddress(); } template constexpr inline size_t GetSizeImpl() const { - return this->pas.GetSize() / sizeof(Entry); + return m_pas.GetSize() / sizeof(Entry); } public: - constexpr BufferBase() : pas() { /* ... */ } - constexpr BufferBase(const cmif::PointerAndSize &_pas) : pas(_pas) { /* ... */ } - constexpr BufferBase(uintptr_t ptr, size_t sz) : pas(ptr, sz) { /* ... */ } + constexpr BufferBase() : m_pas() { /* ... */ } + constexpr BufferBase(const cmif::PointerAndSize &pas) : m_pas(pas) { /* ... */ } + constexpr BufferBase(uintptr_t ptr, size_t sz) : m_pas(ptr, sz) { /* ... */ } }; class InBufferBase : public BufferBase { @@ -113,7 +113,7 @@ namespace ams::sf { SfBufferAttr_In; public: constexpr InBufferBase() : BaseType() { /* ... */ } - constexpr InBufferBase(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr InBufferBase(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr InBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr InBufferBase(const void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -127,7 +127,7 @@ namespace ams::sf { SfBufferAttr_Out; public: constexpr OutBufferBase() : BaseType() { /* ... */ } - constexpr OutBufferBase(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr OutBufferBase(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr OutBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr OutBufferBase(void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -143,7 +143,7 @@ namespace ams::sf { ExtraAttributes; public: constexpr InBufferImpl() : BaseType() { /* ... */ } - constexpr InBufferImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr InBufferImpl(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr InBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr InBufferImpl(const void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -167,7 +167,7 @@ namespace ams::sf { ExtraAttributes; public: constexpr OutBufferImpl() : BaseType() { /* ... */ } - constexpr OutBufferImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr OutBufferImpl(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr OutBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr OutBufferImpl(void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -190,7 +190,7 @@ namespace ams::sf { static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes; public: constexpr InArrayImpl() : BaseType() { /* ... */ } - constexpr InArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr InArrayImpl(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr InArrayImpl(const T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } constexpr const T *GetPointer() const { @@ -222,7 +222,7 @@ namespace ams::sf { static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes; public: constexpr OutArrayImpl() : BaseType() { /* ... */ } - constexpr OutArrayImpl(const cmif::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr OutArrayImpl(const cmif::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr OutArrayImpl(T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } constexpr T *GetPointer() const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_lmem_utility.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_lmem_utility.hpp index 341b903aa..27839e46a 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_lmem_utility.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_lmem_utility.hpp @@ -22,25 +22,25 @@ namespace ams::sf { class ExpHeapMemoryResource : public MemoryResource { private: - lmem::HeapHandle handle; + lmem::HeapHandle m_handle; public: - constexpr ExpHeapMemoryResource() : handle() { /* ... */ } - constexpr explicit ExpHeapMemoryResource(lmem::HeapHandle h) : handle(h) { /* ... */ } + constexpr ExpHeapMemoryResource() : m_handle() { /* ... */ } + constexpr explicit ExpHeapMemoryResource(lmem::HeapHandle h) : m_handle(h) { /* ... */ } void Attach(lmem::HeapHandle h) { - AMS_ABORT_UNLESS(this->handle == lmem::HeapHandle()); - this->handle = h; + AMS_ABORT_UNLESS(m_handle == lmem::HeapHandle()); + m_handle = h; } - lmem::HeapHandle GetHandle() const { return this->handle; } + lmem::HeapHandle GetHandle() const { return m_handle; } private: virtual void *AllocateImpl(size_t size, size_t alignment) override { - return lmem::AllocateFromExpHeap(this->handle, size, static_cast(alignment)); + return lmem::AllocateFromExpHeap(m_handle, size, static_cast(alignment)); } virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override { AMS_UNUSED(size, alignment); - return lmem::FreeToExpHeap(this->handle, buffer); + return lmem::FreeToExpHeap(m_handle, buffer); } virtual bool IsEqualImpl(const MemoryResource &resource) const { @@ -50,30 +50,30 @@ namespace ams::sf { class UnitHeapMemoryResource : public MemoryResource { private: - lmem::HeapHandle handle; + lmem::HeapHandle m_handle; public: - constexpr UnitHeapMemoryResource() : handle() { /* ... */ } - constexpr explicit UnitHeapMemoryResource(lmem::HeapHandle h) : handle(h) { /* ... */ } + constexpr UnitHeapMemoryResource() : m_handle() { /* ... */ } + constexpr explicit UnitHeapMemoryResource(lmem::HeapHandle h) : m_handle(h) { /* ... */ } void Attach(lmem::HeapHandle h) { - AMS_ABORT_UNLESS(this->handle == lmem::HeapHandle()); - this->handle = h; + AMS_ABORT_UNLESS(m_handle == lmem::HeapHandle()); + m_handle = h; } - lmem::HeapHandle GetHandle() const { return this->handle; } + lmem::HeapHandle GetHandle() const { return m_handle; } private: virtual void *AllocateImpl(size_t size, size_t alignment) override { - AMS_ASSERT(size <= lmem::GetUnitHeapUnitSize(this->handle)); - AMS_ASSERT(alignment <= static_cast(lmem::GetUnitHeapAlignment(this->handle))); + AMS_ASSERT(size <= lmem::GetUnitHeapUnitSize(m_handle)); + AMS_ASSERT(alignment <= static_cast(lmem::GetUnitHeapAlignment(m_handle))); AMS_UNUSED(size, alignment); - return lmem::AllocateFromUnitHeap(this->handle); + return lmem::AllocateFromUnitHeap(m_handle); } virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override { AMS_UNUSED(size, alignment); - return lmem::FreeToUnitHeap(this->handle, buffer); + return lmem::FreeToUnitHeap(m_handle, buffer); } virtual bool IsEqualImpl(const MemoryResource &resource) const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_mem_utility.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_mem_utility.hpp index d894c5d2e..c745ca599 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_mem_utility.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_mem_utility.hpp @@ -22,19 +22,19 @@ namespace ams::sf { class StandardAllocatorMemoryResource : public MemoryResource { private: - mem::StandardAllocator *standard_allocator; + mem::StandardAllocator *m_standard_allocator; public: - explicit StandardAllocatorMemoryResource(mem::StandardAllocator *sa) : standard_allocator(sa) { /* ... */ } + explicit StandardAllocatorMemoryResource(mem::StandardAllocator *sa) : m_standard_allocator(sa) { /* ... */ } - mem::StandardAllocator *GetAllocator() const { return this->standard_allocator; } + mem::StandardAllocator *GetAllocator() const { return m_standard_allocator; } private: virtual void *AllocateImpl(size_t size, size_t alignment) override { - return this->standard_allocator->Allocate(size, alignment); + return m_standard_allocator->Allocate(size, alignment); } virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override { AMS_UNUSED(size, alignment); - return this->standard_allocator->Free(buffer); + return m_standard_allocator->Free(buffer); } virtual bool IsEqualImpl(const MemoryResource &resource) const { diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_out.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_out.hpp index e6b1acdb7..b9bc21da1 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_out.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_out.hpp @@ -40,31 +40,31 @@ namespace ams::sf { public: static constexpr size_t TypeSize = sizeof(T); private: - T *ptr; + T *m_ptr; public: - constexpr Out(uintptr_t p) : ptr(reinterpret_cast(p)) { /* ... */ } - constexpr Out(T *p) : ptr(p) { /* ... */ } - constexpr Out(const cmif::PointerAndSize &pas) : ptr(reinterpret_cast(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ } + constexpr Out(uintptr_t p) : m_ptr(reinterpret_cast(p)) { /* ... */ } + constexpr Out(T *p) : m_ptr(p) { /* ... */ } + constexpr Out(const cmif::PointerAndSize &pas) : m_ptr(reinterpret_cast(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ } void SetValue(const T& value) const { - *this->ptr = value; + *m_ptr = value; } const T &GetValue() const { - return *this->ptr; + return *m_ptr; } T *GetPointer() const { - return this->ptr; + return m_ptr; } /* Convenience operators. */ T &operator*() const { - return *this->ptr; + return *m_ptr; } T *operator->() const { - return this->ptr; + return m_ptr; } }; diff --git a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp index 9ab258e3e..8f0495327 100644 --- a/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp +++ b/libraries/libstratosphere/include/stratosphere/sf/sf_service_object.hpp @@ -36,10 +36,10 @@ namespace ams::sf { class MitmServiceImplBase { protected: - std::shared_ptr<::Service> forward_service; - sm::MitmProcessInfo client_info; + std::shared_ptr<::Service> m_forward_service; + sm::MitmProcessInfo m_client_info; public: - MitmServiceImplBase(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : forward_service(std::move(s)), client_info(c) { /* ... */ } + MitmServiceImplBase(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : m_forward_service(std::move(s)), m_client_info(c) { /* ... */ } }; template diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_buffers.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_buffers.hpp index d225ce953..307caf456 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_buffers.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_buffers.hpp @@ -34,20 +34,20 @@ namespace ams::tipc { public: static constexpr u32 AdditionalAttributes = 0; private: - const tipc::PointerAndSize pas; + const tipc::PointerAndSize m_pas; protected: constexpr ALWAYS_INLINE uintptr_t GetAddressImpl() const { - return this->pas.GetAddress(); + return m_pas.GetAddress(); } template constexpr ALWAYS_INLINE size_t GetSizeImpl() const { - return this->pas.GetSize() / sizeof(Entry); + return m_pas.GetSize() / sizeof(Entry); } public: - constexpr ALWAYS_INLINE BufferBase() : pas() { /* ... */ } - constexpr ALWAYS_INLINE BufferBase(const tipc::PointerAndSize &_pas) : pas(_pas) { /* ... */ } - constexpr ALWAYS_INLINE BufferBase(uintptr_t ptr, size_t sz) : pas(ptr, sz) { /* ... */ } + constexpr ALWAYS_INLINE BufferBase() : m_pas() { /* ... */ } + constexpr ALWAYS_INLINE BufferBase(const tipc::PointerAndSize &pas) : m_pas(pas) { /* ... */ } + constexpr ALWAYS_INLINE BufferBase(uintptr_t ptr, size_t sz) : m_pas(ptr, sz) { /* ... */ } }; class InBufferBase : public BufferBase { @@ -57,7 +57,7 @@ namespace ams::tipc { SfBufferAttr_In; public: constexpr ALWAYS_INLINE InBufferBase() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE InBufferBase(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE InBufferBase(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE InBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE InBufferBase(const void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -71,7 +71,7 @@ namespace ams::tipc { SfBufferAttr_Out; public: constexpr ALWAYS_INLINE OutBufferBase() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE OutBufferBase(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE OutBufferBase(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE OutBufferBase(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE OutBufferBase(void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -86,7 +86,7 @@ namespace ams::tipc { ExtraAttributes; public: constexpr ALWAYS_INLINE InBufferImpl() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE InBufferImpl(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE InBufferImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE InBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE InBufferImpl(const void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -109,7 +109,7 @@ namespace ams::tipc { ExtraAttributes; public: constexpr ALWAYS_INLINE OutBufferImpl() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE OutBufferImpl(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE OutBufferImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE OutBufferImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE OutBufferImpl(void *ptr, size_t sz) : BaseType(reinterpret_cast(ptr), sz) { /* ... */ } @@ -131,7 +131,7 @@ namespace ams::tipc { static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes; public: constexpr ALWAYS_INLINE InArrayImpl() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE InArrayImpl(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE InArrayImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE InArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE InArrayImpl(const T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } @@ -164,7 +164,7 @@ namespace ams::tipc { static constexpr u32 AdditionalAttributes = BaseType::AdditionalAttributes; public: constexpr ALWAYS_INLINE OutArrayImpl() : BaseType() { /* ... */ } - constexpr ALWAYS_INLINE OutArrayImpl(const tipc::PointerAndSize &_pas) : BaseType(_pas) { /* ... */ } + constexpr ALWAYS_INLINE OutArrayImpl(const tipc::PointerAndSize &pas) : BaseType(pas) { /* ... */ } constexpr ALWAYS_INLINE OutArrayImpl(uintptr_t ptr, size_t sz) : BaseType(ptr, sz) { /* ... */ } constexpr ALWAYS_INLINE OutArrayImpl(T *ptr, size_t num_elements) : BaseType(reinterpret_cast(ptr), num_elements * sizeof(T)) { /* ... */ } diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp index a71513514..1c72ff40d 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_handles.hpp @@ -44,36 +44,36 @@ namespace ams::tipc { class OutHandleImpl : public OutHandleTag { static_assert(std::is_base_of::value, "OutHandleImpl requires InHandle base"); private: - T *ptr; + T *m_ptr; public: - constexpr OutHandleImpl(T *p) : ptr(p) { /* ... */ } + constexpr OutHandleImpl(T *p) : m_ptr(p) { /* ... */ } constexpr void SetValue(const os::NativeHandle &value) { - *this->ptr = value; + *m_ptr = value; } constexpr void SetValue(const T &value) { - *this->ptr = value; + *m_ptr = value; } constexpr const T &GetValue() const { - return *this->ptr; + return *m_ptr; } constexpr T *GetPointer() const { - return this->ptr; + return m_ptr; } constexpr os::NativeHandle *GetHandlePointer() const { - return &this->ptr->handle; + return &m_ptr->handle; } constexpr T &operator *() const { - return *this->ptr; + return *m_ptr; } constexpr T *operator ->() const { - return this->ptr; + return m_ptr; } }; diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_out.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_out.hpp index 1db42e3bc..d608cc859 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_out.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_out.hpp @@ -40,31 +40,31 @@ namespace ams::tipc { public: static constexpr size_t TypeSize = sizeof(T); private: - T *ptr; + T *m_ptr; public: - constexpr Out(uintptr_t p) : ptr(reinterpret_cast(p)) { /* ... */ } - constexpr Out(T *p) : ptr(p) { /* ... */ } - constexpr Out(const tipc::PointerAndSize &pas) : ptr(reinterpret_cast(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ } + constexpr Out(uintptr_t p) : m_ptr(reinterpret_cast(p)) { /* ... */ } + constexpr Out(T *p) : m_ptr(p) { /* ... */ } + constexpr Out(const tipc::PointerAndSize &pas) : m_ptr(reinterpret_cast(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ } ALWAYS_INLINE void SetValue(const T& value) const { - *this->ptr = value; + *m_ptr = value; } ALWAYS_INLINE const T &GetValue() const { - return *this->ptr; + return *m_ptr; } ALWAYS_INLINE T *GetPointer() const { - return this->ptr; + return m_ptr; } /* Convenience operators. */ ALWAYS_INLINE T &operator*() const { - return *this->ptr; + return *m_ptr; } ALWAYS_INLINE T *operator->() const { - return this->ptr; + return m_ptr; } }; diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_pointer_and_size.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_pointer_and_size.hpp index 9af35dc30..23e206876 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_pointer_and_size.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_pointer_and_size.hpp @@ -20,23 +20,23 @@ namespace ams::tipc { class PointerAndSize { private: - uintptr_t pointer; - size_t size; + uintptr_t m_pointer; + size_t m_size; public: - constexpr PointerAndSize() : pointer(0), size(0) { /* ... */ } - constexpr PointerAndSize(uintptr_t ptr, size_t sz) : pointer(ptr), size(sz) { /* ... */ } + constexpr PointerAndSize() : m_pointer(0), m_size(0) { /* ... */ } + constexpr PointerAndSize(uintptr_t ptr, size_t sz) : m_pointer(ptr), m_size(sz) { /* ... */ } constexpr PointerAndSize(void *ptr, size_t sz) : PointerAndSize(reinterpret_cast(ptr), sz) { /* ... */ } constexpr ALWAYS_INLINE void *GetPointer() const { - return reinterpret_cast(this->pointer); + return reinterpret_cast(m_pointer); } constexpr ALWAYS_INLINE uintptr_t GetAddress() const { - return this->pointer; + return m_pointer; } constexpr ALWAYS_INLINE size_t GetSize() const { - return this->size; + return m_size; } }; diff --git a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp index 6f5f897b1..1e898c173 100644 --- a/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp +++ b/libraries/libstratosphere/include/stratosphere/tipc/tipc_server_manager.hpp @@ -143,7 +143,7 @@ namespace ams::tipc { void RegisterPort(s32 index, os::NativeHandle port_handle) { /* Set our port number. */ - this->m_port_number = index; + m_port_number = index; /* Create an object holder for the port. */ tipc::ObjectHolder object; diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp index bc0471b35..db40a8dae 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.cpp @@ -20,50 +20,50 @@ namespace ams::capsrv::server { Result DecoderControlServerManager::Initialize() { /* Create the objects. */ - this->service_holder.emplace(); - this->server_manager_holder.emplace(); + m_service_holder.emplace(); + m_server_manager_holder.emplace(); /* Register the service. */ - R_ABORT_UNLESS((this->server_manager_holder->RegisterObjectForServer(this->service_holder->GetShared(), ServiceName, MaxSessions))); + R_ABORT_UNLESS((m_server_manager_holder->RegisterObjectForServer(m_service_holder->GetShared(), ServiceName, MaxSessions))); /* Initialize the idle event, we're idle initially. */ - os::InitializeEvent(std::addressof(this->idle_event), true, os::EventClearMode_ManualClear); + os::InitializeEvent(std::addressof(m_idle_event), true, os::EventClearMode_ManualClear); return ResultSuccess(); } void DecoderControlServerManager::Finalize() { /* Check that the server is idle. */ - AMS_ASSERT(os::TryWaitEvent(std::addressof(this->idle_event))); + AMS_ASSERT(os::TryWaitEvent(std::addressof(m_idle_event))); /* Destroy the server. */ - os::FinalizeEvent(std::addressof(this->idle_event)); - this->server_manager_holder = util::nullopt; - this->service_holder = util::nullopt; + os::FinalizeEvent(std::addressof(m_idle_event)); + m_server_manager_holder = util::nullopt; + m_service_holder = util::nullopt; } void DecoderControlServerManager::StartServer() { - this->server_manager_holder->ResumeProcessing(); + m_server_manager_holder->ResumeProcessing(); } void DecoderControlServerManager::StopServer() { /* Request the server stop, and wait until it does. */ - this->server_manager_holder->RequestStopProcessing(); - os::WaitEvent(std::addressof(this->idle_event)); + m_server_manager_holder->RequestStopProcessing(); + os::WaitEvent(std::addressof(m_idle_event)); } void DecoderControlServerManager::RunServer() { /* Ensure that we are allowed to run. */ - AMS_ABORT_UNLESS(os::TryWaitEvent(std::addressof(this->idle_event))); + AMS_ABORT_UNLESS(os::TryWaitEvent(std::addressof(m_idle_event))); /* Clear the event. */ - os::ClearEvent(std::addressof(this->idle_event)); + os::ClearEvent(std::addressof(m_idle_event)); /* Process forever. */ - this->server_manager_holder->LoopProcess(); + m_server_manager_holder->LoopProcess(); /* Signal that we're idle again. */ - os::SignalEvent(std::addressof(this->idle_event)); + os::SignalEvent(std::addressof(m_idle_event)); } } diff --git a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp index a4c2645fc..0ac745f67 100644 --- a/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp +++ b/libraries/libstratosphere/source/capsrv/server/decodersrv/decodersrv_decoder_control_server_manager.hpp @@ -31,11 +31,11 @@ namespace ams::capsrv::server { using ServerOptions = sf::hipc::DefaultServerManagerOptions; using ServerManager = sf::hipc::ServerManager; private: - util::optional service_holder; - util::optional server_manager_holder; - os::EventType idle_event; + util::optional m_service_holder; + util::optional m_server_manager_holder; + os::EventType m_idle_event; public: - constexpr DecoderControlServerManager() : service_holder(), server_manager_holder(), idle_event{} { /* ... */ } + constexpr DecoderControlServerManager() : m_service_holder(), m_server_manager_holder(), m_idle_event{} { /* ... */ } Result Initialize(); void Finalize(); diff --git a/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp b/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp index 08424e58a..f20485e32 100644 --- a/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp +++ b/libraries/libstratosphere/source/ddsf/ddsf_device_code_entry_manager.cpp @@ -23,17 +23,17 @@ namespace ams::ddsf { AMS_ASSERT(device->IsDriverAttached()); /* Acquire exclusive access to the manager. */ - std::scoped_lock lk(this->entry_list_lock); + std::scoped_lock lk(m_entry_list_lock); /* Check that we don't already have an entry with the code. */ - for (const auto &holder : this->entry_list) { + for (const auto &holder : m_entry_list) { AMS_ASSERT(holder.IsConstructed()); AMS_ASSERT(holder.Get().GetDeviceCode() != device_code); AMS_UNUSED(holder); } /* Allocate memory for a new device code entry holder. */ - void *holder_storage = this->memory_resource->Allocate(sizeof(DeviceCodeEntryHolder)); + void *holder_storage = m_memory_resource->Allocate(sizeof(DeviceCodeEntryHolder)); R_UNLESS(holder_storage != nullptr, ddsf::ResultOutOfResource()); /* Initialize the new holder. */ @@ -41,18 +41,18 @@ namespace ams::ddsf { holder->Construct(device_code, device); /* Link the new holder. */ - holder->AddTo(this->entry_list); + holder->AddTo(m_entry_list); return ResultSuccess(); } bool DeviceCodeEntryManager::Remove(DeviceCode device_code) { /* Acquire exclusive access to the manager. */ - std::scoped_lock lk(this->entry_list_lock); + std::scoped_lock lk(m_entry_list_lock); /* Find and erase the entry. */ bool erased = false; - for (auto it = this->entry_list.begin(); it != this->entry_list.end(); /* ... */) { + for (auto it = m_entry_list.begin(); it != m_entry_list.end(); /* ... */) { /* Get the current entry, and advance the iterator. */ DeviceCodeEntryHolder *cur = std::addressof(*(it++)); @@ -62,7 +62,7 @@ namespace ams::ddsf { /* Destroy and deallocate the holder. */ cur->Destroy(); std::destroy_at(cur); - this->memory_resource->Deallocate(cur, sizeof(*cur)); + m_memory_resource->Deallocate(cur, sizeof(*cur)); erased = true; } diff --git a/libraries/libstratosphere/source/ddsf/ddsf_event_handler.cpp b/libraries/libstratosphere/source/ddsf/ddsf_event_handler.cpp index 7eb8d5e5f..c6ab01436 100644 --- a/libraries/libstratosphere/source/ddsf/ddsf_event_handler.cpp +++ b/libraries/libstratosphere/source/ddsf/ddsf_event_handler.cpp @@ -38,63 +38,63 @@ namespace ams::ddsf { void EventHandlerManager::Initialize() { /* Check that we're not already initialized. */ - if (this->is_initialized) { + if (m_is_initialized) { return; } /* Initialize multi wait/holder. */ - os::InitializeMultiWait(std::addressof(this->multi_wait)); - os::InitializeMultiWaitHolder(std::addressof(this->loop_control_event_holder), this->loop_control_event.GetBase()); - os::LinkMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->loop_control_event_holder)); + os::InitializeMultiWait(std::addressof(m_multi_wait)); + os::InitializeMultiWaitHolder(std::addressof(m_loop_control_event_holder), m_loop_control_event.GetBase()); + os::LinkMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_loop_control_event_holder)); - this->is_initialized = true; + m_is_initialized = true; } void EventHandlerManager::Finalize() { /* Check that we're initialized and not looping. */ - AMS_ASSERT(!this->is_looping); - AMS_ASSERT(this->is_initialized); - if (!this->is_initialized) { + AMS_ASSERT(!m_is_looping); + AMS_ASSERT(m_is_initialized); + if (!m_is_initialized) { return; } /* Finalize multi wait/holder. */ - os::UnlinkMultiWaitHolder(std::addressof(this->loop_control_event_holder)); - os::FinalizeMultiWaitHolder(std::addressof(this->loop_control_event_holder)); - os::FinalizeMultiWait(std::addressof(this->multi_wait)); + os::UnlinkMultiWaitHolder(std::addressof(m_loop_control_event_holder)); + os::FinalizeMultiWaitHolder(std::addressof(m_loop_control_event_holder)); + os::FinalizeMultiWait(std::addressof(m_multi_wait)); - this->is_initialized = false; + m_is_initialized = false; } void EventHandlerManager::ProcessControlCommand(LoopControlCommandParameters *params) { /* Check pre-conditions. */ - AMS_ASSERT(this->is_initialized); + AMS_ASSERT(m_is_initialized); AMS_ASSERT(params != nullptr); /* Acquire exclusive access. */ - std::scoped_lock lk(this->loop_control_lock); + std::scoped_lock lk(m_loop_control_lock); /* If we're processing for the loop thread, we can directly handle. */ - if (!this->is_looping || this->IsRunningOnLoopThread()) { + if (!m_is_looping || this->IsRunningOnLoopThread()) { this->ProcessControlCommandImpl(params); } else { /* Otherwise, signal to the loop thread. */ - this->loop_control_command_params = params; - this->loop_control_event.Signal(); - this->loop_control_command_done_event.Wait(); + m_loop_control_command_params = params; + m_loop_control_event.Signal(); + m_loop_control_command_done_event.Wait(); } } void EventHandlerManager::ProcessControlCommandImpl(LoopControlCommandParameters *params) { /* Check pre-conditions. */ - AMS_ASSERT(this->loop_control_lock.IsLockedByCurrentThread() || !this->loop_control_lock.TryLock()); + AMS_ASSERT(m_loop_control_lock.IsLockedByCurrentThread() || !m_loop_control_lock.TryLock()); AMS_ASSERT(params != nullptr); AMS_ASSERT(params->target != nullptr); /* Process the command. */ switch (params->command) { case LoopControlCommand::Register: - params->target->Link(std::addressof(this->multi_wait)); + params->target->Link(std::addressof(m_multi_wait)); break; case LoopControlCommand::Unregister: params->target->Unlink(); @@ -125,74 +125,74 @@ namespace ams::ddsf { void EventHandlerManager::WaitLoopEnter() { /* Acquire exclusive access. */ - std::scoped_lock lk(this->loop_control_lock); + std::scoped_lock lk(m_loop_control_lock); /* Wait until we're looping. */ - while (!this->is_looping) { - this->is_looping_cv.Wait(this->loop_control_lock); + while (!m_is_looping) { + m_is_looping_cv.Wait(m_loop_control_lock); } } void EventHandlerManager::WaitLoopExit() { /* Acquire exclusive access. */ - std::scoped_lock lk(this->loop_control_lock); + std::scoped_lock lk(m_loop_control_lock); /* Wait until we're not looping. */ - while (this->is_looping) { - this->is_looping_cv.Wait(this->loop_control_lock); + while (m_is_looping) { + m_is_looping_cv.Wait(m_loop_control_lock); } } void EventHandlerManager::RequestStop() { /* Check that we're looping and not the loop thread. */ - AMS_ASSERT(this->is_looping); + AMS_ASSERT(m_is_looping); AMS_ASSERT(!this->IsRunningOnLoopThread()); - if (this->is_looping) { + if (m_is_looping) { /* Acquire exclusive access. */ - std::scoped_lock lk(this->loop_control_lock); + std::scoped_lock lk(m_loop_control_lock); /* Signal to the loop thread. */ LoopControlCommandParameters params(LoopControlCommand::Terminate, nullptr); - this->loop_control_command_params = std::addressof(params); - this->loop_control_event.Signal(); - this->loop_control_command_done_event.Wait(); + m_loop_control_command_params = std::addressof(params); + m_loop_control_event.Signal(); + m_loop_control_command_done_event.Wait(); } } void EventHandlerManager::LoopAuto() { /* Check that we're not already looping. */ - AMS_ASSERT(!this->is_looping); + AMS_ASSERT(!m_is_looping); /* Begin looping with the current thread. */ - this->loop_thread = os::GetCurrentThread(); - this->is_looping = true; - this->is_looping_cv.Broadcast(); + m_loop_thread = os::GetCurrentThread(); + m_is_looping = true; + m_is_looping_cv.Broadcast(); /* Whenever we're done looping, clean up. */ ON_SCOPE_EXIT { - this->loop_thread = nullptr; - this->is_looping = false; - this->is_looping_cv.Broadcast(); + m_loop_thread = nullptr; + m_is_looping = false; + m_is_looping_cv.Broadcast(); }; /* Loop until we're asked to stop. */ bool should_terminate = false; while (!should_terminate) { /* Wait for a holder to be signaled. */ - os::MultiWaitHolderType *event_holder = os::WaitAny(std::addressof(this->multi_wait)); + os::MultiWaitHolderType *event_holder = os::WaitAny(std::addressof(m_multi_wait)); AMS_ASSERT(event_holder != nullptr); /* Check if we have a request to handle. */ - if (event_holder == std::addressof(this->loop_control_event_holder)) { + if (event_holder == std::addressof(m_loop_control_event_holder)) { /* Check that the request hasn't already been handled. */ - if (this->loop_control_event.TryWait()) { + if (m_loop_control_event.TryWait()) { /* Handle the request. */ - AMS_ASSERT(this->loop_control_command_params != nullptr); - switch (this->loop_control_command_params->command) { + AMS_ASSERT(m_loop_control_command_params != nullptr); + switch (m_loop_control_command_params->command) { case LoopControlCommand::Register: case LoopControlCommand::Unregister: - this->ProcessControlCommandImpl(this->loop_control_command_params); + this->ProcessControlCommandImpl(m_loop_control_command_params); break; case LoopControlCommand::Terminate: should_terminate = true; @@ -201,8 +201,8 @@ namespace ams::ddsf { } /* Clear the request, and signal that it's done. */ - this->loop_control_command_params = nullptr; - this->loop_control_command_done_event.Signal(); + m_loop_control_command_params = nullptr; + m_loop_control_command_done_event.Signal(); } } else { /* Handle the event. */ diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp index 178494a49..371a7a6f8 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.cpp @@ -28,20 +28,20 @@ namespace ams::erpt::srv { return attachment_name; } - Attachment::Attachment(JournalRecord *r) : record(r) { - this->record->AddReference(); + Attachment::Attachment(JournalRecord *r) : m_record(r) { + m_record->AddReference(); } Attachment::~Attachment() { this->CloseStream(); - if (this->record->RemoveReference()) { + if (m_record->RemoveReference()) { this->DeleteStream(this->FileName().name); - delete this->record; + delete m_record; } } AttachmentFileName Attachment::FileName() const { - return FileName(this->record->info.attachment_id); + return FileName(m_record->m_info.attachment_id); } Result Attachment::Open(AttachmentOpenType type) { @@ -65,13 +65,13 @@ namespace ams::erpt::srv { } Result Attachment::GetFlags(AttachmentFlagSet *out) const { - *out = this->record->info.flags; + *out = m_record->m_info.flags; return ResultSuccess(); } Result Attachment::SetFlags(AttachmentFlagSet flags) { - if (((~this->record->info.flags) & flags).IsAnySet()) { - this->record->info.flags |= flags; + if (((~m_record->m_info.flags) & flags).IsAnySet()) { + m_record->m_info.flags |= flags; return Journal::Commit(); } return ResultSuccess(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp index 2a3bc4bea..0d259cb87 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment.hpp @@ -30,7 +30,7 @@ namespace ams::erpt::srv { class Attachment : public Allocator, public Stream { private: - JournalRecord *record; + JournalRecord *m_record; private: AttachmentFileName FileName() const; public: diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp index ff39c131d..8309a7be2 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.cpp @@ -19,7 +19,7 @@ namespace ams::erpt::srv { - AttachmentImpl::AttachmentImpl() : attachment(nullptr) { + AttachmentImpl::AttachmentImpl() : m_attachment(nullptr) { /* ... */ } @@ -28,52 +28,52 @@ namespace ams::erpt::srv { } Result AttachmentImpl::Open(const AttachmentId &attachment_id) { - R_UNLESS(this->attachment == nullptr, erpt::ResultAlreadyInitialized()); + R_UNLESS(m_attachment == nullptr, erpt::ResultAlreadyInitialized()); JournalRecord *record = Journal::Retrieve(attachment_id); R_UNLESS(record != nullptr, erpt::ResultNotFound()); - this->attachment = new Attachment(record); - R_UNLESS(this->attachment != nullptr, erpt::ResultOutOfMemory()); - auto attachment_guard = SCOPE_GUARD { delete this->attachment; this->attachment = nullptr; }; + m_attachment = new Attachment(record); + R_UNLESS(m_attachment != nullptr, erpt::ResultOutOfMemory()); + auto attachment_guard = SCOPE_GUARD { delete m_attachment; m_attachment = nullptr; }; - R_TRY(this->attachment->Open(AttachmentOpenType_Read)); + R_TRY(m_attachment->Open(AttachmentOpenType_Read)); attachment_guard.Cancel(); return ResultSuccess(); } Result AttachmentImpl::Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) { - R_UNLESS(this->attachment != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return this->attachment->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); + return m_attachment->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); } Result AttachmentImpl::SetFlags(AttachmentFlagSet flags) { - R_UNLESS(this->attachment != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return this->attachment->SetFlags(flags); + return m_attachment->SetFlags(flags); } Result AttachmentImpl::GetFlags(ams::sf::Out out) { - R_UNLESS(this->attachment != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return this->attachment->GetFlags(out.GetPointer()); + return m_attachment->GetFlags(out.GetPointer()); } Result AttachmentImpl::Close() { - if (this->attachment != nullptr) { - this->attachment->Close(); - delete this->attachment; - this->attachment = nullptr; + if (m_attachment != nullptr) { + m_attachment->Close(); + delete m_attachment; + m_attachment = nullptr; } return ResultSuccess(); } Result AttachmentImpl::GetSize(ams::sf::Out out) { - R_UNLESS(this->attachment != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_attachment != nullptr, erpt::ResultNotInitialized()); - return this->attachment->GetSize(out.GetPointer()); + return m_attachment->GetSize(out.GetPointer()); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp index fa0a4bcdc..63e14f486 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_attachment_impl.hpp @@ -22,7 +22,7 @@ namespace ams::erpt::srv { class AttachmentImpl { private: - Attachment *attachment; + Attachment *m_attachment; public: AttachmentImpl(); ~AttachmentImpl(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.cpp index a38bce464..1bcd34bce 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_cipher.cpp @@ -18,7 +18,7 @@ namespace ams::erpt::srv { - u8 Cipher::s_key[crypto::Aes128CtrEncryptor::KeySize + crypto::Aes128CtrEncryptor::IvSize + crypto::Aes128CtrEncryptor::BlockSize]; - bool Cipher::s_need_to_store_cipher = false; + constinit u8 Cipher::s_key[crypto::Aes128CtrEncryptor::KeySize + crypto::Aes128CtrEncryptor::IvSize + crypto::Aes128CtrEncryptor::BlockSize]; + constinit bool Cipher::s_need_to_store_cipher = false; } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp index 50a029de5..5ce9d071d 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.cpp @@ -25,11 +25,11 @@ namespace ams::erpt::srv { using ContextList = util::IntrusiveListBaseTraits::ListType; - ContextList g_category_list; + constinit ContextList g_category_list; } - Context::Context(CategoryId cat, u32 max_records) : category(cat), max_record_count(max_records), record_count(0) { + Context::Context(CategoryId cat, u32 max_records) : m_category(cat), m_max_record_count(max_records), m_record_count(0) { g_category_list.push_front(*this); } @@ -38,12 +38,12 @@ namespace ams::erpt::srv { } Result Context::AddCategoryToReport(Report *report) { - R_SUCCEED_IF(this->record_list.empty()); + R_SUCCEED_IF(m_record_list.empty()); - for (auto it = this->record_list.begin(); it != this->record_list.end(); it++) { - for (u32 i = 0; i < it->ctx.field_count; i++) { - auto *field = std::addressof(it->ctx.fields[i]); - u8 *arr_buf = it->ctx.array_buffer; + for (auto it = m_record_list.begin(); it != m_record_list.end(); it++) { + for (u32 i = 0; i < it->m_ctx.field_count; i++) { + auto *field = std::addressof(it->m_ctx.fields[i]); + u8 *arr_buf = it->m_ctx.array_buffer; switch (field->type) { case FieldType_Bool: R_TRY(Cipher::AddField(report, field->id, field->value_bool)); break; @@ -81,13 +81,13 @@ namespace ams::erpt::srv { } Result Context::AddContextRecordToCategory(std::unique_ptr record) { - if (this->record_count < this->max_record_count) { - this->record_list.push_front(*record.release()); - this->record_count++; + if (m_record_count < m_max_record_count) { + m_record_list.push_front(*record.release()); + m_record_count++; } else { - ContextRecord *back = std::addressof(this->record_list.back()); - this->record_list.pop_back(); - this->record_list.push_front(*record.release()); + ContextRecord *back = std::addressof(m_record_list.back()); + m_record_list.pop_back(); + m_record_list.push_front(*record.release()); delete back; } @@ -96,7 +96,7 @@ namespace ams::erpt::srv { Result Context::SubmitContext(const ContextEntry *entry, const u8 *data, u32 data_size) { auto it = util::range::find_if(g_category_list, [&](const Context &cur) { - return cur.category == entry->category; + return cur.m_category == entry->category; }); R_UNLESS(it != g_category_list.end(), erpt::ResultCategoryNotFound()); @@ -105,7 +105,7 @@ namespace ams::erpt::srv { Result Context::SubmitContextRecord(std::unique_ptr record) { auto it = util::range::find_if(g_category_list, [&](const Context &cur) { - return cur.category == record->ctx.category; + return cur.m_category == record->m_ctx.category; }); R_UNLESS(it != g_category_list.end(), erpt::ResultCategoryNotFound()); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.hpp index 6912c3433..a8a62743e 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context.hpp @@ -25,10 +25,10 @@ namespace ams::erpt::srv { class Context : public Allocator, public util::IntrusiveListBaseNode { private: - const CategoryId category; - const u32 max_record_count; - u32 record_count; - util::IntrusiveListBaseTraits::ListType record_list; + const CategoryId m_category; + const u32 m_max_record_count; + u32 m_record_count; + util::IntrusiveListBaseTraits::ListType m_record_list; public: Context(CategoryId cat, u32 max_records); ~Context(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp index b4dd8ff4b..95d243ed2 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.cpp @@ -18,7 +18,7 @@ namespace ams::erpt::srv { - u32 ContextRecord::s_record_count = 0; + constinit u32 ContextRecord::s_record_count = 0; namespace { @@ -34,56 +34,56 @@ namespace ams::erpt::srv { } ContextRecord::ContextRecord() { - this->ctx = {}; + m_ctx = {}; } ContextRecord::ContextRecord(CategoryId category, u32 array_buf_size) { - this->ctx = { + m_ctx = { .category = category, .array_buffer = static_cast(Allocate(array_buf_size)), }; - if (this->ctx.array_buffer != nullptr) { - this->ctx.array_buffer_size = array_buf_size; - this->ctx.array_free_count = array_buf_size; + if (m_ctx.array_buffer != nullptr) { + m_ctx.array_buffer_size = array_buf_size; + m_ctx.array_free_count = array_buf_size; } } ContextRecord::~ContextRecord() { - if (this->ctx.array_buffer != nullptr) { - Deallocate(this->ctx.array_buffer); + if (m_ctx.array_buffer != nullptr) { + Deallocate(m_ctx.array_buffer); } - AMS_ABORT_UNLESS(s_record_count >= this->ctx.field_count); - s_record_count -= this->ctx.field_count; + AMS_ABORT_UNLESS(s_record_count >= m_ctx.field_count); + s_record_count -= m_ctx.field_count; } Result ContextRecord::Initialize(const ContextEntry *ctx_ptr, const u8 *data, u32 data_size) { R_UNLESS(data_size <= ArrayBufferSizeMax, erpt::ResultInvalidArgument()); - this->ctx.version = ctx_ptr->version; - this->ctx.field_count = ctx_ptr->field_count; - this->ctx.category = ctx_ptr->category; - this->ctx.array_buffer = nullptr; - this->ctx.array_buffer_size = data_size; - this->ctx.array_free_count = 0; + m_ctx.version = ctx_ptr->version; + m_ctx.field_count = ctx_ptr->field_count; + m_ctx.category = ctx_ptr->category; + m_ctx.array_buffer = nullptr; + m_ctx.array_buffer_size = data_size; + m_ctx.array_free_count = 0; - auto guard = SCOPE_GUARD { this->ctx.field_count = 0; }; + auto guard = SCOPE_GUARD { m_ctx.field_count = 0; }; - R_UNLESS(this->ctx.field_count <= FieldsPerContext, erpt::ResultInvalidArgument()); - R_UNLESS(0 <= this->ctx.category && this->ctx.category < CategoryId_Count, erpt::ResultInvalidArgument()); + R_UNLESS(m_ctx.field_count <= FieldsPerContext, erpt::ResultInvalidArgument()); + R_UNLESS(0 <= m_ctx.category && m_ctx.category < CategoryId_Count, erpt::ResultInvalidArgument()); - for (u32 i = 0; i < this->ctx.field_count; i++) { - this->ctx.fields[i] = ctx_ptr->fields[i]; + for (u32 i = 0; i < m_ctx.field_count; i++) { + m_ctx.fields[i] = ctx_ptr->fields[i]; - R_UNLESS(0 <= this->ctx.fields[i].id && this->ctx.fields[i].id < FieldId_Count, erpt::ResultInvalidArgument()); - R_UNLESS(0 <= this->ctx.fields[i].type && this->ctx.fields[i].type < FieldType_Count, erpt::ResultInvalidArgument()); + R_UNLESS(0 <= m_ctx.fields[i].id && m_ctx.fields[i].id < FieldId_Count, erpt::ResultInvalidArgument()); + R_UNLESS(0 <= m_ctx.fields[i].type && m_ctx.fields[i].type < FieldType_Count, erpt::ResultInvalidArgument()); - R_UNLESS(this->ctx.fields[i].type == FieldToTypeMap[this->ctx.fields[i].id], erpt::ResultFieldTypeMismatch()); - R_UNLESS(this->ctx.category == FieldToCategoryMap[this->ctx.fields[i].id], erpt::ResultFieldCategoryMismatch()); + R_UNLESS(m_ctx.fields[i].type == FieldToTypeMap[m_ctx.fields[i].id], erpt::ResultFieldTypeMismatch()); + R_UNLESS(m_ctx.category == FieldToCategoryMap[m_ctx.fields[i].id], erpt::ResultFieldCategoryMismatch()); - if (IsArrayFieldType(this->ctx.fields[i].type)) { - const u32 start_idx = this->ctx.fields[i].value_array.start_idx; - const u32 size = this->ctx.fields[i].value_array.size; + if (IsArrayFieldType(m_ctx.fields[i].type)) { + const u32 start_idx = m_ctx.fields[i].value_array.start_idx; + const u32 size = m_ctx.fields[i].value_array.size; const u32 end_idx = start_idx + size; R_UNLESS(start_idx <= data_size, erpt::ResultInvalidArgument()); @@ -95,25 +95,25 @@ namespace ams::erpt::srv { if (data_size > 0) { /* If array buffer isn't nullptr, we'll leak memory here, so verify that it is. */ - AMS_ABORT_UNLESS(this->ctx.array_buffer == nullptr); + AMS_ABORT_UNLESS(m_ctx.array_buffer == nullptr); - this->ctx.array_buffer = static_cast(AllocateWithAlign(data_size, alignof(u64))); - R_UNLESS(this->ctx.array_buffer != nullptr, erpt::ResultOutOfMemory()); + m_ctx.array_buffer = static_cast(AllocateWithAlign(data_size, alignof(u64))); + R_UNLESS(m_ctx.array_buffer != nullptr, erpt::ResultOutOfMemory()); - std::memcpy(this->ctx.array_buffer, data, data_size); + std::memcpy(m_ctx.array_buffer, data, data_size); } guard.Cancel(); - s_record_count += this->ctx.field_count; + s_record_count += m_ctx.field_count; return ResultSuccess(); } Result ContextRecord::Add(FieldId field_id, bool value_bool) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = FieldType_Bool; @@ -124,10 +124,10 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, u32 value_u32) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = FieldType_NumericU32; @@ -138,10 +138,10 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, u64 value_u64) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = FieldType_NumericU64; @@ -152,10 +152,10 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, s32 value_i32) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = FieldType_NumericI32; @@ -166,10 +166,10 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, s64 value_i64) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = FieldType_NumericI64; @@ -180,14 +180,14 @@ namespace ams::erpt::srv { } Result ContextRecord::Add(FieldId field_id, const void *arr, u32 size, FieldType type) { - R_UNLESS(this->ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); - R_UNLESS(size <= this->ctx.array_free_count, erpt::ResultOutOfArraySpace()); + R_UNLESS(m_ctx.field_count < FieldsPerContext, erpt::ResultOutOfFieldSpace()); + R_UNLESS(size <= m_ctx.array_free_count, erpt::ResultOutOfArraySpace()); - const u32 start_idx = this->ctx.array_buffer_size - this->ctx.array_free_count; - this->ctx.array_free_count -= size; + const u32 start_idx = m_ctx.array_buffer_size - m_ctx.array_free_count; + m_ctx.array_free_count -= size; s_record_count++; - auto &field = this->ctx.fields[this->ctx.field_count++]; + auto &field = m_ctx.fields[m_ctx.field_count++]; field.id = field_id; field.type = type; @@ -197,7 +197,7 @@ namespace ams::erpt::srv { .size = size, }; - std::memcpy(this->ctx.array_buffer + start_idx, arr, size); + std::memcpy(m_ctx.array_buffer + start_idx, arr, size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.hpp index 64bdea90c..59a82dbb8 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_context_record.hpp @@ -30,7 +30,7 @@ namespace ams::erpt::srv { return s_record_count; } private: - ContextEntry ctx; + ContextEntry m_ctx; private: Result Add(FieldId field_id, const void *arr, u32 size, FieldType type); public: @@ -39,7 +39,7 @@ namespace ams::erpt::srv { ~ContextRecord(); const ContextEntry *GetContextEntryPtr() const { - return std::addressof(this->ctx); + return std::addressof(m_ctx); } Result Initialize(const ContextEntry *ctx_ptr, const u8 *data, u32 data_size); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp index 3579385aa..25c303f85 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_attachments.cpp @@ -19,9 +19,9 @@ namespace ams::erpt::srv { - util::IntrusiveListBaseTraits>::ListType JournalForAttachments::s_attachment_list; - u32 JournalForAttachments::s_attachment_count = 0; - u32 JournalForAttachments::s_used_storage = 0; + constinit util::IntrusiveListBaseTraits>::ListType JournalForAttachments::s_attachment_list; + constinit u32 JournalForAttachments::s_attachment_count = 0; + constinit u32 JournalForAttachments::s_used_storage = 0; namespace { @@ -34,7 +34,7 @@ namespace ams::erpt::srv { auto *record = std::addressof(*it); it = s_attachment_list.erase(s_attachment_list.iterator_to(*record)); if (record->RemoveReference()) { - Stream::DeleteStream(Attachment::FileName(record->info.attachment_id).name); + Stream::DeleteStream(Attachment::FileName(record->m_info.attachment_id).name); delete record; } } @@ -48,7 +48,7 @@ namespace ams::erpt::srv { Result JournalForAttachments::CommitJournal(Stream *stream) { R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(s_attachment_count)), sizeof(s_attachment_count))); for (auto it = s_attachment_list.crbegin(); it != s_attachment_list.crend(); it++) { - R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(it->info)), sizeof(it->info))); + R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(it->m_info)), sizeof(it->m_info))); } return ResultSuccess(); } @@ -56,17 +56,17 @@ namespace ams::erpt::srv { Result JournalForAttachments::DeleteAttachments(ReportId report_id) { for (auto it = s_attachment_list.begin(); it != s_attachment_list.end(); /* ... */) { auto *record = std::addressof(*it); - if (record->info.owner_report_id == report_id) { + if (record->m_info.owner_report_id == report_id) { /* Erase from the list. */ it = s_attachment_list.erase(s_attachment_list.iterator_to(*record)); /* Update storage tracking counts. */ --s_attachment_count; - s_used_storage -= static_cast(record->info.attachment_size); + s_used_storage -= static_cast(record->m_info.attachment_size); /* Delete the object, if we should. */ if (record->RemoveReference()) { - Stream::DeleteStream(Attachment::FileName(record->info.attachment_id).name); + Stream::DeleteStream(Attachment::FileName(record->m_info.attachment_id).name); delete record; } } else { @@ -80,8 +80,8 @@ namespace ams::erpt::srv { Result JournalForAttachments::GetAttachmentList(AttachmentList *out, ReportId report_id) { u32 count = 0; for (auto it = s_attachment_list.cbegin(); it != s_attachment_list.cend() && count < util::size(out->attachments); it++) { - if (report_id == it->info.owner_report_id) { - out->attachments[count++] = it->info; + if (report_id == it->m_info.owner_report_id) { + out->attachments[count++] = it->m_info; } } out->attachment_count = count; @@ -118,17 +118,17 @@ namespace ams::erpt::srv { auto record_guard = SCOPE_GUARD { delete record; }; - if (R_FAILED(Stream::GetStreamSize(std::addressof(record->info.attachment_size), Attachment::FileName(record->info.attachment_id).name))) { + if (R_FAILED(Stream::GetStreamSize(std::addressof(record->m_info.attachment_size), Attachment::FileName(record->m_info.attachment_id).name))) { continue; } - if (record->info.flags.Test() && JournalForReports::RetrieveRecord(record->info.owner_report_id) != nullptr) { + if (record->m_info.flags.Test() && JournalForReports::RetrieveRecord(record->m_info.owner_report_id) != nullptr) { /* NOTE: Nintendo does not check the result of storing the new record... */ record_guard.Cancel(); StoreRecord(record); } else { /* If the attachment has no owner (or we deleted the report), delete the file associated with it. */ - Stream::DeleteStream(Attachment::FileName(record->info.attachment_id).name); + Stream::DeleteStream(Attachment::FileName(record->m_info.attachment_id).name); } } @@ -138,7 +138,7 @@ namespace ams::erpt::srv { JournalRecord *JournalForAttachments::RetrieveRecord(AttachmentId attachment_id) { for (auto it = s_attachment_list.begin(); it != s_attachment_list.end(); it++) { - if (auto *record = std::addressof(*it); record->info.attachment_id == attachment_id) { + if (auto *record = std::addressof(*it); record->m_info.attachment_id == attachment_id) { return record; } } @@ -148,11 +148,11 @@ namespace ams::erpt::srv { Result JournalForAttachments::SetOwner(AttachmentId attachment_id, ReportId report_id) { for (auto it = s_attachment_list.begin(); it != s_attachment_list.end(); it++) { auto *record = std::addressof(*it); - if (record->info.attachment_id == attachment_id) { - R_UNLESS(!record->info.flags.Test(), erpt::ResultAlreadyOwned()); + if (record->m_info.attachment_id == attachment_id) { + R_UNLESS(!record->m_info.flags.Test(), erpt::ResultAlreadyOwned()); - record->info.owner_report_id = report_id; - record->info.flags.Set(); + record->m_info.owner_report_id = report_id; + record->m_info.flags.Set(); return ResultSuccess(); } } @@ -162,7 +162,7 @@ namespace ams::erpt::srv { Result JournalForAttachments::StoreRecord(JournalRecord *record) { /* Check if the record already exists. */ for (auto it = s_attachment_list.begin(); it != s_attachment_list.end(); it++) { - R_UNLESS(it->info.attachment_id != record->info.attachment_id, erpt::ResultAlreadyExists()); + R_UNLESS(it->m_info.attachment_id != record->m_info.attachment_id, erpt::ResultAlreadyExists()); } /* Add a reference to the new record. */ @@ -171,7 +171,7 @@ namespace ams::erpt::srv { /* Push the record into the list. */ s_attachment_list.push_front(*record); s_attachment_count++; - s_used_storage += static_cast(record->info.attachment_size); + s_used_storage += static_cast(record->m_info.attachment_size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp index 683a5629b..09337fdcd 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_meta.cpp @@ -18,7 +18,7 @@ namespace ams::erpt::srv { - JournalMeta JournalForMeta::s_journal_meta; + constinit JournalMeta JournalForMeta::s_journal_meta; void JournalForMeta::InitializeJournal() { std::memset(std::addressof(s_journal_meta), 0, sizeof(s_journal_meta)); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_reports.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_reports.cpp index bd6a0ab2b..6840d997c 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_reports.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_for_reports.cpp @@ -19,17 +19,17 @@ namespace ams::erpt::srv { - util::IntrusiveListBaseTraits>::ListType JournalForReports::s_record_list; - u32 JournalForReports::s_record_count = 0; - u32 JournalForReports::s_record_count_by_type[ReportType_Count] = {}; - u32 JournalForReports::s_used_storage = 0; + constinit util::IntrusiveListBaseTraits>::ListType JournalForReports::s_record_list; + constinit u32 JournalForReports::s_record_count = 0; + constinit u32 JournalForReports::s_record_count_by_type[ReportType_Count] = {}; + constinit u32 JournalForReports::s_used_storage = 0; void JournalForReports::CleanupReports() { for (auto it = s_record_list.begin(); it != s_record_list.end(); /* ... */) { auto *record = std::addressof(*it); it = s_record_list.erase(s_record_list.iterator_to(*record)); if (record->RemoveReference()) { - Stream::DeleteStream(Report::FileName(record->info.id, false).name); + Stream::DeleteStream(Report::FileName(record->m_info.id, false).name); delete record; } } @@ -44,7 +44,7 @@ namespace ams::erpt::srv { Result JournalForReports::CommitJournal(Stream *stream) { R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(s_record_count)), sizeof(s_record_count))); for (auto it = s_record_list.crbegin(); it != s_record_list.crend(); it++) { - R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(it->info)), sizeof(it->info))); + R_TRY(stream->WriteStream(reinterpret_cast(std::addressof(it->m_info)), sizeof(it->m_info))); } return ResultSuccess(); } @@ -55,22 +55,22 @@ namespace ams::erpt::srv { /* Update storage tracking counts. */ --s_record_count; - --s_record_count_by_type[record->info.type]; - s_used_storage -= static_cast(record->info.report_size); + --s_record_count_by_type[record->m_info.type]; + s_used_storage -= static_cast(record->m_info.report_size); /* If we should increment count, do so. */ if (increment_count) { - JournalForMeta::IncrementCount(record->info.flags.Test(), record->info.type); + JournalForMeta::IncrementCount(record->m_info.flags.Test(), record->m_info.type); } /* Delete any attachments. */ - if (force_delete_attachments || record->info.flags.Test()) { - JournalForAttachments::DeleteAttachments(record->info.id); + if (force_delete_attachments || record->m_info.flags.Test()) { + JournalForAttachments::DeleteAttachments(record->m_info.id); } /* Delete the object, if we should. */ if (record->RemoveReference()) { - Stream::DeleteStream(Report::FileName(record->info.id, false).name); + Stream::DeleteStream(Report::FileName(record->m_info.id, false).name); delete record; } } @@ -78,7 +78,7 @@ namespace ams::erpt::srv { Result JournalForReports::DeleteReport(ReportId report_id) { for (auto it = s_record_list.begin(); it != s_record_list.end(); it++) { auto *record = std::addressof(*it); - if (record->info.id == report_id) { + if (record->m_info.id == report_id) { EraseReportImpl(record, false, false); return ResultSuccess(); } @@ -89,7 +89,7 @@ namespace ams::erpt::srv { Result JournalForReports::DeleteReportWithAttachments() { for (auto it = s_record_list.rbegin(); it != s_record_list.rend(); it++) { auto *record = std::addressof(*it); - if (record->info.flags.Test()) { + if (record->m_info.flags.Test()) { EraseReportImpl(record, true, true); return ResultSuccess(); } @@ -100,7 +100,7 @@ namespace ams::erpt::srv { s64 JournalForReports::GetMaxReportSize() { s64 max_size = 0; for (auto it = s_record_list.begin(); it != s_record_list.end(); it++) { - max_size = std::max(max_size, it->info.report_size); + max_size = std::max(max_size, it->m_info.report_size); } return max_size; } @@ -108,8 +108,8 @@ namespace ams::erpt::srv { Result JournalForReports::GetReportList(ReportList *out, ReportType type_filter) { u32 count = 0; for (auto it = s_record_list.cbegin(); it != s_record_list.cend() && count < util::size(out->reports); it++) { - if (type_filter == ReportType_Any || type_filter == it->info.type) { - out->reports[count++] = it->info; + if (type_filter == ReportType_Any || type_filter == it->m_info.type) { + out->reports[count++] = it->m_info; } } out->report_count = count; @@ -158,8 +158,8 @@ namespace ams::erpt::srv { /* We will ensure it is freed if we early error. */ auto record_guard = SCOPE_GUARD { delete record; }; - if (record->info.report_size == 0) { - R_UNLESS(R_SUCCEEDED(Stream::GetStreamSize(std::addressof(record->info.report_size), Report::FileName(record->info.id, false).name)), erpt::ResultCorruptJournal()); + if (record->m_info.report_size == 0) { + R_UNLESS(R_SUCCEEDED(Stream::GetStreamSize(std::addressof(record->m_info.report_size), Report::FileName(record->m_info.id, false).name)), erpt::ResultCorruptJournal()); } record_guard.Cancel(); @@ -174,7 +174,7 @@ namespace ams::erpt::srv { JournalRecord *JournalForReports::RetrieveRecord(ReportId report_id) { for (auto it = s_record_list.begin(); it != s_record_list.end(); it++) { - if (auto *record = std::addressof(*it); record->info.id == report_id) { + if (auto *record = std::addressof(*it); record->m_info.id == report_id) { return record; } } @@ -185,14 +185,14 @@ namespace ams::erpt::srv { Result JournalForReports::StoreRecord(JournalRecord *record) { /* Check if the record already exists. */ for (auto it = s_record_list.begin(); it != s_record_list.end(); it++) { - R_UNLESS(it->info.id != record->info.id, erpt::ResultAlreadyExists()); + R_UNLESS(it->m_info.id != record->m_info.id, erpt::ResultAlreadyExists()); } /* Delete an older report if we need to. */ if (s_record_count >= ReportCountMax) { /* Nintendo deletes the oldest report from the type with the most reports. */ /* This is an approximation of FIFO. */ - ReportType most_used_type = record->info.type; + ReportType most_used_type = record->m_info.type; u32 most_used_count = s_record_count_by_type[most_used_type]; for (int i = ReportType_Start; i < ReportType_End; i++) { @@ -203,7 +203,7 @@ namespace ams::erpt::srv { } for (auto it = s_record_list.rbegin(); it != s_record_list.rend(); it++) { - if (it->info.type != most_used_type) { + if (it->m_info.type != most_used_type) { continue; } @@ -219,8 +219,8 @@ namespace ams::erpt::srv { /* Push the record into the list. */ s_record_list.push_front(*record); s_record_count++; - s_record_count_by_type[record->info.type]++; - s_used_storage += static_cast(record->info.report_size); + s_record_count_by_type[record->m_info.type]++; + s_used_storage += static_cast(record->m_info.report_size); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_record.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_record.hpp index 2d99c348e..484ffde53 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_record.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_journal_record.hpp @@ -23,13 +23,13 @@ namespace ams::erpt::srv { template class JournalRecord : public Allocator, public RefCount, public util::IntrusiveListBaseNode> { public: - Info info; + Info m_info; JournalRecord() { - std::memset(std::addressof(this->info), 0, sizeof(this->info)); + std::memset(std::addressof(m_info), 0, sizeof(m_info)); } - explicit JournalRecord(Info info) : info(info) { /* ... */ } + explicit JournalRecord(Info info) : m_info(info) { /* ... */ } }; diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp index 9a29d41d9..3413afb5a 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_main.cpp @@ -24,8 +24,8 @@ namespace ams::erpt::srv { - lmem::HeapHandle g_heap_handle; - ams::sf::ExpHeapAllocator g_sf_allocator; + constinit lmem::HeapHandle g_heap_handle; + constinit ams::sf::ExpHeapAllocator g_sf_allocator; namespace { diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp index 6fb040957..daab91319 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.cpp @@ -23,11 +23,11 @@ namespace ams::erpt::srv { using ManagerList = util::IntrusiveListBaseTraits::ListType; - ManagerList g_manager_list; + constinit ManagerList g_manager_list; } - ManagerImpl::ManagerImpl() : system_event(os::EventClearMode_AutoClear, true) { + ManagerImpl::ManagerImpl() : m_system_event(os::EventClearMode_AutoClear, true) { g_manager_list.push_front(*this); } @@ -36,7 +36,7 @@ namespace ams::erpt::srv { } void ManagerImpl::NotifyOne() { - this->system_event.Signal(); + m_system_event.Signal(); } Result ManagerImpl::NotifyAll() { @@ -53,7 +53,7 @@ namespace ams::erpt::srv { } Result ManagerImpl::GetEvent(ams::sf::OutCopyHandle out) { - out.SetValue(this->system_event.GetReadableHandle(), false); + out.SetValue(m_system_event.GetReadableHandle(), false); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp index 3ccda6311..bbf0c254e 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_manager_impl.hpp @@ -20,7 +20,7 @@ namespace ams::erpt::srv { class ManagerImpl : public util::IntrusiveListBaseNode { private: - os::SystemEvent system_event; + os::SystemEvent m_system_event; public: ManagerImpl(); ~ManagerImpl(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_ref_count.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_ref_count.hpp index f8beeabbf..ec4f00474 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_ref_count.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_ref_count.hpp @@ -21,17 +21,17 @@ namespace ams::erpt::srv { class RefCount { private: static constexpr u32 MaxReferenceCount = 1000; - std::atomic ref_count; + std::atomic m_ref_count; public: - RefCount() : ref_count(0) { /* ... */ } + RefCount() : m_ref_count(0) { /* ... */ } void AddReference() { - const auto prev = this->ref_count.fetch_add(1); + const auto prev = m_ref_count.fetch_add(1); AMS_ABORT_UNLESS(prev <= MaxReferenceCount); } bool RemoveReference() { - auto prev = this->ref_count.fetch_sub(1); + auto prev = m_ref_count.fetch_sub(1); AMS_ABORT_UNLESS(prev != 0); return prev == 1; } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp index 8b2094b0c..7aa56300a 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.cpp @@ -34,20 +34,20 @@ namespace ams::erpt::srv { return report_name; } - Report::Report(JournalRecord *r, bool redirect_to_sd) : record(r), redirect_to_sd_card(redirect_to_sd) { - this->record->AddReference(); + Report::Report(JournalRecord *r, bool redirect_to_sd) : m_record(r), m_redirect_to_sd_card(redirect_to_sd) { + m_record->AddReference(); } Report::~Report() { this->CloseStream(); - if (this->record->RemoveReference()) { + if (m_record->RemoveReference()) { this->DeleteStream(this->FileName().name); - delete this->record; + delete m_record; } } ReportFileName Report::FileName() const { - return FileName(this->record->info.id, this->redirect_to_sd_card); + return FileName(m_record->m_info.id, m_redirect_to_sd_card); } Result Report::Open(ReportOpenType type) { @@ -71,13 +71,13 @@ namespace ams::erpt::srv { } Result Report::GetFlags(ReportFlagSet *out) const { - *out = this->record->info.flags; + *out = m_record->m_info.flags; return ResultSuccess(); } Result Report::SetFlags(ReportFlagSet flags) { - if (((~this->record->info.flags) & flags).IsAnySet()) { - this->record->info.flags |= flags; + if (((~m_record->m_info.flags) & flags).IsAnySet()) { + m_record->m_info.flags |= flags; return Journal::Commit(); } return ResultSuccess(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp index 79b463637..115644e15 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report.hpp @@ -30,8 +30,8 @@ namespace ams::erpt::srv { class Report : public Allocator, public Stream { private: - JournalRecord *record; - bool redirect_to_sd_card; + JournalRecord *m_record; + bool m_redirect_to_sd_card; private: ReportFileName FileName() const; public: diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp index c6dac136b..f3926f2d6 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.cpp @@ -19,7 +19,7 @@ namespace ams::erpt::srv { - ReportImpl::ReportImpl() : report(nullptr) { + ReportImpl::ReportImpl() : m_report(nullptr) { /* ... */ } @@ -28,52 +28,52 @@ namespace ams::erpt::srv { } Result ReportImpl::Open(const ReportId &report_id) { - R_UNLESS(this->report == nullptr, erpt::ResultAlreadyInitialized()); + R_UNLESS(m_report == nullptr, erpt::ResultAlreadyInitialized()); JournalRecord *record = Journal::Retrieve(report_id); R_UNLESS(record != nullptr, erpt::ResultNotFound()); - this->report = new Report(record, false); - R_UNLESS(this->report != nullptr, erpt::ResultOutOfMemory()); - auto report_guard = SCOPE_GUARD { delete this->report; this->report = nullptr; }; + m_report = new Report(record, false); + R_UNLESS(m_report != nullptr, erpt::ResultOutOfMemory()); + auto report_guard = SCOPE_GUARD { delete m_report; m_report = nullptr; }; - R_TRY(this->report->Open(ReportOpenType_Read)); + R_TRY(m_report->Open(ReportOpenType_Read)); report_guard.Cancel(); return ResultSuccess(); } Result ReportImpl::Read(ams::sf::Out out_count, const ams::sf::OutBuffer &out_buffer) { - R_UNLESS(this->report != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return this->report->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); + return m_report->Read(out_count.GetPointer(), static_cast(out_buffer.GetPointer()), static_cast(out_buffer.GetSize())); } Result ReportImpl::SetFlags(ReportFlagSet flags) { - R_UNLESS(this->report != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return this->report->SetFlags(flags); + return m_report->SetFlags(flags); } Result ReportImpl::GetFlags(ams::sf::Out out) { - R_UNLESS(this->report != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return this->report->GetFlags(out.GetPointer()); + return m_report->GetFlags(out.GetPointer()); } Result ReportImpl::Close() { - if (this->report != nullptr) { - this->report->Close(); - delete this->report; - this->report = nullptr; + if (m_report != nullptr) { + m_report->Close(); + delete m_report; + m_report = nullptr; } return ResultSuccess(); } Result ReportImpl::GetSize(ams::sf::Out out) { - R_UNLESS(this->report != nullptr, erpt::ResultNotInitialized()); + R_UNLESS(m_report != nullptr, erpt::ResultNotInitialized()); - return this->report->GetSize(out.GetPointer()); + return m_report->GetSize(out.GetPointer()); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp index 0a8de0bff..f6ac77352 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_report_impl.hpp @@ -22,7 +22,7 @@ namespace ams::erpt::srv { class ReportImpl { private: - Report *report; + Report *m_report; public: ReportImpl(); ~ReportImpl(); diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index 83f913ac8..fa6112afa 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -356,16 +356,16 @@ namespace ams::erpt::srv { R_UNLESS(record != nullptr, erpt::ResultOutOfMemory()); record->AddReference(); - record->info.type = type; - record->info.id = report_id; - record->info.flags = erpt::srv::MakeNoReportFlags(); - record->info.timestamp_user = timestamp_user; - record->info.timestamp_network = timestamp_network; + record->m_info.type = type; + record->m_info.id = report_id; + record->m_info.flags = erpt::srv::MakeNoReportFlags(); + record->m_info.timestamp_user = timestamp_user; + record->m_info.timestamp_network = timestamp_network; if (meta != nullptr) { - record->info.meta_data = *meta; + record->m_info.meta_data = *meta; } if (num_attachments > 0) { - record->info.flags.Set(); + record->m_info.flags.Set(); } auto report = std::make_unique(record.get(), redirect_new_reports); @@ -373,7 +373,7 @@ namespace ams::erpt::srv { auto report_guard = SCOPE_GUARD { report->Delete(); }; R_TRY(Context::WriteContextsToReport(report.get())); - R_TRY(report->GetSize(std::addressof(record->info.report_size))); + R_TRY(report->GetSize(std::addressof(record->m_info.report_size))); if (!redirect_new_reports) { /* If we're not redirecting new reports, then we want to store the report in the journal. */ diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp index 90df0c641..03da203c8 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_service.cpp @@ -40,7 +40,7 @@ namespace ams::erpt::srv { constexpr inline sm::ServiceName ErrorReportContextServiceName = sm::ServiceName::Encode("erpt:c"); constexpr inline sm::ServiceName ErrorReportReportServiceName = sm::ServiceName::Encode("erpt:r"); - alignas(os::ThreadStackAlignment) u8 g_server_thread_stack[16_KB]; + alignas(os::ThreadStackAlignment) constinit u8 g_server_thread_stack[16_KB]; enum PortIndex { PortIndex_Report, @@ -49,8 +49,8 @@ namespace ams::erpt::srv { class ErrorReportServiceManager : public ams::sf::hipc::ServerManager { private: - os::ThreadType thread; - ams::sf::UnmanagedServiceObject context_session_object; + os::ThreadType m_thread; + ams::sf::UnmanagedServiceObject m_context_session_object; private: static void ThreadFunction(void *_this) { reinterpret_cast(_this)->SetupAndLoopProcess(); @@ -67,7 +67,7 @@ namespace ams::erpt::srv { return this->AcceptImpl(server, intf); } case PortIndex_Context: - return AcceptImpl(server, this->context_session_object.GetShared()); + return AcceptImpl(server, m_context_session_object.GetShared()); default: return erpt::ResultNotSupported(); } @@ -79,16 +79,16 @@ namespace ams::erpt::srv { this->ResumeProcessing(); - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), ThreadFunction, this, g_server_thread_stack, sizeof(g_server_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(erpt, IpcServer))); - os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(erpt, IpcServer)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_thread), ThreadFunction, this, g_server_thread_stack, sizeof(g_server_thread_stack), AMS_GET_SYSTEM_THREAD_PRIORITY(erpt, IpcServer))); + os::SetThreadNamePointer(std::addressof(m_thread), AMS_GET_SYSTEM_THREAD_NAME(erpt, IpcServer)); - os::StartThread(std::addressof(this->thread)); + os::StartThread(std::addressof(m_thread)); return ResultSuccess(); } void Wait() { - os::WaitThread(std::addressof(this->thread)); + os::WaitThread(std::addressof(m_thread)); } }; @@ -136,16 +136,17 @@ namespace ams::erpt::srv { } } - ErrorReportServiceManager g_erpt_server_manager; + constinit util::TypedStorage g_erpt_server_manager; } Result InitializeService() { - return g_erpt_server_manager.Initialize(); + util::ConstructAt(g_erpt_server_manager); + return util::GetReference(g_erpt_server_manager).Initialize(); } void WaitService() { - return g_erpt_server_manager.Wait(); + return util::GetReference(g_erpt_server_manager).Wait(); } } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp index e203a5ee6..1ac43a0d8 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.cpp @@ -50,7 +50,7 @@ namespace ams::erpt::srv { return fs::GetFileSize(out, file); } - Stream::Stream() : buffer_size(0), file_position(0), buffer_count(0), buffer(nullptr), stream_mode(StreamMode_Invalid), initialized(false) { + Stream::Stream() : m_buffer_size(0), m_file_position(0), m_buffer_count(0), m_buffer(nullptr), m_stream_mode(StreamMode_Invalid), m_initialized(false) { /* ... */ } @@ -60,8 +60,8 @@ namespace ams::erpt::srv { } Result Stream::OpenStream(const char *path, StreamMode mode, u32 buffer_size) { - R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); - R_UNLESS(!this->initialized, erpt::ResultAlreadyInitialized()); + R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); + R_UNLESS(!m_initialized, erpt::ResultAlreadyInitialized()); auto lock_guard = SCOPE_GUARD { if (s_fs_commit_mutex.IsLockedByCurrentThread()) { @@ -73,7 +73,7 @@ namespace ams::erpt::srv { s_fs_commit_mutex.Lock(); while (true) { - R_TRY_CATCH(fs::OpenFile(std::addressof(this->file_handle), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)) { + R_TRY_CATCH(fs::OpenFile(std::addressof(m_file_handle), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)) { R_CATCH(fs::ResultPathNotFound) { R_TRY(fs::CreateFile(path, 0)); continue; @@ -81,31 +81,31 @@ namespace ams::erpt::srv { } R_END_TRY_CATCH; break; } - fs::SetFileSize(this->file_handle, 0); + fs::SetFileSize(m_file_handle, 0); } else { R_UNLESS(mode == StreamMode_Read, erpt::ResultInvalidArgument()); - R_TRY(fs::OpenFile(std::addressof(this->file_handle), path, fs::OpenMode_Read)); + R_TRY(fs::OpenFile(std::addressof(m_file_handle), path, fs::OpenMode_Read)); } - auto file_guard = SCOPE_GUARD { fs::CloseFile(this->file_handle); }; + auto file_guard = SCOPE_GUARD { fs::CloseFile(m_file_handle); }; - std::strncpy(this->file_name, path, sizeof(this->file_name)); - this->file_name[sizeof(this->file_name) - 1] = '\x00'; + std::strncpy(m_file_name, path, sizeof(m_file_name)); + m_file_name[sizeof(m_file_name) - 1] = '\x00'; if (buffer_size > 0) { - this->buffer = reinterpret_cast(Allocate(buffer_size)); - AMS_ASSERT(this->buffer != nullptr); + m_buffer = reinterpret_cast(Allocate(buffer_size)); + AMS_ASSERT(m_buffer != nullptr); } else { - this->buffer = nullptr; + m_buffer = nullptr; } - this->buffer_size = this->buffer != nullptr ? buffer_size : 0; - this->buffer_count = 0; - this->buffer_position = 0; - this->file_position = 0; - this->stream_mode = mode; - this->initialized = true; + m_buffer_size = m_buffer != nullptr ? buffer_size : 0; + m_buffer_count = 0; + m_buffer_position = 0; + m_file_position = 0; + m_stream_mode = mode; + m_initialized = true; file_guard.Cancel(); lock_guard.Cancel(); @@ -113,11 +113,11 @@ namespace ams::erpt::srv { } Result Stream::ReadStream(u32 *out, u8 *dst, u32 dst_size) { - R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); - R_UNLESS(this->initialized, erpt::ResultNotInitialized()); - R_UNLESS(this->stream_mode == StreamMode_Read, erpt::ResultNotInitialized()); - R_UNLESS(out != nullptr, erpt::ResultInvalidArgument()); - R_UNLESS(dst != nullptr, erpt::ResultInvalidArgument()); + R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); + R_UNLESS(m_initialized, erpt::ResultNotInitialized()); + R_UNLESS(m_stream_mode == StreamMode_Read, erpt::ResultNotInitialized()); + R_UNLESS(out != nullptr, erpt::ResultInvalidArgument()); + R_UNLESS(dst != nullptr, erpt::ResultInvalidArgument()); size_t fs_read_size; u32 read_count = 0; @@ -126,30 +126,30 @@ namespace ams::erpt::srv { *out = read_count; }; - if (this->buffer != nullptr) { + if (m_buffer != nullptr) { while (dst_size > 0) { - if (u32 cur = std::min(this->buffer_count - this->buffer_position, dst_size); cur > 0) { - std::memcpy(dst, this->buffer + this->buffer_position, cur); - this->buffer_position += cur; - dst += cur; - dst_size -= cur; - read_count += cur; + if (u32 cur = std::min(m_buffer_count - m_buffer_position, dst_size); cur > 0) { + std::memcpy(dst, m_buffer + m_buffer_position, cur); + m_buffer_position += cur; + dst += cur; + dst_size -= cur; + read_count += cur; } else { - R_TRY(fs::ReadFile(std::addressof(fs_read_size), this->file_handle, this->file_position, this->buffer, this->buffer_size)); + R_TRY(fs::ReadFile(std::addressof(fs_read_size), m_file_handle, m_file_position, m_buffer, m_buffer_size)); - this->buffer_position = 0; - this->file_position += static_cast(fs_read_size); - this->buffer_count = static_cast(fs_read_size); + m_buffer_position = 0; + m_file_position += static_cast(fs_read_size); + m_buffer_count = static_cast(fs_read_size); - if (this->buffer_count == 0) { + if (m_buffer_count == 0) { break; } } } } else { - R_TRY(fs::ReadFile(std::addressof(fs_read_size), this->file_handle, this->file_position, dst, dst_size)); + R_TRY(fs::ReadFile(std::addressof(fs_read_size), m_file_handle, m_file_position, dst, dst_size)); - this->file_position += static_cast(fs_read_size); + m_file_position += static_cast(fs_read_size); read_count = static_cast(fs_read_size); } @@ -157,47 +157,47 @@ namespace ams::erpt::srv { } Result Stream::WriteStream(const u8 *src, u32 src_size) { - R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); - R_UNLESS(this->initialized, erpt::ResultNotInitialized()); - R_UNLESS(this->stream_mode == StreamMode_Write, erpt::ResultNotInitialized()); - R_UNLESS(src != nullptr || src_size == 0, erpt::ResultInvalidArgument()); + R_UNLESS(s_can_access_fs, erpt::ResultInvalidPowerState()); + R_UNLESS(m_initialized, erpt::ResultNotInitialized()); + R_UNLESS(m_stream_mode == StreamMode_Write, erpt::ResultNotInitialized()); + R_UNLESS(src != nullptr || src_size == 0, erpt::ResultInvalidArgument()); - if (this->buffer != nullptr) { + if (m_buffer != nullptr) { while (src_size > 0) { - if (u32 cur = std::min(this->buffer_size - this->buffer_count, src_size); cur > 0) { - std::memcpy(this->buffer + this->buffer_count, src, cur); - this->buffer_count += cur; - src += cur; - src_size -= cur; + if (u32 cur = std::min(m_buffer_size - m_buffer_count, src_size); cur > 0) { + std::memcpy(m_buffer + m_buffer_count, src, cur); + m_buffer_count += cur; + src += cur; + src_size -= cur; } - if (this->buffer_count == this->buffer_size) { + if (m_buffer_count == m_buffer_size) { R_TRY(this->Flush()); } } } else { - R_TRY(fs::WriteFile(this->file_handle, this->file_position, src, src_size, fs::WriteOption::None)); - this->file_position += src_size; + R_TRY(fs::WriteFile(m_file_handle, m_file_position, src, src_size, fs::WriteOption::None)); + m_file_position += src_size; } return ResultSuccess(); } void Stream::CloseStream() { - if (this->initialized) { + if (m_initialized) { if (s_can_access_fs) { - if (this->stream_mode == StreamMode_Write) { + if (m_stream_mode == StreamMode_Write) { this->Flush(); - fs::FlushFile(this->file_handle); + fs::FlushFile(m_file_handle); } - fs::CloseFile(this->file_handle); + fs::CloseFile(m_file_handle); } - if (this->buffer != nullptr) { - Deallocate(this->buffer); + if (m_buffer != nullptr) { + Deallocate(m_buffer); } - this->initialized = false; + m_initialized = false; if (s_fs_commit_mutex.IsLockedByCurrentThread()) { s_fs_commit_mutex.Unlock(); @@ -206,17 +206,17 @@ namespace ams::erpt::srv { } Result Stream::GetStreamSize(s64 *out) const { - return GetStreamSize(out, this->file_name); + return GetStreamSize(out, m_file_name); } Result Stream::Flush() { AMS_ASSERT(s_fs_commit_mutex.IsLockedByCurrentThread()); - R_SUCCEED_IF(this->buffer_count == 0); - R_TRY(fs::WriteFile(this->file_handle, this->file_position, this->buffer, this->buffer_count, fs::WriteOption::None)); + R_SUCCEED_IF(m_buffer_count == 0); + R_TRY(fs::WriteFile(m_file_handle, m_file_position, m_buffer, m_buffer_count, fs::WriteOption::None)); - this->file_position += this->buffer_count; - this->buffer_count = 0; + m_file_position += m_buffer_count; + m_buffer_count = 0; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.hpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.hpp index 6f2f03024..cd0975f3d 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.hpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_stream.hpp @@ -29,15 +29,15 @@ namespace ams::erpt::srv { static bool s_can_access_fs; static os::SdkMutex s_fs_commit_mutex; private: - u32 buffer_size; - u32 file_position; - u32 buffer_position; - u32 buffer_count; - u8 *buffer; - StreamMode stream_mode; - bool initialized; - fs::FileHandle file_handle; - char file_name[ReportFileNameLength]; + u32 m_buffer_size; + u32 m_file_position; + u32 m_buffer_position; + u32 m_buffer_count; + u8 *m_buffer; + StreamMode m_stream_mode; + bool m_initialized; + fs::FileHandle m_file_handle; + char m_file_name[ReportFileNameLength]; public: Stream(); ~Stream(); diff --git a/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp b/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp index 86d4867d2..d0df24ccd 100644 --- a/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_dbm_hierarchical_rom_file_table.cpp @@ -50,18 +50,18 @@ namespace ams::fs { Result HierarchicalRomFileTable::Initialize(SubStorage dir_bucket, SubStorage dir_entry, SubStorage file_bucket, SubStorage file_entry) { s64 dir_bucket_size; R_TRY(dir_bucket.GetSize(std::addressof(dir_bucket_size))); - R_TRY(this->dir_table.Initialize(dir_bucket, DirectoryEntryMapTable::QueryBucketCount(dir_bucket_size), dir_entry)); + R_TRY(m_dir_table.Initialize(dir_bucket, DirectoryEntryMapTable::QueryBucketCount(dir_bucket_size), dir_entry)); s64 file_bucket_size; R_TRY(file_bucket.GetSize(std::addressof(file_bucket_size))); - R_TRY(this->file_table.Initialize(file_bucket, FileEntryMapTable::QueryBucketCount(file_bucket_size), file_entry)); + R_TRY(m_file_table.Initialize(file_bucket, FileEntryMapTable::QueryBucketCount(file_bucket_size), file_entry)); return ResultSuccess(); } void HierarchicalRomFileTable::Finalize() { - this->dir_table.Finalize(); - this->file_table.Finalize(); + m_dir_table.Finalize(); + m_file_table.Finalize(); } Result HierarchicalRomFileTable::CreateRootDirectory() { @@ -74,7 +74,7 @@ namespace ams::fs { .dir = InvalidPosition, .file = InvalidPosition, }; - return this->dir_table.Add(std::addressof(root_pos), root_key, root_entry); + return m_dir_table.Add(std::addressof(root_pos), root_key, root_entry); } Result HierarchicalRomFileTable::CreateDirectory(RomDirectoryId *out, const RomPathChar *path, const DirectoryInfo &info) { @@ -95,7 +95,7 @@ namespace ams::fs { AMS_UNUSED(info); Position new_pos = 0; - R_TRY_CATCH(this->dir_table.Add(std::addressof(new_pos), new_key, new_entry)) { + R_TRY_CATCH(m_dir_table.Add(std::addressof(new_pos), new_key, new_entry)) { R_CONVERT(fs::ResultDbmKeyFull, fs::ResultDbmDirectoryEntryFull()) } R_END_TRY_CATCH; @@ -104,18 +104,18 @@ namespace ams::fs { if (parent_entry.dir == InvalidPosition) { parent_entry.dir = new_pos; - R_TRY(this->dir_table.SetByPosition(new_key.key.parent, parent_entry)); + R_TRY(m_dir_table.SetByPosition(new_key.key.parent, parent_entry)); } else { Position cur_pos = parent_entry.dir; while (true) { RomEntryKey cur_key = {}; RomDirectoryEntry cur_entry = {}; - R_TRY(this->dir_table.GetByPosition(std::addressof(cur_key), std::addressof(cur_entry), cur_pos)); + R_TRY(m_dir_table.GetByPosition(std::addressof(cur_key), std::addressof(cur_entry), cur_pos)); if (cur_entry.next == InvalidPosition) { cur_entry.next = new_pos; - R_TRY(this->dir_table.SetByPosition(cur_pos, cur_entry)); + R_TRY(m_dir_table.SetByPosition(cur_pos, cur_entry)); break; } @@ -142,7 +142,7 @@ namespace ams::fs { }; Position new_pos = 0; - R_TRY_CATCH(this->file_table.Add(std::addressof(new_pos), new_key, new_entry)) { + R_TRY_CATCH(m_file_table.Add(std::addressof(new_pos), new_key, new_entry)) { R_CONVERT(fs::ResultDbmKeyFull, fs::ResultDbmFileEntryFull()) } R_END_TRY_CATCH; @@ -151,18 +151,18 @@ namespace ams::fs { if (parent_entry.file == InvalidPosition) { parent_entry.file = new_pos; - R_TRY(this->dir_table.SetByPosition(new_key.key.parent, parent_entry)); + R_TRY(m_dir_table.SetByPosition(new_key.key.parent, parent_entry)); } else { Position cur_pos = parent_entry.file; while (true) { RomEntryKey cur_key = {}; RomFileEntry cur_entry = {}; - R_TRY(this->file_table.GetByPosition(std::addressof(cur_key), std::addressof(cur_entry), cur_pos)); + R_TRY(m_file_table.GetByPosition(std::addressof(cur_key), std::addressof(cur_entry), cur_pos)); if (cur_entry.next == InvalidPosition) { cur_entry.next = new_pos; - R_TRY(this->file_table.SetByPosition(cur_pos, cur_entry)); + R_TRY(m_file_table.SetByPosition(cur_pos, cur_entry)); break; } @@ -285,7 +285,7 @@ namespace ams::fs { RomEntryKey key = {}; RomDirectoryEntry entry = {}; size_t aux_size = 0; - R_TRY(this->dir_table.GetByPosition(std::addressof(key), std::addressof(entry), out, std::addressof(aux_size), find->next_dir)); + R_TRY(m_dir_table.GetByPosition(std::addressof(key), std::addressof(entry), out, std::addressof(aux_size), find->next_dir)); AMS_ASSERT(aux_size / sizeof(RomPathChar) <= RomPathTool::MaxPathLength); out[aux_size / sizeof(RomPathChar)] = RomStringTraits::NullTerminator; @@ -305,7 +305,7 @@ namespace ams::fs { RomEntryKey key = {}; RomFileEntry entry = {}; size_t aux_size = 0; - R_TRY(this->file_table.GetByPosition(std::addressof(key), std::addressof(entry), out, std::addressof(aux_size), find->next_file)); + R_TRY(m_file_table.GetByPosition(std::addressof(key), std::addressof(entry), out, std::addressof(aux_size), find->next_file)); AMS_ASSERT(aux_size / sizeof(RomPathChar) <= RomPathTool::MaxPathLength); out[aux_size / sizeof(RomPathChar)] = RomStringTraits::NullTerminator; @@ -318,8 +318,8 @@ namespace ams::fs { AMS_ASSERT(out_dir_entry_size != nullptr); AMS_ASSERT(out_file_entry_size != nullptr); - *out_dir_entry_size = this->dir_table.GetTotalEntrySize(); - *out_file_entry_size = this->file_table.GetTotalEntrySize(); + *out_dir_entry_size = m_dir_table.GetTotalEntrySize(); + *out_file_entry_size = m_file_table.GetTotalEntrySize(); return ResultSuccess(); } @@ -331,7 +331,7 @@ namespace ams::fs { RomEntryKey gp_key = {}; RomDirectoryEntry gp_entry = {}; - R_TRY(this->dir_table.GetByPosition(std::addressof(gp_key), std::addressof(gp_entry), pos)); + R_TRY(m_dir_table.GetByPosition(std::addressof(gp_key), std::addressof(gp_entry), pos)); out_dir_key->key.parent = gp_key.parent; R_TRY(RomPathTool::GetParentDirectoryName(std::addressof(out_dir_key->name), name, path)); @@ -458,7 +458,7 @@ namespace ams::fs { { Position pos = InvalidPosition; RomDirectoryEntry entry = {}; - const Result get_res = this->dir_table.Get(std::addressof(pos), std::addressof(entry), key); + const Result get_res = m_dir_table.Get(std::addressof(pos), std::addressof(entry), key); if (!fs::ResultDbmKeyNotFound::Includes(get_res)) { R_TRY(get_res); return if_exists; @@ -469,7 +469,7 @@ namespace ams::fs { { Position pos = InvalidPosition; RomFileEntry entry = {}; - const Result get_res = this->file_table.Get(std::addressof(pos), std::addressof(entry), key); + const Result get_res = m_file_table.Get(std::addressof(pos), std::addressof(entry), key); if (!fs::ResultDbmKeyNotFound::Includes(get_res)) { R_TRY(get_res); return if_exists; @@ -482,13 +482,13 @@ namespace ams::fs { AMS_ASSERT(out_pos != nullptr); AMS_ASSERT(out_entry != nullptr); - const Result dir_res = this->dir_table.Get(out_pos, out_entry, key); + const Result dir_res = m_dir_table.Get(out_pos, out_entry, key); R_UNLESS(R_FAILED(dir_res), dir_res); R_UNLESS(fs::ResultDbmKeyNotFound::Includes(dir_res), dir_res); Position pos = 0; RomFileEntry entry = {}; - const Result file_res = this->file_table.Get(std::addressof(pos), std::addressof(entry), key); + const Result file_res = m_file_table.Get(std::addressof(pos), std::addressof(entry), key); R_UNLESS(R_FAILED(file_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(file_res), fs::ResultDbmDirectoryNotFound()); return file_res; @@ -499,12 +499,12 @@ namespace ams::fs { Position pos = DirectoryIdToPosition(id); RomEntryKey key = {}; - const Result dir_res = this->dir_table.GetByPosition(std::addressof(key), out_entry, pos); + const Result dir_res = m_dir_table.GetByPosition(std::addressof(key), out_entry, pos); R_UNLESS(R_FAILED(dir_res), dir_res); R_UNLESS(fs::ResultDbmKeyNotFound::Includes(dir_res), dir_res); RomFileEntry entry = {}; - const Result file_res = this->file_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); + const Result file_res = m_file_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); R_UNLESS(R_FAILED(file_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(file_res), fs::ResultDbmDirectoryNotFound()); return file_res; @@ -514,13 +514,13 @@ namespace ams::fs { AMS_ASSERT(out_pos != nullptr); AMS_ASSERT(out_entry != nullptr); - const Result file_res = this->file_table.Get(out_pos, out_entry, key); + const Result file_res = m_file_table.Get(out_pos, out_entry, key); R_UNLESS(R_FAILED(file_res), file_res); R_UNLESS(fs::ResultDbmKeyNotFound::Includes(file_res), file_res); Position pos = 0; RomDirectoryEntry entry = {}; - const Result dir_res = this->dir_table.Get(std::addressof(pos), std::addressof(entry), key); + const Result dir_res = m_dir_table.Get(std::addressof(pos), std::addressof(entry), key); R_UNLESS(R_FAILED(dir_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(dir_res), fs::ResultDbmFileNotFound()); return dir_res; @@ -531,12 +531,12 @@ namespace ams::fs { Position pos = FileIdToPosition(id); RomEntryKey key = {}; - const Result file_res = this->file_table.GetByPosition(std::addressof(key), out_entry, pos); + const Result file_res = m_file_table.GetByPosition(std::addressof(key), out_entry, pos); R_UNLESS(R_FAILED(file_res), file_res); R_UNLESS(fs::ResultDbmKeyNotFound::Includes(file_res), file_res); RomDirectoryEntry entry = {}; - const Result dir_res = this->dir_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); + const Result dir_res = m_dir_table.GetByPosition(std::addressof(key), std::addressof(entry), pos); R_UNLESS(R_FAILED(dir_res), fs::ResultDbmInvalidOperation()); R_UNLESS(!fs::ResultDbmKeyNotFound::Includes(dir_res), fs::ResultDbmFileNotFound()); return dir_res; diff --git a/libraries/libstratosphere/source/fs/common/fs_dbm_rom_path_tool.cpp b/libraries/libstratosphere/source/fs/common/fs_dbm_rom_path_tool.cpp index 8ac52a920..d665d4afe 100644 --- a/libraries/libstratosphere/source/fs/common/fs_dbm_rom_path_tool.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_dbm_rom_path_tool.cpp @@ -26,9 +26,9 @@ namespace ams::fs::RomPathTool { path++; } - this->prev_path_start = path; - this->prev_path_end = path; - for (this->next_path = path + 1; IsSeparator(this->next_path[0]); ++this->next_path) { + m_prev_path_start = path; + m_prev_path_end = path; + for (m_next_path = path + 1; IsSeparator(m_next_path[0]); ++m_next_path) { /* ... */ } @@ -36,63 +36,63 @@ namespace ams::fs::RomPathTool { } void PathParser::Finalize() { - this->prev_path_start = nullptr; - this->prev_path_end = nullptr; - this->next_path = nullptr; - this->finished = false; + m_prev_path_start = nullptr; + m_prev_path_end = nullptr; + m_next_path = nullptr; + m_finished = false; } bool PathParser::IsParseFinished() const { - return this->finished; + return m_finished; } bool PathParser::IsDirectoryPath() const { - AMS_ASSERT(this->next_path != nullptr); + AMS_ASSERT(m_next_path != nullptr); - if (IsNullTerminator(this->next_path[0]) && IsSeparator(this->next_path[-1])) { + if (IsNullTerminator(m_next_path[0]) && IsSeparator(m_next_path[-1])) { return true; } - if (IsCurrentDirectory(this->next_path)) { + if (IsCurrentDirectory(m_next_path)) { return true; } - return IsParentDirectory(this->next_path); + return IsParentDirectory(m_next_path); } Result PathParser::GetNextDirectoryName(RomEntryName *out) { AMS_ASSERT(out != nullptr); - AMS_ASSERT(this->prev_path_start != nullptr); - AMS_ASSERT(this->prev_path_end != nullptr); - AMS_ASSERT(this->next_path != nullptr); + AMS_ASSERT(m_prev_path_start != nullptr); + AMS_ASSERT(m_prev_path_end != nullptr); + AMS_ASSERT(m_next_path != nullptr); /* Set the current path to output. */ - out->length = this->prev_path_end - this->prev_path_start; - out->path = this->prev_path_start; + out->length = m_prev_path_end - m_prev_path_start; + out->path = m_prev_path_start; /* Parse the next path. */ - this->prev_path_start = this->next_path; - const RomPathChar *cur = this->next_path; + m_prev_path_start = m_next_path; + const RomPathChar *cur = m_next_path; for (size_t name_len = 0; true; name_len++) { if (IsSeparator(cur[name_len])) { R_UNLESS(name_len < MaxPathLength, fs::ResultDbmDirectoryNameTooLong()); - this->prev_path_end = cur + name_len; - this->next_path = this->prev_path_end + 1; + m_prev_path_end = cur + name_len; + m_next_path = m_prev_path_end + 1; - while (IsSeparator(this->next_path[0])) { - ++this->next_path; + while (IsSeparator(m_next_path[0])) { + ++m_next_path; } - if (IsNullTerminator(this->next_path[0])) { - this->finished = true; + if (IsNullTerminator(m_next_path[0])) { + m_finished = true; } break; } if (IsNullTerminator(cur[name_len])) { - this->finished = true; - this->next_path = cur + name_len; - this->prev_path_end = cur + name_len; + m_finished = true; + m_next_path = cur + name_len; + m_prev_path_end = cur + name_len; break; } } @@ -102,29 +102,29 @@ namespace ams::fs::RomPathTool { Result PathParser::GetAsDirectoryName(RomEntryName *out) const { AMS_ASSERT(out != nullptr); - AMS_ASSERT(this->prev_path_start != nullptr); - AMS_ASSERT(this->prev_path_end != nullptr); - AMS_ASSERT(this->next_path != nullptr); + AMS_ASSERT(m_prev_path_start != nullptr); + AMS_ASSERT(m_prev_path_end != nullptr); + AMS_ASSERT(m_next_path != nullptr); - const size_t len = this->prev_path_end - this->prev_path_start; + const size_t len = m_prev_path_end - m_prev_path_start; R_UNLESS(len <= MaxPathLength, fs::ResultDbmDirectoryNameTooLong()); out->length = len; - out->path = this->prev_path_start; + out->path = m_prev_path_start; return ResultSuccess(); } Result PathParser::GetAsFileName(RomEntryName *out) const { AMS_ASSERT(out != nullptr); - AMS_ASSERT(this->prev_path_start != nullptr); - AMS_ASSERT(this->prev_path_end != nullptr); - AMS_ASSERT(this->next_path != nullptr); + AMS_ASSERT(m_prev_path_start != nullptr); + AMS_ASSERT(m_prev_path_end != nullptr); + AMS_ASSERT(m_next_path != nullptr); - const size_t len = this->prev_path_end - this->prev_path_start; + const size_t len = m_prev_path_end - m_prev_path_start; R_UNLESS(len <= MaxPathLength, fs::ResultDbmFileNameTooLong()); out->length = len; - out->path = this->prev_path_start; + out->path = m_prev_path_start; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp index f7ebcc38e..c4426b224 100644 --- a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp @@ -18,8 +18,8 @@ namespace ams::fs { Result FileStorage::UpdateSize() { - R_SUCCEED_IF(this->size != InvalidSize); - return this->base_file->GetSize(std::addressof(this->size)); + R_SUCCEED_IF(m_size != InvalidSize); + return m_base_file->GetSize(std::addressof(m_size)); } Result FileStorage::Read(s64 offset, void *buffer, size_t size) { @@ -33,10 +33,10 @@ namespace ams::fs { R_TRY(this->UpdateSize()); /* Ensure our access is valid. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); size_t read_size; - return this->base_file->Read(std::addressof(read_size), offset, buffer, size); + return m_base_file->Read(std::addressof(read_size), offset, buffer, size); } Result FileStorage::Write(s64 offset, const void *buffer, size_t size) { @@ -50,24 +50,24 @@ namespace ams::fs { R_TRY(this->UpdateSize()); /* Ensure our access is valid. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); - return this->base_file->Write(offset, buffer, size, fs::WriteOption()); + return m_base_file->Write(offset, buffer, size, fs::WriteOption()); } Result FileStorage::Flush() { - return this->base_file->Flush(); + return m_base_file->Flush(); } Result FileStorage::GetSize(s64 *out_size) { R_TRY(this->UpdateSize()); - *out_size = this->size; + *out_size = m_size; return ResultSuccess(); } Result FileStorage::SetSize(s64 size) { - this->size = InvalidSize; - return this->base_file->SetSize(size); + m_size = InvalidSize; + return m_base_file->SetSize(size); } Result FileStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -84,7 +84,7 @@ namespace ams::fs { } R_TRY(this->UpdateSize()); R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange()); - return this->base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); default: return fs::ResultUnsupportedOperationInFileStorageA(); } @@ -97,19 +97,19 @@ namespace ams::fs { /* Set the file. */ this->SetFile(std::move(base_file)); - this->base_file_system = std::move(base_file_system); + m_base_file_system = std::move(base_file_system); return ResultSuccess(); } Result FileHandleStorage::UpdateSize() { - R_SUCCEED_IF(this->size != InvalidSize); - return GetFileSize(std::addressof(this->size), this->handle); + R_SUCCEED_IF(m_size != InvalidSize); + return GetFileSize(std::addressof(m_size), m_handle); } Result FileHandleStorage::Read(s64 offset, void *buffer, size_t size) { /* Lock the mutex. */ - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Immediately succeed if there's nothing to read. */ R_SUCCEED_IF(size == 0); @@ -121,14 +121,14 @@ namespace ams::fs { R_TRY(this->UpdateSize()); /* Ensure our access is valid. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); - return ReadFile(this->handle, offset, buffer, size, fs::ReadOption()); + return ReadFile(m_handle, offset, buffer, size, fs::ReadOption()); } Result FileHandleStorage::Write(s64 offset, const void *buffer, size_t size) { /* Lock the mutex. */ - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Immediately succeed if there's nothing to write. */ R_SUCCEED_IF(size == 0); @@ -140,24 +140,24 @@ namespace ams::fs { R_TRY(this->UpdateSize()); /* Ensure our access is valid. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange()); - return WriteFile(this->handle, offset, buffer, size, fs::WriteOption()); + return WriteFile(m_handle, offset, buffer, size, fs::WriteOption()); } Result FileHandleStorage::Flush() { - return FlushFile(this->handle); + return FlushFile(m_handle); } Result FileHandleStorage::GetSize(s64 *out_size) { R_TRY(this->UpdateSize()); - *out_size = this->size; + *out_size = m_size; return ResultSuccess(); } Result FileHandleStorage::SetSize(s64 size) { - this->size = InvalidSize; - return SetFileSize(this->handle, size); + m_size = InvalidSize; + return SetFileSize(m_handle, size); } Result FileHandleStorage::OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -169,7 +169,7 @@ namespace ams::fs { R_UNLESS(dst != nullptr, fs::ResultNullptrArgument()); R_UNLESS(dst_size == sizeof(QueryRangeInfo), fs::ResultInvalidSize()); - return QueryRange(static_cast(dst), this->handle, offset, size); + return QueryRange(static_cast(dst), m_handle, offset, size); default: return fs::ResultUnsupportedOperationInFileStorageB(); } diff --git a/libraries/libstratosphere/source/fs/fs_access_log.cpp b/libraries/libstratosphere/source/fs/fs_access_log.cpp index c0602854c..981e33f1f 100644 --- a/libraries/libstratosphere/source/fs/fs_access_log.cpp +++ b/libraries/libstratosphere/source/fs/fs_access_log.cpp @@ -82,10 +82,10 @@ namespace ams::fs { namespace ams::fs::impl { const char *IdString::ToValueString(int id) { - const int len = util::SNPrintf(this->buffer, sizeof(this->buffer), "%d", id); - AMS_ASSERT(static_cast(len) < sizeof(this->buffer)); + const int len = util::SNPrintf(m_buffer, sizeof(m_buffer), "%d", id); + AMS_ASSERT(static_cast(len) < sizeof(m_buffer)); AMS_UNUSED(len); - return this->buffer; + return m_buffer; } template<> const char *IdString::ToString(fs::Priority id) { @@ -171,20 +171,20 @@ namespace ams::fs::impl { class AccessLogPrinterCallbackManager { private: - AccessLogPrinterCallback callback; + AccessLogPrinterCallback m_callback; public: - constexpr AccessLogPrinterCallbackManager() : callback(nullptr) { /* ... */ } + constexpr AccessLogPrinterCallbackManager() : m_callback(nullptr) { /* ... */ } - constexpr bool IsRegisteredCallback() const { return this->callback != nullptr; } + constexpr bool IsRegisteredCallback() const { return m_callback != nullptr; } constexpr void RegisterCallback(AccessLogPrinterCallback c) { - AMS_ASSERT(this->callback == nullptr); - this->callback = c; + AMS_ASSERT(m_callback == nullptr); + m_callback = c; } constexpr int InvokeCallback(char *buf, size_t size) const { - AMS_ASSERT(this->callback != nullptr); - return this->callback(buf, size); + AMS_ASSERT(m_callback != nullptr); + return m_callback(buf, size); } }; diff --git a/libraries/libstratosphere/source/fs/fs_bis.cpp b/libraries/libstratosphere/source/fs/fs_bis.cpp index 4ae441bb3..8073d9cd1 100644 --- a/libraries/libstratosphere/source/fs/fs_bis.cpp +++ b/libraries/libstratosphere/source/fs/fs_bis.cpp @@ -22,13 +22,13 @@ namespace ams::fs { class BisCommonMountNameGenerator : public fsa::ICommonMountNameGenerator, public impl::Newable { private: - const BisPartitionId id; + const BisPartitionId m_id; public: - explicit BisCommonMountNameGenerator(BisPartitionId i) : id(i) { /* ... */ } + explicit BisCommonMountNameGenerator(BisPartitionId i) : m_id(i) { /* ... */ } virtual Result GenerateCommonMountName(char *dst, size_t dst_size) override { /* Determine how much space we need. */ - const char *bis_mount_name = GetBisMountName(this->id); + const char *bis_mount_name = GetBisMountName(m_id); const size_t needed_size = util::Strnlen(bis_mount_name, MountNameLengthMax) + 2; AMS_ABORT_UNLESS(dst_size >= needed_size); diff --git a/libraries/libstratosphere/source/fs/fs_code.cpp b/libraries/libstratosphere/source/fs/fs_code.cpp index d9a671dbe..81c146d02 100644 --- a/libraries/libstratosphere/source/fs/fs_code.cpp +++ b/libraries/libstratosphere/source/fs/fs_code.cpp @@ -251,11 +251,11 @@ namespace ams::fs { class SdCardRedirectionCodeFileSystem : public OpenFileOnlyFileSystem { private: - util::optional sd_content_fs; - ReadOnlyFileSystem code_fs; - bool is_redirect; + util::optional m_sd_content_fs; + ReadOnlyFileSystem m_code_fs; + bool m_is_redirect; public: - SdCardRedirectionCodeFileSystem(std::unique_ptr &&code, ncm::ProgramId program_id, bool redirect) : code_fs(std::move(code)), is_redirect(redirect) { + SdCardRedirectionCodeFileSystem(std::unique_ptr &&code, ncm::ProgramId program_id, bool redirect) : m_code_fs(std::move(code)), m_is_redirect(redirect) { if (!cfg::IsSdCardInitialized()) { return; } @@ -275,12 +275,12 @@ namespace ams::fs { return; } - sd_content_fs.emplace(std::move(subdir_fs)); + m_sd_content_fs.emplace(std::move(subdir_fs)); } private: bool IsFileStubbed(const char *path) { /* If we don't have an sd content fs, nothing is stubbed. */ - if (!this->sd_content_fs) { + if (!m_sd_content_fs) { return false; } @@ -290,7 +290,7 @@ namespace ams::fs { /* Query whether we have the file. */ bool has_file; - if (R_FAILED(fssystem::HasFile(std::addressof(has_file), std::addressof(*this->sd_content_fs), stub_path))) { + if (R_FAILED(fssystem::HasFile(std::addressof(has_file), std::addressof(*m_sd_content_fs), stub_path))) { return false; } @@ -302,70 +302,70 @@ namespace ams::fs { R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode()); /* If we support redirection, we'd like to prefer a file from the sd card. */ - if (this->is_redirect) { - R_SUCCEED_IF(R_SUCCEEDED(this->sd_content_fs->OpenFile(out_file, path, mode))); + if (m_is_redirect) { + R_SUCCEED_IF(R_SUCCEEDED(m_sd_content_fs->OpenFile(out_file, path, mode))); } /* Otherwise, check if the file is stubbed. */ R_UNLESS(!this->IsFileStubbed(path), fs::ResultPathNotFound()); /* Open a file from the base code fs. */ - return this->code_fs.OpenFile(out_file, path, mode); + return m_code_fs.OpenFile(out_file, path, mode); } }; class AtmosphereCodeFileSystem : public OpenFileOnlyFileSystem { private: - util::optional code_fs; - util::optional hbl_fs; - ncm::ProgramId program_id; - bool initialized; + util::optional m_code_fs; + util::optional m_hbl_fs; + ncm::ProgramId m_program_id; + bool m_initialized; public: - AtmosphereCodeFileSystem() : initialized(false) { /* ... */ } + AtmosphereCodeFileSystem() : m_initialized(false) { /* ... */ } Result Initialize(CodeVerificationData *out_verification_data, const char *path, ncm::ProgramId program_id, bool is_hbl, bool is_specific) { - AMS_ABORT_UNLESS(!this->initialized); + AMS_ABORT_UNLESS(!m_initialized); /* If we're hbl, we need to open a hbl fs. */ if (is_hbl) { std::unique_ptr fsa; R_TRY(OpenHblCodeFileSystemImpl(std::addressof(fsa))); - this->hbl_fs.emplace(std::move(fsa)); + m_hbl_fs.emplace(std::move(fsa)); } /* Open the code filesystem. */ std::unique_ptr fsa; R_TRY(OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(out_verification_data, std::addressof(fsa), path, program_id)); - this->code_fs.emplace(std::move(fsa), program_id, is_specific); + m_code_fs.emplace(std::move(fsa), program_id, is_specific); - this->program_id = program_id; - this->initialized = true; + m_program_id = program_id; + m_initialized = true; return ResultSuccess(); } private: virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, OpenMode mode) override final { /* Ensure that we're initialized. */ - R_UNLESS(this->initialized, fs::ResultNotInitialized()); + R_UNLESS(m_initialized, fs::ResultNotInitialized()); /* Only allow opening files with mode = read. */ R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode()); /* First, check if there's an external code. */ { - fsa::IFileSystem *ecs = fssystem::GetExternalCodeFileSystem(this->program_id); + fsa::IFileSystem *ecs = fssystem::GetExternalCodeFileSystem(m_program_id); if (ecs != nullptr) { return ecs->OpenFile(out_file, path, mode); } } /* If we're hbl, open from the hbl fs. */ - if (this->hbl_fs) { - return this->hbl_fs->OpenFile(out_file, path, mode); + if (m_hbl_fs) { + return m_hbl_fs->OpenFile(out_file, path, mode); } /* If we're not hbl, fall back to our code filesystem. */ - return this->code_fs->OpenFile(out_file, path, mode); + return m_code_fs->OpenFile(out_file, path, mode); } }; diff --git a/libraries/libstratosphere/source/fs/fs_context.cpp b/libraries/libstratosphere/source/fs/fs_context.cpp index 338478a7e..3cc28ab83 100644 --- a/libraries/libstratosphere/source/fs/fs_context.cpp +++ b/libraries/libstratosphere/source/fs/fs_context.cpp @@ -69,7 +69,7 @@ namespace ams::fs { g_context_tls.SetValue(reinterpret_cast(context)); } - ScopedAutoAbortDisabler::ScopedAutoAbortDisabler() : prev_context(GetCurrentThreadFsContext()) { + ScopedAutoAbortDisabler::ScopedAutoAbortDisabler() : m_prev_context(GetCurrentThreadFsContext()) { SetCurrentThreadFsContext(std::addressof(g_always_return_context)); } diff --git a/libraries/libstratosphere/source/fs/fs_game_card.cpp b/libraries/libstratosphere/source/fs/fs_game_card.cpp index 0a75a326a..4a80a7931 100644 --- a/libraries/libstratosphere/source/fs/fs_game_card.cpp +++ b/libraries/libstratosphere/source/fs/fs_game_card.cpp @@ -31,18 +31,18 @@ namespace ams::fs { class GameCardCommonMountNameGenerator : public fsa::ICommonMountNameGenerator, public impl::Newable { private: - const GameCardHandle handle; - const GameCardPartition partition; + const GameCardHandle m_handle; + const GameCardPartition m_partition; public: - explicit GameCardCommonMountNameGenerator(GameCardHandle h, GameCardPartition p) : handle(h), partition(p) { /* ... */ } + explicit GameCardCommonMountNameGenerator(GameCardHandle h, GameCardPartition p) : m_handle(h), m_partition(p) { /* ... */ } virtual Result GenerateCommonMountName(char *dst, size_t dst_size) override { /* Determine how much space we need. */ - const size_t needed_size = strnlen(impl::GameCardFileSystemMountName, MountNameLengthMax) + strnlen(GetGameCardMountNameSuffix(this->partition), MountNameLengthMax) + sizeof(GameCardHandle) * 2 + 2; + const size_t needed_size = strnlen(impl::GameCardFileSystemMountName, MountNameLengthMax) + strnlen(GetGameCardMountNameSuffix(m_partition), MountNameLengthMax) + sizeof(GameCardHandle) * 2 + 2; AMS_ABORT_UNLESS(dst_size >= needed_size); /* Generate the name. */ - const auto size = util::SNPrintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(this->partition), this->handle); + const auto size = util::SNPrintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(m_partition), m_handle); AMS_ASSERT(static_cast(size) == needed_size - 1); AMS_UNUSED(size); diff --git a/libraries/libstratosphere/source/fs/fs_path_utils.cpp b/libraries/libstratosphere/source/fs/fs_path_utils.cpp index 9af6c385b..2fd86e883 100644 --- a/libraries/libstratosphere/source/fs/fs_path_utils.cpp +++ b/libraries/libstratosphere/source/fs/fs_path_utils.cpp @@ -21,14 +21,14 @@ namespace ams::fs { class PathVerifier { private: - u32 invalid_chars[6]; - u32 separators[2]; + u32 m_invalid_chars[6]; + u32 m_separators[2]; public: PathVerifier() { /* Convert all invalid characters. */ - u32 *dst_invalid = this->invalid_chars; + u32 *dst_invalid = m_invalid_chars; for (const char *cur = ":*?<>|"; *cur != '\x00'; ++cur) { - AMS_ASSERT(dst_invalid < std::end(this->invalid_chars)); + AMS_ASSERT(dst_invalid < std::end(m_invalid_chars)); const auto result = util::ConvertCharacterUtf8ToUtf32(dst_invalid, cur); AMS_ASSERT(result == util::CharacterEncodingResult_Success); @@ -36,12 +36,12 @@ namespace ams::fs { ++dst_invalid; } - AMS_ASSERT(dst_invalid == std::end(this->invalid_chars)); + AMS_ASSERT(dst_invalid == std::end(m_invalid_chars)); /* Convert all separators. */ - u32 *dst_sep = this->separators; + u32 *dst_sep = m_separators; for (const char *cur = "/\\"; *cur != '\x00'; ++cur) { - AMS_ASSERT(dst_sep < std::end(this->separators)); + AMS_ASSERT(dst_sep < std::end(m_separators)); const auto result = util::ConvertCharacterUtf8ToUtf32(dst_sep, cur); AMS_ASSERT(result == util::CharacterEncodingResult_Success); @@ -49,7 +49,7 @@ namespace ams::fs { ++dst_sep; } - AMS_ASSERT(dst_sep == std::end(this->separators)); + AMS_ASSERT(dst_sep == std::end(m_separators)); } Result Verify(const char *path, int max_path_len, int max_name_len) const { @@ -74,7 +74,7 @@ namespace ams::fs { R_UNLESS(result == util::CharacterEncodingResult_Success, fs::ResultInvalidCharacter()); /* Check if the character is invalid. */ - for (const auto invalid : this->invalid_chars) { + for (const auto invalid : m_invalid_chars) { R_UNLESS(path_char != invalid, fs::ResultInvalidCharacter()); } @@ -82,7 +82,7 @@ namespace ams::fs { ++name_len; /* Check for separator. */ - for (const auto sep : this->separators) { + for (const auto sep : m_separators) { if (path_char == sep) { name_len = 0; break; diff --git a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp index 2f8da85a4..7a222663d 100644 --- a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp +++ b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp @@ -166,11 +166,11 @@ namespace ams::fs { class RomFsFile : public fsa::IFile, public impl::Newable { private: - RomFsFileSystem *parent; - s64 start; - s64 end; + RomFsFileSystem *m_parent; + s64 m_start; + s64 m_end; public: - RomFsFile(RomFsFileSystem *p, s64 s, s64 e) : parent(p), start(s), end(e) { /* ... */ } + RomFsFile(RomFsFileSystem *p, s64 s, s64 e) : m_parent(p), m_start(s), m_end(e) { /* ... */ } virtual ~RomFsFile() { /* ... */ } Result VerifyArguments(size_t *out, s64 offset, void *buf, size_t size, const fs::ReadOption &option) { @@ -189,22 +189,22 @@ namespace ams::fs { } s64 GetOffset() const { - return this->start; + return m_start; } s64 GetSize() const { - return this->end - this->start; + return m_end - m_start; } IStorage *GetStorage() { - return this->parent->GetBaseStorage(); + return m_parent->GetBaseStorage(); } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override { size_t read_size = 0; R_TRY(this->VerifyArguments(std::addressof(read_size), offset, buffer, size, option)); - R_TRY(this->ConvertResult(this->GetStorage()->Read(offset + this->start, buffer, size))); + R_TRY(this->ConvertResult(this->GetStorage()->Read(offset + m_start, buffer, size))); *out = read_size; return ResultSuccess(); @@ -242,7 +242,7 @@ namespace ams::fs { operate_size = this->GetSize() - offset; } - return this->GetStorage()->OperateRange(dst, dst_size, op_id, this->start + offset, operate_size, src, src_size); + return this->GetStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size); } default: return fs::ResultUnsupportedOperationInRomFsFileB(); @@ -258,20 +258,20 @@ namespace ams::fs { private: using FindPosition = RomFsFileSystem::RomFileTable::FindPosition; private: - RomFsFileSystem *parent; - FindPosition current_find; - FindPosition first_find; - fs::OpenDirectoryMode mode; + RomFsFileSystem *m_parent; + FindPosition m_current_find; + FindPosition m_first_find; + fs::OpenDirectoryMode m_mode; public: - RomFsDirectory(RomFsFileSystem *p, const FindPosition &f, fs::OpenDirectoryMode m) : parent(p), current_find(f), first_find(f), mode(m) { /* ... */ } + RomFsDirectory(RomFsFileSystem *p, const FindPosition &f, fs::OpenDirectoryMode m) : m_parent(p), m_current_find(f), m_first_find(f), m_mode(m) { /* ... */ } virtual ~RomFsDirectory() override { /* ... */ } public: virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) { - return this->ReadInternal(out_count, std::addressof(this->current_find), out_entries, max_entries); + return this->ReadInternal(out_count, std::addressof(m_current_find), out_entries, max_entries); } virtual Result DoGetEntryCount(s64 *out) { - FindPosition find = this->first_find; + FindPosition find = m_first_find; return this->ReadInternal(out, std::addressof(find), nullptr, 0); } private: @@ -286,9 +286,9 @@ namespace ams::fs { s32 i = 0; - if (this->mode & fs::OpenDirectoryMode_Directory) { + if (m_mode & fs::OpenDirectoryMode_Directory) { while (i < max_entries || out_entries == nullptr) { - R_TRY_CATCH(this->parent->GetRomFileTable()->FindNextDirectory(name_buf, find, NameBufferSize)) { + R_TRY_CATCH(m_parent->GetRomFileTable()->FindNextDirectory(name_buf, find, NameBufferSize)) { R_CATCH(fs::ResultDbmFindFinished) { break; } } R_END_TRY_CATCH; @@ -304,11 +304,11 @@ namespace ams::fs { } } - if (this->mode & fs::OpenDirectoryMode_File) { + if (m_mode & fs::OpenDirectoryMode_File) { while (i < max_entries || out_entries == nullptr) { auto file_pos = find->next_file; - R_TRY_CATCH(this->parent->GetRomFileTable()->FindNextFile(name_buf, find, NameBufferSize)) { + R_TRY_CATCH(m_parent->GetRomFileTable()->FindNextFile(name_buf, find, NameBufferSize)) { R_CATCH(fs::ResultDbmFindFinished) { break; } } R_END_TRY_CATCH; @@ -319,7 +319,7 @@ namespace ams::fs { out_entries[i].type = fs::DirectoryEntryType_File; RomFsFileSystem::RomFileTable::FileInfo file_info; - R_TRY(this->parent->GetRomFileTable()->OpenFile(std::addressof(file_info), this->parent->GetRomFileTable()->PositionToFileId(file_pos))); + R_TRY(m_parent->GetRomFileTable()->OpenFile(std::addressof(file_info), m_parent->GetRomFileTable()->PositionToFileId(file_pos))); out_entries[i].file_size = file_info.size.Get(); } @@ -339,7 +339,7 @@ namespace ams::fs { } - RomFsFileSystem::RomFsFileSystem() : base_storage() { + RomFsFileSystem::RomFsFileSystem() : m_base_storage() { /* ... */ } @@ -379,46 +379,46 @@ namespace ams::fs { R_TRY(ReadFile(base, header.file_bucket_offset, file_bucket_buf, header.file_bucket_size)); R_TRY(ReadFile(base, header.file_entry_offset, file_entry_buf, header.file_entry_size)); - this->dir_bucket_storage.reset(new MemoryStorage(dir_bucket_buf, header.directory_bucket_size)); - this->dir_entry_storage.reset(new MemoryStorage(dir_entry_buf, header.directory_entry_size)); - this->file_bucket_storage.reset(new MemoryStorage(file_bucket_buf, header.file_bucket_size)); - this->file_entry_storage.reset(new MemoryStorage(file_entry_buf, header.file_entry_size)); + m_dir_bucket_storage.reset(new MemoryStorage(dir_bucket_buf, header.directory_bucket_size)); + m_dir_entry_storage.reset(new MemoryStorage(dir_entry_buf, header.directory_entry_size)); + m_file_bucket_storage.reset(new MemoryStorage(file_bucket_buf, header.file_bucket_size)); + m_file_entry_storage.reset(new MemoryStorage(file_entry_buf, header.file_entry_size)); } else { - this->dir_bucket_storage.reset(new SubStorage(base, header.directory_bucket_offset, header.directory_bucket_size)); - this->dir_entry_storage.reset(new SubStorage(base, header.directory_entry_offset, header.directory_entry_size)); - this->file_bucket_storage.reset(new SubStorage(base, header.file_bucket_offset, header.file_bucket_size)); - this->file_entry_storage.reset(new SubStorage(base, header.file_entry_offset, header.file_entry_size)); + m_dir_bucket_storage.reset(new SubStorage(base, header.directory_bucket_offset, header.directory_bucket_size)); + m_dir_entry_storage.reset(new SubStorage(base, header.directory_entry_offset, header.directory_entry_size)); + m_file_bucket_storage.reset(new SubStorage(base, header.file_bucket_offset, header.file_bucket_size)); + m_file_entry_storage.reset(new SubStorage(base, header.file_entry_offset, header.file_entry_size)); } /* Ensure we allocated storages successfully. */ - R_UNLESS(this->dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); - R_UNLESS(this->dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); - R_UNLESS(this->file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); - R_UNLESS(this->file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); + R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); + R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); + R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); + R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemA()); /* Initialize the rom table. */ { - SubStorage db(this->dir_bucket_storage.get(), 0, header.directory_bucket_size); - SubStorage de(this->dir_entry_storage.get(), 0, header.directory_entry_size); - SubStorage fb(this->file_bucket_storage.get(), 0, header.file_bucket_size); - SubStorage fe(this->file_entry_storage.get(), 0, header.file_entry_size); - R_TRY(this->rom_file_table.Initialize(db, de, fb, fe)); + SubStorage db(m_dir_bucket_storage.get(), 0, header.directory_bucket_size); + SubStorage de(m_dir_entry_storage.get(), 0, header.directory_entry_size); + SubStorage fb(m_file_bucket_storage.get(), 0, header.file_bucket_size); + SubStorage fe(m_file_entry_storage.get(), 0, header.file_entry_size); + R_TRY(m_rom_file_table.Initialize(db, de, fb, fe)); } /* Set members. */ - this->entry_size = header.body_offset; - this->base_storage = base; + m_entry_size = header.body_offset; + m_base_storage = base; return ResultSuccess(); } Result RomFsFileSystem::Initialize(std::unique_ptr&& base, void *work, size_t work_size, bool use_cache) { - this->unique_storage = std::move(base); - return this->Initialize(this->unique_storage.get(), work, work_size, use_cache); + m_unique_storage = std::move(base); + return this->Initialize(m_unique_storage.get(), work, work_size, use_cache); } Result RomFsFileSystem::GetFileInfo(RomFileTable::FileInfo *out, const char *path) { - R_TRY_CATCH(this->rom_file_table.OpenFile(out, path)) { + R_TRY_CATCH(m_rom_file_table.OpenFile(out, path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()); R_CONVERT(fs::ResultDbmInvalidOperation, fs::ResultPathNotFound()); } R_END_TRY_CATCH; @@ -426,11 +426,11 @@ namespace ams::fs { } IStorage *RomFsFileSystem::GetBaseStorage() { - return this->base_storage; + return m_base_storage; } RomFsFileSystem::RomFileTable *RomFsFileSystem::GetRomFileTable() { - return std::addressof(this->rom_file_table); + return std::addressof(m_rom_file_table); } Result RomFsFileSystem::GetFileBaseOffset(s64 *out, const char *path) { @@ -439,7 +439,7 @@ namespace ams::fs { RomFileTable::FileInfo info; R_TRY(this->GetFileInfo(std::addressof(info), path)); - *out = this->entry_size + info.offset.Get(); + *out = m_entry_size + info.offset.Get(); return ResultSuccess(); } @@ -480,7 +480,7 @@ namespace ams::fs { Result RomFsFileSystem::DoGetEntryType(fs::DirectoryEntryType *out, const char *path) { RomDirectoryInfo dir_info; - R_TRY_CATCH(this->rom_file_table.GetDirectoryInformation(std::addressof(dir_info), path)) { + R_TRY_CATCH(m_rom_file_table.GetDirectoryInformation(std::addressof(dir_info), path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()) R_CATCH(fs::ResultDbmInvalidOperation) { RomFileTable::FileInfo file_info; @@ -503,7 +503,7 @@ namespace ams::fs { RomFileTable::FileInfo file_info; R_TRY(this->GetFileInfo(std::addressof(file_info), path)); - auto file = std::make_unique(this, this->entry_size + file_info.offset.Get(), this->entry_size + file_info.offset.Get() + file_info.size.Get()); + auto file = std::make_unique(this, m_entry_size + file_info.offset.Get(), m_entry_size + file_info.offset.Get() + file_info.size.Get()); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); *out_file = std::move(file); @@ -515,7 +515,7 @@ namespace ams::fs { AMS_ASSERT(path != nullptr); RomFileTable::FindPosition find; - R_TRY_CATCH(this->rom_file_table.FindOpen(std::addressof(find), path)) { + R_TRY_CATCH(m_rom_file_table.FindOpen(std::addressof(find), path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()) R_CONVERT(fs::ResultDbmInvalidOperation, fs::ResultPathNotFound()) } R_END_TRY_CATCH; diff --git a/libraries/libstratosphere/source/fs/fs_scoped_setter.hpp b/libraries/libstratosphere/source/fs/fs_scoped_setter.hpp index 2b727d168..fc867aeb6 100644 --- a/libraries/libstratosphere/source/fs/fs_scoped_setter.hpp +++ b/libraries/libstratosphere/source/fs/fs_scoped_setter.hpp @@ -22,33 +22,33 @@ namespace ams::fs { class ScopedSetter { NON_COPYABLE(ScopedSetter); private: - T *ptr; - T value; + T *m_ptr; + T m_value; public: - constexpr ALWAYS_INLINE ScopedSetter(T &p, T v) : ptr(std::addressof(p)), value(v) { /* ... */ } + constexpr ALWAYS_INLINE ScopedSetter(T &p, T v) : m_ptr(std::addressof(p)), m_value(v) { /* ... */ } ALWAYS_INLINE ~ScopedSetter() { - if (this->ptr) { - *this->ptr = this->value; + if (m_ptr) { + *m_ptr = m_value; } } ALWAYS_INLINE ScopedSetter(ScopedSetter &&rhs) { - this->ptr = rhs.ptr; - this->value = rhs.value; + m_ptr = rhs.ptr; + m_value = rhs.value; rhs.Reset(); } ALWAYS_INLINE ScopedSetter &operator=(ScopedSetter &&rhs) { - this->ptr = rhs.ptr; - this->value = rhs.value; + m_ptr = rhs.ptr; + m_value = rhs.value; rhs.Reset(); return *this; } - ALWAYS_INLINE void Set(T v) { this->value = v; } + ALWAYS_INLINE void Set(T v) { m_value = v; } private: ALWAYS_INLINE void Reset() { - this->ptr = nullptr; + m_ptr = nullptr; } }; diff --git a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp index e72cb42b7..632d53920 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.cpp @@ -19,21 +19,21 @@ namespace ams::fs::impl { - DirectoryAccessor::DirectoryAccessor(std::unique_ptr&& d, FileSystemAccessor &p) : impl(std::move(d)), parent(p) { + DirectoryAccessor::DirectoryAccessor(std::unique_ptr&& d, FileSystemAccessor &p) : m_impl(std::move(d)), m_parent(p) { /* ... */ } DirectoryAccessor::~DirectoryAccessor() { - this->impl.reset(); - this->parent.NotifyCloseDirectory(this); + m_impl.reset(); + m_parent.NotifyCloseDirectory(this); } Result DirectoryAccessor::Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) { - return this->impl->Read(out_count, out_entries, max_entries); + return m_impl->Read(out_count, out_entries, max_entries); } Result DirectoryAccessor::GetEntryCount(s64 *out) { - return this->impl->GetEntryCount(out); + return m_impl->GetEntryCount(out); } } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.hpp b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.hpp index d950a99e6..a7e7dc473 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.hpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_directory_accessor.hpp @@ -23,8 +23,8 @@ namespace ams::fs::impl { class DirectoryAccessor : public util::IntrusiveListBaseNode, public Newable { NON_COPYABLE(DirectoryAccessor); private: - std::unique_ptr impl; - FileSystemAccessor &parent; + std::unique_ptr m_impl; + FileSystemAccessor &m_parent; public: DirectoryAccessor(std::unique_ptr&& d, FileSystemAccessor &p); ~DirectoryAccessor(); @@ -32,7 +32,7 @@ namespace ams::fs::impl { Result Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries); Result GetEntryCount(s64 *out); - FileSystemAccessor *GetParent() const { return std::addressof(this->parent); } + FileSystemAccessor *GetParent() const { return std::addressof(m_parent); } }; } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp index 3ea0d08e3..6647d2d57 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.cpp @@ -22,20 +22,20 @@ namespace ams::fs::impl { FileAccessor::FileAccessor(std::unique_ptr&& f, FileSystemAccessor *p, OpenMode mode) - : impl(std::move(f)), parent(p), write_state(WriteState::None), write_result(ResultSuccess()), open_mode(mode) + : m_impl(std::move(f)), m_parent(p), m_write_state(WriteState::None), m_write_result(ResultSuccess()), m_open_mode(mode) { /* ... */ } FileAccessor::~FileAccessor() { /* Ensure that all files are flushed. */ - if (R_SUCCEEDED(this->write_result)) { - AMS_FS_ABORT_UNLESS_WITH_RESULT(this->write_state != WriteState::NeedsFlush, fs::ResultNeedFlush()); + if (R_SUCCEEDED(m_write_result)) { + AMS_FS_ABORT_UNLESS_WITH_RESULT(m_write_state != WriteState::NeedsFlush, fs::ResultNeedFlush()); } - this->impl.reset(); + m_impl.reset(); - if (this->parent != nullptr) { - this->parent->NotifyCloseFile(this); + if (m_parent != nullptr) { + m_parent->NotifyCloseFile(this); } } @@ -46,7 +46,7 @@ namespace ams::fs::impl { } Result FileAccessor::ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) { - return this->impl->Read(out, offset, buf, size, option); + return m_impl->Read(out, offset, buf, size, option); } Result FileAccessor::Read(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option) { @@ -54,11 +54,11 @@ namespace ams::fs::impl { FileHandle handle = { this }; /* Fail after a write fails. */ - R_UNLESS(R_SUCCEEDED(this->write_result), AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(this->write_result, handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size))); + R_UNLESS(R_SUCCEEDED(m_write_result), AMS_FS_IMPL_ACCESS_LOG_WITH_NAME(m_write_result, handle, "ReadFile", AMS_FS_IMPL_ACCESS_LOG_FORMAT_READ_FILE(out, offset, size))); /* TODO: Support cache. */ - const bool use_path_cache = this->parent != nullptr && this->file_path_hash != nullptr; - const bool use_data_cache = /* TODO */false && this->parent != nullptr && this->parent->IsFileDataCacheAttachable(); + const bool use_path_cache = m_parent != nullptr && m_file_path_hash != nullptr; + const bool use_data_cache = /* TODO */false && m_parent != nullptr && m_parent->IsFileDataCacheAttachable(); if (use_path_cache && use_data_cache && false) { /* TODO */ @@ -70,14 +70,14 @@ namespace ams::fs::impl { Result FileAccessor::Write(s64 offset, const void *buf, size_t size, const WriteOption &option) { /* Fail after a write fails. */ - R_TRY(this->write_result); + R_TRY(m_write_result); - auto setter = MakeScopedSetter(this->write_state, WriteState::Failed); - if (this->file_path_hash != nullptr && /* TODO */ false) { + auto setter = MakeScopedSetter(m_write_state, WriteState::Failed); + if (m_file_path_hash != nullptr && /* TODO */ false) { /* TODO */ AMS_ABORT(); } else { - R_TRY(this->UpdateLastResult(this->impl->Write(offset, buf, size, option))); + R_TRY(this->UpdateLastResult(m_impl->Write(offset, buf, size, option))); } setter.Set(option.HasFlushFlag() ? WriteState::None : WriteState::NeedsFlush); @@ -87,10 +87,10 @@ namespace ams::fs::impl { Result FileAccessor::Flush() { /* Fail after a write fails. */ - R_TRY(this->write_result); + R_TRY(m_write_result); - auto setter = MakeScopedSetter(this->write_state, WriteState::Failed); - R_TRY(this->UpdateLastResult(this->impl->Flush())); + auto setter = MakeScopedSetter(m_write_state, WriteState::Failed); + R_TRY(this->UpdateLastResult(m_impl->Flush())); setter.Set(WriteState::None); return ResultSuccess(); @@ -98,14 +98,14 @@ namespace ams::fs::impl { Result FileAccessor::SetSize(s64 size) { /* Fail after a write fails. */ - R_TRY(this->write_result); + R_TRY(m_write_result); - const WriteState old_write_state = this->write_state; - auto setter = MakeScopedSetter(this->write_state, WriteState::Failed); + const WriteState old_write_state = m_write_state; + auto setter = MakeScopedSetter(m_write_state, WriteState::Failed); - R_TRY(this->UpdateLastResult(this->impl->SetSize(size))); + R_TRY(this->UpdateLastResult(m_impl->SetSize(size))); - if (this->file_path_hash != nullptr) { + if (m_file_path_hash != nullptr) { /* TODO: invalidate path cache */ } @@ -115,13 +115,13 @@ namespace ams::fs::impl { Result FileAccessor::GetSize(s64 *out) { /* Fail after a write fails. */ - R_TRY(this->write_result); + R_TRY(m_write_result); - return this->impl->GetSize(out); + return m_impl->GetSize(out); } Result FileAccessor::OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size) { - return this->impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size); + return m_impl->OperateRange(dst, dst_size, operation, offset, size, src, src_size); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp index 30b7b2d0e..a40bad582 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_file_accessor.hpp @@ -30,13 +30,13 @@ namespace ams::fs::impl { class FileAccessor : public util::IntrusiveListBaseNode, public Newable { NON_COPYABLE(FileAccessor); private: - std::unique_ptr impl; - FileSystemAccessor * const parent; - WriteState write_state; - Result write_result; - const OpenMode open_mode; - std::unique_ptr file_path_hash; - s32 path_hash_index; + std::unique_ptr m_impl; + FileSystemAccessor * const m_parent; + WriteState m_write_state; + Result m_write_result; + const OpenMode m_open_mode; + std::unique_ptr m_file_path_hash; + s32 m_path_hash_index; public: FileAccessor(std::unique_ptr&& f, FileSystemAccessor *p, OpenMode mode); ~FileAccessor(); @@ -48,9 +48,9 @@ namespace ams::fs::impl { Result GetSize(s64 *out); Result OperateRange(void *dst, size_t dst_size, OperationId operation, s64 offset, s64 size, const void *src, size_t src_size); - OpenMode GetOpenMode() const { return this->open_mode; } - WriteState GetWriteState() const { return this->write_state; } - FileSystemAccessor *GetParent() const { return this->parent; } + OpenMode GetOpenMode() const { return m_open_mode; } + WriteState GetWriteState() const { return m_write_state; } + FileSystemAccessor *GetParent() const { return m_parent; } void SetFilePathHash(std::unique_ptr&& file_path_hash, s32 index); Result ReadWithoutCacheAccessLog(size_t *out, s64 offset, void *buf, size_t size, const ReadOption &option); @@ -59,7 +59,7 @@ namespace ams::fs::impl { ALWAYS_INLINE Result UpdateLastResult(Result r) { if (!fs::ResultNotEnoughFreeSpace::Includes(r)) { - this->write_result = r; + m_write_result = r; } return r; } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp b/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp index d85d903d7..ce00a1755 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.cpp @@ -60,34 +60,34 @@ namespace ams::fs::impl { } FileSystemAccessor::FileSystemAccessor(const char *n, std::unique_ptr &&fs, std::unique_ptr &&generator) - : impl(std::move(fs)), open_list_lock(), mount_name_generator(std::move(generator)), - access_log_enabled(false), data_cache_attachable(false), path_cache_attachable(false), path_cache_attached(false), multi_commit_supported(false) + : m_impl(std::move(fs)), m_open_list_lock(), m_mount_name_generator(std::move(generator)), + m_access_log_enabled(false), m_data_cache_attachable(false), m_path_cache_attachable(false), m_path_cache_attached(false), m_multi_commit_supported(false) { R_ABORT_UNLESS(ValidateMountName(n)); - std::strncpy(this->name.str, n, MountNameLengthMax); - this->name.str[MountNameLengthMax] = 0; + std::strncpy(m_name.str, n, MountNameLengthMax); + m_name.str[MountNameLengthMax] = 0; } FileSystemAccessor::~FileSystemAccessor() { - std::scoped_lock lk(this->open_list_lock); + std::scoped_lock lk(m_open_list_lock); /* TODO: Iterate over list entries. */ - if (!this->open_file_list.empty()) { R_ABORT_UNLESS(fs::ResultFileNotClosed()); } - if (!this->open_dir_list.empty()) { R_ABORT_UNLESS(fs::ResultDirectoryNotClosed()); } + if (!m_open_file_list.empty()) { R_ABORT_UNLESS(fs::ResultFileNotClosed()); } + if (!m_open_dir_list.empty()) { R_ABORT_UNLESS(fs::ResultDirectoryNotClosed()); } - if (this->path_cache_attached) { + if (m_path_cache_attached) { /* TODO: Invalidate path cache */ } } Result FileSystemAccessor::GetCommonMountName(char *dst, size_t dst_size) const { - R_UNLESS(this->mount_name_generator != nullptr, fs::ResultPreconditionViolation()); - return this->mount_name_generator->GenerateCommonMountName(dst, dst_size); + R_UNLESS(m_mount_name_generator != nullptr, fs::ResultPreconditionViolation()); + return m_mount_name_generator->GenerateCommonMountName(dst, dst_size); } std::shared_ptr FileSystemAccessor::GetMultiCommitTarget() { - if (this->multi_commit_supported) { + if (m_multi_commit_supported) { /* TODO: Support multi commit. */ AMS_ABORT(); } @@ -95,90 +95,90 @@ namespace ams::fs::impl { } void FileSystemAccessor::NotifyCloseFile(FileAccessor *f) { - std::scoped_lock lk(this->open_list_lock); - Remove(this->open_file_list, f); + std::scoped_lock lk(m_open_list_lock); + Remove(m_open_file_list, f); } void FileSystemAccessor::NotifyCloseDirectory(DirectoryAccessor *d) { - std::scoped_lock lk(this->open_list_lock); - Remove(this->open_dir_list, d); + std::scoped_lock lk(m_open_list_lock); + Remove(m_open_dir_list, d); } Result FileSystemAccessor::CreateFile(const char *path, s64 size, int option) { - R_TRY(ValidatePath(this->name.str, path)); - if (this->path_cache_attached) { + R_TRY(ValidatePath(m_name.str, path)); + if (m_path_cache_attached) { /* TODO: Path cache */ - R_TRY(this->impl->CreateFile(path, size, option)); + R_TRY(m_impl->CreateFile(path, size, option)); } else { - R_TRY(this->impl->CreateFile(path, size, option)); + R_TRY(m_impl->CreateFile(path, size, option)); } return ResultSuccess(); } Result FileSystemAccessor::DeleteFile(const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->DeleteFile(path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->DeleteFile(path); } Result FileSystemAccessor::CreateDirectory(const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->CreateDirectory(path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->CreateDirectory(path); } Result FileSystemAccessor::DeleteDirectory(const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->DeleteDirectory(path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->DeleteDirectory(path); } Result FileSystemAccessor::DeleteDirectoryRecursively(const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->DeleteDirectoryRecursively(path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->DeleteDirectoryRecursively(path); } Result FileSystemAccessor::RenameFile(const char *old_path, const char *new_path) { - R_TRY(ValidatePath(this->name.str, old_path)); - R_TRY(ValidatePath(this->name.str, new_path)); - if (this->path_cache_attached) { + R_TRY(ValidatePath(m_name.str, old_path)); + R_TRY(ValidatePath(m_name.str, new_path)); + if (m_path_cache_attached) { /* TODO: Path cache */ - R_TRY(this->impl->RenameFile(old_path, new_path)); + R_TRY(m_impl->RenameFile(old_path, new_path)); } else { - R_TRY(this->impl->RenameFile(old_path, new_path)); + R_TRY(m_impl->RenameFile(old_path, new_path)); } return ResultSuccess(); } Result FileSystemAccessor::RenameDirectory(const char *old_path, const char *new_path) { - R_TRY(ValidatePath(this->name.str, old_path)); - R_TRY(ValidatePath(this->name.str, new_path)); - if (this->path_cache_attached) { + R_TRY(ValidatePath(m_name.str, old_path)); + R_TRY(ValidatePath(m_name.str, new_path)); + if (m_path_cache_attached) { /* TODO: Path cache */ - R_TRY(this->impl->RenameDirectory(old_path, new_path)); + R_TRY(m_impl->RenameDirectory(old_path, new_path)); } else { - R_TRY(this->impl->RenameDirectory(old_path, new_path)); + R_TRY(m_impl->RenameDirectory(old_path, new_path)); } return ResultSuccess(); } Result FileSystemAccessor::GetEntryType(DirectoryEntryType *out, const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->GetEntryType(out, path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->GetEntryType(out, path); } Result FileSystemAccessor::OpenFile(std::unique_ptr *out_file, const char *path, OpenMode mode) { - R_TRY(ValidatePath(this->name.str, path)); + R_TRY(ValidatePath(m_name.str, path)); std::unique_ptr file; - R_TRY(this->impl->OpenFile(std::addressof(file), path, mode)); + R_TRY(m_impl->OpenFile(std::addressof(file), path, mode)); auto accessor = new FileAccessor(std::move(file), this, mode); R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorA()); { - std::scoped_lock lk(this->open_list_lock); - this->open_file_list.push_back(*accessor); + std::scoped_lock lk(m_open_list_lock); + m_open_file_list.push_back(*accessor); } - if (this->path_cache_attached) { + if (m_path_cache_attached) { if (mode & OpenMode_AllowAppend) { /* TODO: Append Path cache */ } else { @@ -191,17 +191,17 @@ namespace ams::fs::impl { } Result FileSystemAccessor::OpenDirectory(std::unique_ptr *out_dir, const char *path, OpenDirectoryMode mode) { - R_TRY(ValidatePath(this->name.str, path)); + R_TRY(ValidatePath(m_name.str, path)); std::unique_ptr dir; - R_TRY(this->impl->OpenDirectory(std::addressof(dir), path, mode)); + R_TRY(m_impl->OpenDirectory(std::addressof(dir), path, mode)); auto accessor = new DirectoryAccessor(std::move(dir), *this); R_UNLESS(accessor != nullptr, fs::ResultAllocationFailureInFileSystemAccessorB()); { - std::scoped_lock lk(this->open_list_lock); - this->open_dir_list.push_back(*accessor); + std::scoped_lock lk(m_open_list_lock); + m_open_dir_list.push_back(*accessor); } out_dir->reset(accessor); @@ -210,33 +210,33 @@ namespace ams::fs::impl { Result FileSystemAccessor::Commit() { { - std::scoped_lock lk(this->open_list_lock); - R_ABORT_UNLESS(ValidateNoOpenWriteModeFiles(this->open_file_list)); + std::scoped_lock lk(m_open_list_lock); + R_ABORT_UNLESS(ValidateNoOpenWriteModeFiles(m_open_file_list)); } - return this->impl->Commit(); + return m_impl->Commit(); } Result FileSystemAccessor::GetFreeSpaceSize(s64 *out, const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->GetFreeSpaceSize(out, path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->GetFreeSpaceSize(out, path); } Result FileSystemAccessor::GetTotalSpaceSize(s64 *out, const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->GetTotalSpaceSize(out, path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->GetTotalSpaceSize(out, path); } Result FileSystemAccessor::CleanDirectoryRecursively(const char *path) { - R_TRY(ValidatePath(this->name.str, path)); - return this->impl->CleanDirectoryRecursively(path); + R_TRY(ValidatePath(m_name.str, path)); + return m_impl->CleanDirectoryRecursively(path); } Result FileSystemAccessor::GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) { - return this->impl->GetFileTimeStampRaw(out, path); + return m_impl->GetFileTimeStampRaw(out, path); } Result FileSystemAccessor::QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path) { - return this->impl->QueryEntry(dst, dst_size, src, src_size, query, path); + return m_impl->QueryEntry(dst, dst_size, src, src_size, query, path); } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp b/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp index 3de87bec5..a7f8fbf41 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_filesystem_accessor.hpp @@ -31,17 +31,17 @@ namespace ams::fs::impl { using FileList = util::IntrusiveListBaseTraits::ListType; using DirList = util::IntrusiveListBaseTraits::ListType; private: - MountName name; - std::unique_ptr impl; - FileList open_file_list; - DirList open_dir_list; - os::SdkMutex open_list_lock; - std::unique_ptr mount_name_generator; - bool access_log_enabled; - bool data_cache_attachable; - bool path_cache_attachable; - bool path_cache_attached; - bool multi_commit_supported; + MountName m_name; + std::unique_ptr m_impl; + FileList m_open_file_list; + DirList m_open_dir_list; + os::SdkMutex m_open_list_lock; + std::unique_ptr m_mount_name_generator; + bool m_access_log_enabled; + bool m_data_cache_attachable; + bool m_path_cache_attachable; + bool m_path_cache_attached; + bool m_multi_commit_supported; public: FileSystemAccessor(const char *name, std::unique_ptr &&fs, std::unique_ptr &&generator = nullptr); virtual ~FileSystemAccessor(); @@ -63,32 +63,32 @@ namespace ams::fs::impl { Result GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path); Result QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path); - const char *GetName() const { return this->name.str; } + const char *GetName() const { return m_name.str; } Result GetCommonMountName(char *dst, size_t dst_size) const; - void SetAccessLogEnabled(bool en) { this->access_log_enabled = en; } - void SetFileDataCacheAttachable(bool en) { this->data_cache_attachable = en; } - void SetPathBasedFileDataCacheAttachable(bool en) { this->path_cache_attachable = en; } - void SetMultiCommitSupported(bool en) { this->multi_commit_supported = en; } + void SetAccessLogEnabled(bool en) { m_access_log_enabled = en; } + void SetFileDataCacheAttachable(bool en) { m_data_cache_attachable = en; } + void SetPathBasedFileDataCacheAttachable(bool en) { m_path_cache_attachable = en; } + void SetMultiCommitSupported(bool en) { m_multi_commit_supported = en; } - bool IsEnabledAccessLog() const { return this->access_log_enabled; } - bool IsFileDataCacheAttachable() const { return this->data_cache_attachable; } - bool IsPathBasedFileDataCacheAttachable() const { return this->path_cache_attachable; } + bool IsEnabledAccessLog() const { return m_access_log_enabled; } + bool IsFileDataCacheAttachable() const { return m_data_cache_attachable; } + bool IsPathBasedFileDataCacheAttachable() const { return m_path_cache_attachable; } void AttachPathBasedFileDataCache() { if (this->IsPathBasedFileDataCacheAttachable()) { - this->path_cache_attached = true; + m_path_cache_attached = true; } } void DetachPathBasedFileDataCache() { - this->path_cache_attached = false; + m_path_cache_attached = false; } std::shared_ptr GetMultiCommitTarget(); fsa::IFileSystem *GetRawFileSystemUnsafe() { - return this->impl.get(); + return m_impl.get(); } private: void NotifyCloseFile(FileAccessor *f); diff --git a/libraries/libstratosphere/source/fs/fsa/fs_mount_table.cpp b/libraries/libstratosphere/source/fs/fsa/fs_mount_table.cpp index 71c3a0cd5..1325192fc 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_mount_table.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_mount_table.cpp @@ -27,7 +27,7 @@ namespace ams::fs::impl { } bool MountTable::CanAcceptMountName(const char *name) { - for (const auto &fs : this->fs_list) { + for (const auto &fs : m_fs_list) { if (MatchesName(fs, name)) { return false; } @@ -36,18 +36,18 @@ namespace ams::fs::impl { } Result MountTable::Mount(std::unique_ptr &&fs) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); R_UNLESS(this->CanAcceptMountName(fs->GetName()), fs::ResultMountNameAlreadyExists()); - this->fs_list.push_back(*fs.release()); + m_fs_list.push_back(*fs.release()); return ResultSuccess(); } Result MountTable::Find(FileSystemAccessor **out, const char *name) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - for (auto &fs : this->fs_list) { + for (auto &fs : m_fs_list) { if (MatchesName(fs, name)) { *out = std::addressof(fs); return ResultSuccess(); @@ -58,12 +58,12 @@ namespace ams::fs::impl { } void MountTable::Unmount(const char *name) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - for (auto it = this->fs_list.cbegin(); it != this->fs_list.cend(); it++) { + for (auto it = m_fs_list.cbegin(); it != m_fs_list.cend(); it++) { if (MatchesName(*it, name)) { auto p = std::addressof(*it); - this->fs_list.erase(it); + m_fs_list.erase(it); delete p; return; } diff --git a/libraries/libstratosphere/source/fs/fsa/fs_mount_table.hpp b/libraries/libstratosphere/source/fs/fsa/fs_mount_table.hpp index 1198915cd..96f06eeee 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_mount_table.hpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_mount_table.hpp @@ -25,10 +25,10 @@ namespace ams::fs::impl { private: using FileSystemList = util::IntrusiveListBaseTraits::ListType; private: - FileSystemList fs_list; - os::SdkMutex mutex; + FileSystemList m_fs_list; + os::SdkMutex m_mutex; public: - constexpr MountTable() : fs_list(), mutex() { /* ... */ } + constexpr MountTable() : m_fs_list(), m_mutex() { /* ... */ } private: bool CanAcceptMountName(const char *name); public: diff --git a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp index 88813fc37..1b8f88b92 100644 --- a/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp +++ b/libraries/libstratosphere/source/fs/fsa/fs_user_mount_table.cpp @@ -22,7 +22,7 @@ namespace ams::fs::impl { namespace { - MountTable g_mount_table; + constinit MountTable g_mount_table; } diff --git a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp index 6f4b260c2..e393df9e8 100644 --- a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp +++ b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_rom_file_system_creator.cpp @@ -21,15 +21,15 @@ namespace ams::fssrv::fscreator { class RomFileSystemWithBuffer : public ::ams::fssystem::RomFsFileSystem { private: - void *meta_cache_buffer; - size_t meta_cache_buffer_size; - MemoryResource *allocator; + void *m_meta_cache_buffer; + size_t m_meta_cache_buffer_size; + MemoryResource *m_allocator; public: - explicit RomFileSystemWithBuffer(MemoryResource *mr) : meta_cache_buffer(nullptr), allocator(mr) { /* ... */ } + explicit RomFileSystemWithBuffer(MemoryResource *mr) : m_meta_cache_buffer(nullptr), m_allocator(mr) { /* ... */ } ~RomFileSystemWithBuffer() { - if (this->meta_cache_buffer != nullptr) { - this->allocator->Deallocate(this->meta_cache_buffer, this->meta_cache_buffer_size); + if (m_meta_cache_buffer != nullptr) { + m_allocator->Deallocate(m_meta_cache_buffer, m_meta_cache_buffer_size); } } @@ -41,14 +41,14 @@ namespace ams::fssrv::fscreator { } /* Allocate a buffer. */ - this->meta_cache_buffer = this->allocator->Allocate(buffer_size); - if (this->meta_cache_buffer == nullptr) { + m_meta_cache_buffer = m_allocator->Allocate(buffer_size); + if (m_meta_cache_buffer == nullptr) { return RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false); } /* Initialize with cache buffer. */ - this->meta_cache_buffer_size = buffer_size; - return RomFsFileSystem::Initialize(std::move(storage), this->meta_cache_buffer, this->meta_cache_buffer_size, true); + m_meta_cache_buffer_size = buffer_size; + return RomFsFileSystem::Initialize(std::move(storage), m_meta_cache_buffer, m_meta_cache_buffer_size, true); } }; @@ -56,7 +56,7 @@ namespace ams::fssrv::fscreator { Result RomFileSystemCreator::Create(std::shared_ptr *out, std::shared_ptr storage) { /* Allocate a filesystem. */ - std::shared_ptr fs = fssystem::AllocateShared(this->allocator); + std::shared_ptr fs = fssystem::AllocateShared(m_allocator); R_UNLESS(fs != nullptr, fs::ResultAllocationFailureInRomFileSystemCreatorA()); /* Initialize the filesystem. */ diff --git a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_storage_on_nca_creator.cpp b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_storage_on_nca_creator.cpp index 95ca998d2..14114df77 100644 --- a/libraries/libstratosphere/source/fssrv/fscreator/fssrv_storage_on_nca_creator.cpp +++ b/libraries/libstratosphere/source/fssrv/fscreator/fssrv_storage_on_nca_creator.cpp @@ -44,9 +44,9 @@ namespace ams::fssrv::fscreator { R_UNLESS(size == sizeof(acid_size), fs::ResultInvalidAcidFileSize()); /* Allocate memory for the acid. */ - u8 *acid = static_cast(this->allocator->Allocate(acid_size)); + u8 *acid = static_cast(m_allocator->Allocate(acid_size)); R_UNLESS(acid != nullptr, fs::ResultAllocationFailureInStorageOnNcaCreatorA()); - ON_SCOPE_EXIT { this->allocator->Deallocate(acid, acid_size); }; + ON_SCOPE_EXIT { m_allocator->Deallocate(acid, acid_size); }; /* Read the acid. */ R_TRY(file->Read(std::addressof(size), acid_offset, acid, acid_size, fs::ReadOption())); @@ -72,7 +72,7 @@ namespace ams::fssrv::fscreator { { const u8 *sig = acid + AcidSignOffset; const size_t sig_size = static_cast(AcidSignSize); - const u8 *mod = fssystem::GetAcidSignatureKeyModulus(this->is_prod, acid_signature_key_generation); + const u8 *mod = fssystem::GetAcidSignatureKeyModulus(m_is_prod, acid_signature_key_generation); const size_t mod_size = fssystem::AcidSignatureKeyModulusSize; const u8 *exp = fssystem::GetAcidSignatureKeyPublicExponent(); const size_t exp_size = fssystem::AcidSignatureKeyPublicExponentSize; @@ -81,7 +81,7 @@ namespace ams::fssrv::fscreator { const bool is_signature_valid = crypto::VerifyRsa2048PssSha256(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); if (!is_signature_valid) { /* If the signature is invalid, then unless program verification is disabled error out. */ - R_UNLESS(!this->is_enabled_program_verification, fs::ResultAcidVerificationFailed()); + R_UNLESS(!m_is_enabled_program_verification, fs::ResultAcidVerificationFailed()); /* If program verification is disabled, then we're fine. */ return ResultSuccess(); @@ -104,7 +104,7 @@ namespace ams::fssrv::fscreator { Result StorageOnNcaCreator::Create(std::shared_ptr *out, fssystem::NcaFsHeaderReader *out_header_reader, std::shared_ptr nca_reader, s32 index, bool verify_header_sign_2) { /* Create a fs driver. */ - fssystem::NcaFileSystemDriver nca_fs_driver(nca_reader, this->allocator, this->buffer_manager); + fssystem::NcaFileSystemDriver nca_fs_driver(nca_reader, m_allocator, m_buffer_manager); /* Open the storage. */ std::shared_ptr storage; @@ -122,7 +122,7 @@ namespace ams::fssrv::fscreator { Result StorageOnNcaCreator::CreateWithPatch(std::shared_ptr *out, fssystem::NcaFsHeaderReader *out_header_reader, std::shared_ptr original_nca_reader, std::shared_ptr current_nca_reader, s32 index, bool verify_header_sign_2) { /* Create a fs driver. */ - fssystem::NcaFileSystemDriver nca_fs_driver(original_nca_reader, current_nca_reader, this->allocator, this->buffer_manager); + fssystem::NcaFileSystemDriver nca_fs_driver(original_nca_reader, current_nca_reader, m_allocator, m_buffer_manager); /* Open the storage. */ std::shared_ptr storage; @@ -144,7 +144,7 @@ namespace ams::fssrv::fscreator { R_UNLESS(reader != nullptr, fs::ResultAllocationFailureInStorageOnNcaCreatorB()); /* Initialize the reader. */ - R_TRY(reader->Initialize(std::move(storage), this->nca_crypto_cfg)); + R_TRY(reader->Initialize(std::move(storage), m_nca_crypto_cfg)); /* Set the output. */ *out = std::move(reader); @@ -152,8 +152,8 @@ namespace ams::fssrv::fscreator { } void StorageOnNcaCreator::SetEnabledProgramVerification(bool en) { - if (!this->is_prod) { - this->is_enabled_program_verification = en; + if (!m_is_prod) { + m_is_enabled_program_verification = en; } } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp index 51880abab..177e6a4d1 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp @@ -20,7 +20,7 @@ namespace ams::fssrv::impl { FileInterfaceAdapter::FileInterfaceAdapter(std::unique_ptr &&file, FileSystemInterfaceAdapter *parent, util::unique_lock &&sema) - : parent_filesystem(parent, true), base_file(std::move(file)), open_count_semaphore(std::move(sema)) + : m_parent_filesystem(parent, true), m_base_file(std::move(file)), m_open_count_semaphore(std::move(sema)) { /* ... */ } @@ -30,9 +30,9 @@ namespace ams::fssrv::impl { } void FileInterfaceAdapter::InvalidateCache() { - AMS_ABORT_UNLESS(this->parent_filesystem->IsDeepRetryEnabled()); - std::scoped_lock scoped_write_lock(this->parent_filesystem->GetReaderWriterLockForCacheInvalidation()); - this->base_file->OperateRange(nullptr, 0, fs::OperationId::Invalidate, 0, std::numeric_limits::max(), nullptr, 0); + AMS_ABORT_UNLESS(m_parent_filesystem->IsDeepRetryEnabled()); + std::scoped_lock scoped_write_lock(m_parent_filesystem->GetReaderWriterLockForCacheInvalidation()); + m_base_file->OperateRange(nullptr, 0, fs::OperationId::Invalidate, 0, std::numeric_limits::max(), nullptr, 0); } Result FileInterfaceAdapter::Read(ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, fs::ReadOption option) { @@ -42,7 +42,7 @@ namespace ams::fssrv::impl { R_UNLESS(size >= 0, fs::ResultInvalidSize()); size_t read_size = 0; - R_TRY(this->base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast(size), option)); + R_TRY(m_base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast(size), option)); out.SetValue(read_size); return ResultSuccess(); @@ -53,24 +53,24 @@ namespace ams::fssrv::impl { R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); R_UNLESS(size >= 0, fs::ResultInvalidSize()); - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); - return this->base_file->Write(offset, buffer.GetPointer(), size, option); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); + return m_base_file->Write(offset, buffer.GetPointer(), size, option); } Result FileInterfaceAdapter::Flush() { - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); - return this->base_file->Flush(); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); + return m_base_file->Flush(); } Result FileInterfaceAdapter::SetSize(s64 size) { R_UNLESS(size >= 0, fs::ResultInvalidSize()); - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); - return this->base_file->SetSize(size); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); + return m_base_file->SetSize(size); } Result FileInterfaceAdapter::GetSize(ams::sf::Out out) { - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); - return this->base_file->GetSize(out.GetPointer()); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); + return m_base_file->GetSize(out.GetPointer()); } Result FileInterfaceAdapter::OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size) { @@ -79,10 +79,10 @@ namespace ams::fssrv::impl { out->Clear(); if (op_id == static_cast(fs::OperationId::QueryRange)) { - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); fs::FileQueryRangeInfo info; - R_TRY(this->base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); + R_TRY(m_base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); out->Merge(info); } @@ -105,13 +105,13 @@ namespace ams::fssrv::impl { } /* Perform the operation. */ - R_TRY(this->base_file->OperateRange(out_buf.GetPointer(), out_buf.GetSize(), static_cast(op_id), offset, size, in_buf.GetPointer(), in_buf.GetSize())); + R_TRY(m_base_file->OperateRange(out_buf.GetPointer(), out_buf.GetSize(), static_cast(op_id), offset, size, in_buf.GetPointer(), in_buf.GetSize())); return ResultSuccess(); } DirectoryInterfaceAdapter::DirectoryInterfaceAdapter(std::unique_ptr &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock &&sema) - : parent_filesystem(parent, true), base_dir(std::move(dir)), open_count_semaphore(std::move(sema)) + : m_parent_filesystem(parent, true), m_base_dir(std::move(dir)), m_open_count_semaphore(std::move(sema)) { /* ... */ } @@ -121,22 +121,22 @@ namespace ams::fssrv::impl { } Result DirectoryInterfaceAdapter::Read(ams::sf::Out out, const ams::sf::OutBuffer &out_entries) { - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); const s64 max_num_entries = out_entries.GetSize() / sizeof(fs::DirectoryEntry); R_UNLESS(max_num_entries >= 0, fs::ResultInvalidSize()); /* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */ - return this->base_dir->Read(out.GetPointer(), reinterpret_cast(out_entries.GetPointer()), max_num_entries); + return m_base_dir->Read(out.GetPointer(), reinterpret_cast(out_entries.GetPointer()), max_num_entries); } Result DirectoryInterfaceAdapter::GetEntryCount(ams::sf::Out out) { - auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock(); - return this->base_dir->GetEntryCount(out.GetPointer()); + auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock(); + return m_base_dir->GetEntryCount(out.GetPointer()); } FileSystemInterfaceAdapter::FileSystemInterfaceAdapter(std::shared_ptr &&fs, bool open_limited) - : base_fs(std::move(fs)), open_count_limited(open_limited), deep_retry_enabled(false) + : m_base_fs(std::move(fs)), m_open_count_limited(open_limited), m_deep_retry_enabled(false) { /* ... */ } @@ -146,7 +146,7 @@ namespace ams::fssrv::impl { } bool FileSystemInterfaceAdapter::IsDeepRetryEnabled() const { - return this->deep_retry_enabled; + return m_deep_retry_enabled; } bool FileSystemInterfaceAdapter::IsAccessFailureDetectionObserved() const { @@ -156,14 +156,14 @@ namespace ams::fssrv::impl { util::optional> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() { util::optional> lock; - if (this->deep_retry_enabled) { - lock.emplace(this->invalidation_lock); + if (m_deep_retry_enabled) { + lock.emplace(m_invalidation_lock); } return lock; } os::ReaderWriterLock &FileSystemInterfaceAdapter::GetReaderWriterLockForCacheInvalidation() { - return this->invalidation_lock; + return m_invalidation_lock; } Result FileSystemInterfaceAdapter::CreateFile(const fssrv::sf::Path &path, s64 size, s32 option) { @@ -174,7 +174,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->CreateFile(normalizer.GetPath(), size, option); + return m_base_fs->CreateFile(normalizer.GetPath(), size, option); } Result FileSystemInterfaceAdapter::DeleteFile(const fssrv::sf::Path &path) { @@ -183,7 +183,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->DeleteFile(normalizer.GetPath()); + return m_base_fs->DeleteFile(normalizer.GetPath()); } Result FileSystemInterfaceAdapter::CreateDirectory(const fssrv::sf::Path &path) { @@ -194,7 +194,7 @@ namespace ams::fssrv::impl { R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultPathAlreadyExists()); - return this->base_fs->CreateDirectory(normalizer.GetPath()); + return m_base_fs->CreateDirectory(normalizer.GetPath()); } Result FileSystemInterfaceAdapter::DeleteDirectory(const fssrv::sf::Path &path) { @@ -205,7 +205,7 @@ namespace ams::fssrv::impl { R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultDirectoryNotDeletable()); - return this->base_fs->DeleteDirectory(normalizer.GetPath()); + return m_base_fs->DeleteDirectory(normalizer.GetPath()); } Result FileSystemInterfaceAdapter::DeleteDirectoryRecursively(const fssrv::sf::Path &path) { @@ -216,7 +216,7 @@ namespace ams::fssrv::impl { R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultDirectoryNotDeletable()); - return this->base_fs->DeleteDirectoryRecursively(normalizer.GetPath()); + return m_base_fs->DeleteDirectoryRecursively(normalizer.GetPath()); } Result FileSystemInterfaceAdapter::RenameFile(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) { @@ -227,7 +227,7 @@ namespace ams::fssrv::impl { R_UNLESS(old_normalizer.GetPath() != nullptr, old_normalizer.GetResult()); R_UNLESS(new_normalizer.GetPath() != nullptr, new_normalizer.GetResult()); - return this->base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath()); + return m_base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath()); } Result FileSystemInterfaceAdapter::RenameDirectory(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) { @@ -241,7 +241,7 @@ namespace ams::fssrv::impl { const bool is_subpath = fs::IsSubPath(old_normalizer.GetPath(), new_normalizer.GetPath()); R_UNLESS(!is_subpath, fs::ResultDirectoryNotRenamable()); - return this->base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath()); + return m_base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath()); } Result FileSystemInterfaceAdapter::GetEntryType(ams::sf::Out out, const fssrv::sf::Path &path) { @@ -251,14 +251,14 @@ namespace ams::fssrv::impl { R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); static_assert(sizeof(*out.GetPointer()) == sizeof(fs::DirectoryEntryType)); - return this->base_fs->GetEntryType(reinterpret_cast(out.GetPointer()), normalizer.GetPath()); + return m_base_fs->GetEntryType(reinterpret_cast(out.GetPointer()), normalizer.GetPath()); } Result FileSystemInterfaceAdapter::OpenFile(ams::sf::Out> out, const fssrv::sf::Path &path, u32 mode) { auto read_lock = this->AcquireCacheInvalidationReadLock(); util::unique_lock open_count_semaphore; - if (this->open_count_limited) { + if (m_open_count_limited) { /* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */ AMS_ABORT_UNLESS(false); } @@ -268,7 +268,7 @@ namespace ams::fssrv::impl { /* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */ std::unique_ptr file; - R_TRY(this->base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast(mode))); + R_TRY(m_base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast(mode))); /* TODO: This is a hack to get the mitm API to work. Better solution? */ const auto target_object_id = file->GetDomainObjectId(); @@ -286,7 +286,7 @@ namespace ams::fssrv::impl { auto read_lock = this->AcquireCacheInvalidationReadLock(); util::unique_lock open_count_semaphore; - if (this->open_count_limited) { + if (m_open_count_limited) { /* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */ AMS_ABORT_UNLESS(false); } @@ -296,7 +296,7 @@ namespace ams::fssrv::impl { /* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */ std::unique_ptr dir; - R_TRY(this->base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast(mode))); + R_TRY(m_base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast(mode))); /* TODO: This is a hack to get the mitm API to work. Better solution? */ const auto target_object_id = dir->GetDomainObjectId(); @@ -311,7 +311,7 @@ namespace ams::fssrv::impl { Result FileSystemInterfaceAdapter::Commit() { auto read_lock = this->AcquireCacheInvalidationReadLock(); - return this->base_fs->Commit(); + return m_base_fs->Commit(); } Result FileSystemInterfaceAdapter::GetFreeSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path) { @@ -320,7 +320,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->GetFreeSpaceSize(out.GetPointer(), normalizer.GetPath()); + return m_base_fs->GetFreeSpaceSize(out.GetPointer(), normalizer.GetPath()); } Result FileSystemInterfaceAdapter::GetTotalSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path) { @@ -329,7 +329,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->GetTotalSpaceSize(out.GetPointer(), normalizer.GetPath()); + return m_base_fs->GetTotalSpaceSize(out.GetPointer(), normalizer.GetPath()); } Result FileSystemInterfaceAdapter::CleanDirectoryRecursively(const fssrv::sf::Path &path) { @@ -338,7 +338,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->CleanDirectoryRecursively(normalizer.GetPath()); + return m_base_fs->CleanDirectoryRecursively(normalizer.GetPath()); } Result FileSystemInterfaceAdapter::GetFileTimeStampRaw(ams::sf::Out out, const fssrv::sf::Path &path) { @@ -347,7 +347,7 @@ namespace ams::fssrv::impl { PathNormalizer normalizer(path.str); R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult()); - return this->base_fs->GetFileTimeStampRaw(out.GetPointer(), normalizer.GetPath()); + return m_base_fs->GetFileTimeStampRaw(out.GetPointer(), normalizer.GetPath()); } Result FileSystemInterfaceAdapter::QueryEntry(const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const fssrv::sf::Path &path) { @@ -357,7 +357,7 @@ namespace ams::fssrv::impl { char *dst = reinterpret_cast< char *>(out_buf.GetPointer()); const char *src = reinterpret_cast(in_buf.GetPointer()); - return this->base_fs->QueryEntry(dst, out_buf.GetSize(), src, in_buf.GetSize(), static_cast(query_id), path.str); + return m_base_fs->QueryEntry(dst, out_buf.GetSize(), src, in_buf.GetSize(), static_cast(query_id), path.str); } } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_exp_heap.cpp b/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_exp_heap.cpp index ce2b7c989..44dde37bd 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_exp_heap.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_exp_heap.cpp @@ -30,8 +30,8 @@ namespace ams::fssrv { AMS_UNUSED(size); if (p != nullptr) { - this->current_free_size = GetUsedSize(p); - this->peak_free_size = std::min(this->peak_free_size, this->current_free_size); + m_current_free_size = GetUsedSize(p); + m_peak_free_size = std::min(m_peak_free_size, m_current_free_size); } } @@ -39,14 +39,14 @@ namespace ams::fssrv { AMS_UNUSED(size); if (p != nullptr) { - this->current_free_size += GetUsedSize(p); + m_current_free_size += GetUsedSize(p); } } void *PeakCheckableMemoryResourceFromExpHeap::AllocateImpl(size_t size, size_t align) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - void *p = lmem::AllocateFromExpHeap(this->heap_handle, size, static_cast(align)); + void *p = lmem::AllocateFromExpHeap(m_heap_handle, size, static_cast(align)); this->OnAllocate(p, size); return p; } @@ -54,10 +54,10 @@ namespace ams::fssrv { void PeakCheckableMemoryResourceFromExpHeap::DeallocateImpl(void *p, size_t size, size_t align) { AMS_UNUSED(align); - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); this->OnDeallocate(p, size); - lmem::FreeToExpHeap(this->heap_handle, p); + lmem::FreeToExpHeap(m_heap_handle, p); } } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_standard_allocator.cpp b/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_standard_allocator.cpp index 52d2f876c..d198aac65 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_standard_allocator.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_memory_resource_from_standard_allocator.cpp @@ -17,28 +17,28 @@ namespace ams::fssrv { - MemoryResourceFromStandardAllocator::MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator) : allocator(allocator), mutex() { - this->current_free_size = this->allocator->GetTotalFreeSize(); + MemoryResourceFromStandardAllocator::MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator) : m_allocator(allocator), m_mutex() { + m_current_free_size = m_allocator->GetTotalFreeSize(); this->ClearPeak(); } void MemoryResourceFromStandardAllocator::ClearPeak() { - std::scoped_lock lk(this->mutex); - this->peak_free_size = this->current_free_size; - this->peak_allocated_size = 0; + std::scoped_lock lk(m_mutex); + m_peak_free_size = m_current_free_size; + m_peak_allocated_size = 0; } void *MemoryResourceFromStandardAllocator::AllocateImpl(size_t size, size_t align) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - void *p = this->allocator->Allocate(size, align); + void *p = m_allocator->Allocate(size, align); if (p != nullptr) { - this->current_free_size -= this->allocator->GetSizeOf(p); - this->peak_free_size = std::min(this->peak_free_size, this->current_free_size); + m_current_free_size -= m_allocator->GetSizeOf(p); + m_peak_free_size = std::min(m_peak_free_size, m_current_free_size); } - this->peak_allocated_size = std::max(this->peak_allocated_size, size); + m_peak_allocated_size = std::max(m_peak_allocated_size, size); return p; } @@ -46,10 +46,10 @@ namespace ams::fssrv { void MemoryResourceFromStandardAllocator::DeallocateImpl(void *p, size_t size, size_t align) { AMS_UNUSED(size, align); - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - this->current_free_size += this->allocator->GetSizeOf(p); - this->allocator->Free(p); + m_current_free_size += m_allocator->GetSizeOf(p); + m_allocator->Free(p); } } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp index 5e757162d..b29f5ca6d 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp @@ -18,15 +18,15 @@ namespace ams::fssrv::impl { - StorageInterfaceAdapter::StorageInterfaceAdapter(fs::IStorage *storage) : base_storage(storage) { + StorageInterfaceAdapter::StorageInterfaceAdapter(fs::IStorage *storage) : m_base_storage(storage) { /* ... */ } - StorageInterfaceAdapter::StorageInterfaceAdapter(std::unique_ptr storage) : base_storage(storage.release()) { + StorageInterfaceAdapter::StorageInterfaceAdapter(std::unique_ptr storage) : m_base_storage(storage.release()) { /* ... */ } - StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr storage) : base_storage(std::move(storage)) { + StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr storage) : m_base_storage(std::move(storage)) { /* ... */ } @@ -36,8 +36,8 @@ namespace ams::fssrv::impl { util::optional> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() { util::optional> lock; - if (this->deep_retry_enabled) { - lock.emplace(this->invalidation_lock); + if (m_deep_retry_enabled) { + lock.emplace(m_invalidation_lock); } return lock; } @@ -47,7 +47,7 @@ namespace ams::fssrv::impl { /* TODO: Deep retry */ R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); R_UNLESS(size >= 0, fs::ResultInvalidSize()); - return this->base_storage->Read(offset, buffer.GetPointer(), size); + return m_base_storage->Read(offset, buffer.GetPointer(), size); } Result StorageInterfaceAdapter::Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size) { @@ -56,23 +56,23 @@ namespace ams::fssrv::impl { R_UNLESS(size >= 0, fs::ResultInvalidSize()); auto read_lock = this->AcquireCacheInvalidationReadLock(); - return this->base_storage->Write(offset, buffer.GetPointer(), size); + return m_base_storage->Write(offset, buffer.GetPointer(), size); } Result StorageInterfaceAdapter::Flush() { auto read_lock = this->AcquireCacheInvalidationReadLock(); - return this->base_storage->Flush(); + return m_base_storage->Flush(); } Result StorageInterfaceAdapter::SetSize(s64 size) { R_UNLESS(size >= 0, fs::ResultInvalidSize()); auto read_lock = this->AcquireCacheInvalidationReadLock(); - return this->base_storage->SetSize(size); + return m_base_storage->SetSize(size); } Result StorageInterfaceAdapter::GetSize(ams::sf::Out out) { auto read_lock = this->AcquireCacheInvalidationReadLock(); - return this->base_storage->GetSize(out.GetPointer()); + return m_base_storage->GetSize(out.GetPointer()); } Result StorageInterfaceAdapter::OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size) { @@ -84,7 +84,7 @@ namespace ams::fssrv::impl { auto read_lock = this->AcquireCacheInvalidationReadLock(); fs::StorageQueryRangeInfo info; - R_TRY(this->base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); + R_TRY(m_base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0)); out->Merge(info); } diff --git a/libraries/libstratosphere/source/fssystem/buffers/fssystem_buffer_manager_utils.cpp b/libraries/libstratosphere/source/fssystem/buffers/fssystem_buffer_manager_utils.cpp index 419f53389..37f1f13bd 100644 --- a/libraries/libstratosphere/source/fssystem/buffers/fssystem_buffer_manager_utils.cpp +++ b/libraries/libstratosphere/source/fssystem/buffers/fssystem_buffer_manager_utils.cpp @@ -23,14 +23,14 @@ namespace ams::fssystem::buffers { class ThreadLocalStorageWrapper { private: - os::TlsSlot tls_slot; + os::TlsSlot m_tls_slot; public: - ThreadLocalStorageWrapper() { R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(this->tls_slot), nullptr)); } - ~ThreadLocalStorageWrapper() { os::FreeTlsSlot(this->tls_slot); } + ThreadLocalStorageWrapper() { R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(m_tls_slot), nullptr)); } + ~ThreadLocalStorageWrapper() { os::FreeTlsSlot(m_tls_slot); } - void SetValue(uintptr_t value) { os::SetTlsValue(this->tls_slot, value); } - uintptr_t GetValue() const { return os::GetTlsValue(this->tls_slot); } - os::TlsSlot GetTlsSlot() const { return this->tls_slot; } + void SetValue(uintptr_t value) { os::SetTlsValue(m_tls_slot, value); } + uintptr_t GetValue() const { return os::GetTlsValue(m_tls_slot); } + os::TlsSlot GetTlsSlot() const { return m_tls_slot; } } g_buffer_manager_context_tls_slot; } diff --git a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buddy_heap.cpp b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buddy_heap.cpp index c415f715d..bf7738d84 100644 --- a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buddy_heap.cpp +++ b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buddy_heap.cpp @@ -18,22 +18,22 @@ namespace ams::fssystem { FileSystemBuddyHeap::PageEntry *FileSystemBuddyHeap::PageList::PopFront() { - AMS_ASSERT(this->entry_count > 0); + AMS_ASSERT(m_entry_count > 0); /* Get the first entry. */ - auto page_entry = this->first_page_entry; + auto page_entry = m_first_page_entry; /* Advance our list. */ - this->first_page_entry = page_entry->next; + m_first_page_entry = page_entry->next; page_entry->next = nullptr; /* Decrement our count. */ - --this->entry_count; - AMS_ASSERT(this->entry_count >= 0); + --m_entry_count; + AMS_ASSERT(m_entry_count >= 0); /* If this was our last page, clear our last entry. */ - if (this->entry_count == 0) { - this->last_page_entry = nullptr; + if (m_entry_count == 0) { + m_last_page_entry = nullptr; } return page_entry; @@ -44,20 +44,20 @@ namespace ams::fssystem { /* If we're empty, we want to set the first page entry. */ if (this->IsEmpty()) { - this->first_page_entry = page_entry; + m_first_page_entry = page_entry; } else { /* We're not empty, so push the page to the back. */ - AMS_ASSERT(this->last_page_entry != page_entry); - this->last_page_entry->next = page_entry; + AMS_ASSERT(m_last_page_entry != page_entry); + m_last_page_entry->next = page_entry; } /* Set our last page entry to be this one, and link it to the list. */ - this->last_page_entry = page_entry; - this->last_page_entry->next = nullptr; + m_last_page_entry = page_entry; + m_last_page_entry->next = nullptr; /* Increment our entry count. */ - ++this->entry_count; - AMS_ASSERT(this->entry_count > 0); + ++m_entry_count; + AMS_ASSERT(m_entry_count > 0); } bool FileSystemBuddyHeap::PageList::Remove(PageEntry *page_entry) { @@ -70,18 +70,18 @@ namespace ams::fssystem { /* We're going to loop over all pages to find this one, then unlink it. */ PageEntry *prev_entry = nullptr; - PageEntry *cur_entry = this->first_page_entry; + PageEntry *cur_entry = m_first_page_entry; while (true) { /* Check if we found the page. */ if (cur_entry == page_entry) { - if (cur_entry == this->first_page_entry) { + if (cur_entry == m_first_page_entry) { /* If it's the first page, we just set our first. */ - this->first_page_entry = cur_entry->next; - } else if (cur_entry == this->last_page_entry) { + m_first_page_entry = cur_entry->next; + } else if (cur_entry == m_last_page_entry) { /* If it's the last page, we set our last. */ - this->last_page_entry = prev_entry; - this->last_page_entry->next = nullptr; + m_last_page_entry = prev_entry; + m_last_page_entry->next = nullptr; } else { /* If it's in the middle, we just unlink. */ prev_entry->next = cur_entry->next; @@ -91,8 +91,8 @@ namespace ams::fssystem { cur_entry->next = nullptr; /* Update our entry count. */ - --this->entry_count; - AMS_ASSERT(this->entry_count >= 0); + --m_entry_count; + AMS_ASSERT(m_entry_count >= 0); return true; } @@ -110,7 +110,7 @@ namespace ams::fssystem { Result FileSystemBuddyHeap::Initialize(uintptr_t address, size_t size, size_t block_size, s32 order_max) { /* Ensure our preconditions. */ - AMS_ASSERT(this->free_lists == nullptr); + AMS_ASSERT(m_free_lists == nullptr); AMS_ASSERT(address != 0); AMS_ASSERT(util::IsAligned(address, BufferAlignment)); AMS_ASSERT(block_size >= BlockSizeMin); @@ -120,74 +120,74 @@ namespace ams::fssystem { AMS_ASSERT(order_max < OrderUpperLimit); /* Set up our basic member variables */ - this->block_size = block_size; - this->order_max = order_max; - this->heap_start = address; - this->heap_size = (size / this->block_size) * this->block_size; + m_block_size = block_size; + m_order_max = order_max; + m_heap_start = address; + m_heap_size = (size / m_block_size) * m_block_size; - this->total_free_size = 0; + m_total_free_size = 0; /* Determine page sizes. */ - const auto max_page_size = this->block_size << this->order_max; - const auto max_page_count = util::AlignUp(this->heap_size, max_page_size) / max_page_size; + const auto max_page_size = m_block_size << m_order_max; + const auto max_page_count = util::AlignUp(m_heap_size, max_page_size) / max_page_size; AMS_ASSERT(max_page_count > 0); /* Setup the free lists. */ - if (this->external_free_lists != nullptr) { - AMS_ASSERT(this->internal_free_lists == nullptr); - this->free_lists = this->external_free_lists; + if (m_external_free_lists != nullptr) { + AMS_ASSERT(m_internal_free_lists == nullptr); + m_free_lists = m_external_free_lists; } else { - this->internal_free_lists.reset(new PageList[this->order_max + 1]); - this->free_lists = this->internal_free_lists.get(); - R_UNLESS(this->free_lists != nullptr, fs::ResultAllocationFailureInFileSystemBuddyHeapA()); + m_internal_free_lists.reset(new PageList[m_order_max + 1]); + m_free_lists = m_internal_free_lists.get(); + R_UNLESS(m_free_lists != nullptr, fs::ResultAllocationFailureInFileSystemBuddyHeapA()); } /* All but the last page region should go to the max order. */ for (size_t i = 0; i < max_page_count - 1; i++) { - auto page_entry = this->GetPageEntryFromAddress(this->heap_start + i * max_page_size); - this->free_lists[this->order_max].PushBack(page_entry); + auto page_entry = this->GetPageEntryFromAddress(m_heap_start + i * max_page_size); + m_free_lists[m_order_max].PushBack(page_entry); } - this->total_free_size += this->free_lists[this->order_max].GetSize() * this->GetBytesFromOrder(this->order_max); + m_total_free_size += m_free_lists[m_order_max].GetSize() * this->GetBytesFromOrder(m_order_max); /* Allocate remaining space to smaller orders as possible. */ { - auto remaining = this->heap_size - (max_page_count - 1) * max_page_size; - auto cur_address = this->heap_start + (max_page_count - 1) * max_page_size; - AMS_ASSERT(util::IsAligned(remaining, this->block_size)); + auto remaining = m_heap_size - (max_page_count - 1) * max_page_size; + auto cur_address = m_heap_start + (max_page_count - 1) * max_page_size; + AMS_ASSERT(util::IsAligned(remaining, m_block_size)); do { /* Determine what order we can use. */ auto order = GetOrderFromBytes(remaining + 1); if (order < 0) { - AMS_ASSERT(GetOrderFromBytes(remaining) == this->order_max); - order = this->order_max + 1; + AMS_ASSERT(GetOrderFromBytes(remaining) == m_order_max); + order = m_order_max + 1; } AMS_ASSERT(0 < order); - AMS_ASSERT(order <= this->order_max + 1); + AMS_ASSERT(order <= m_order_max + 1); /* Add to the correct free list. */ - this->free_lists[order - 1].PushBack(GetPageEntryFromAddress(cur_address)); - this->total_free_size += GetBytesFromOrder(order - 1); + m_free_lists[order - 1].PushBack(GetPageEntryFromAddress(cur_address)); + m_total_free_size += GetBytesFromOrder(order - 1); /* Move on to the next order. */ const auto page_size = GetBytesFromOrder(order - 1); cur_address += page_size; remaining -= page_size; - } while (this->block_size <= remaining); + } while (m_block_size <= remaining); } return ResultSuccess(); } void FileSystemBuddyHeap::Finalize() { - AMS_ASSERT(this->free_lists != nullptr); - this->free_lists = nullptr; - this->external_free_lists = nullptr; - this->internal_free_lists.reset(); + AMS_ASSERT(m_free_lists != nullptr); + m_free_lists = nullptr; + m_external_free_lists = nullptr; + m_internal_free_lists.reset(); } void *FileSystemBuddyHeap::AllocateByOrder(s32 order) { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); AMS_ASSERT(order >= 0); AMS_ASSERT(order <= this->GetOrderMax()); @@ -204,7 +204,7 @@ namespace ams::fssystem { } void FileSystemBuddyHeap::Free(void *ptr, s32 order) { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); AMS_ASSERT(order >= 0); AMS_ASSERT(order <= this->GetOrderMax()); @@ -214,7 +214,7 @@ namespace ams::fssystem { } /* Ensure the pointer is block aligned. */ - AMS_ASSERT(util::IsAligned(reinterpret_cast(ptr) - this->heap_start, this->GetBlockSize())); + AMS_ASSERT(util::IsAligned(reinterpret_cast(ptr) - m_heap_start, this->GetBlockSize())); /* Get the page entry. */ auto page_entry = this->GetPageEntryFromAddress(reinterpret_cast(ptr)); @@ -225,16 +225,16 @@ namespace ams::fssystem { } size_t FileSystemBuddyHeap::GetTotalFreeSize() const { - AMS_ASSERT(this->free_lists != nullptr); - return this->total_free_size; + AMS_ASSERT(m_free_lists != nullptr); + return m_total_free_size; } size_t FileSystemBuddyHeap::GetAllocatableSizeMax() const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); /* The maximum allocatable size is a chunk from the biggest non-empty order. */ for (s32 order = this->GetOrderMax(); order >= 0; --order) { - if (!this->free_lists[order].IsEmpty()) { + if (!m_free_lists[order].IsEmpty()) { return this->GetBytesFromOrder(order); } } @@ -244,7 +244,7 @@ namespace ams::fssystem { } void FileSystemBuddyHeap::Dump() const { - AMS_ASSERT(this->free_lists != nullptr); + AMS_ASSERT(m_free_lists != nullptr); /* TODO: Support logging metrics. */ } @@ -263,8 +263,8 @@ namespace ams::fssystem { auto divided_entry = this->GetPageEntryFromAddress(address); /* Push back to the list. */ - this->free_lists[order - 1].PushBack(divided_entry); - this->total_free_size += this->GetBytesFromOrder(order - 1); + m_free_lists[order - 1].PushBack(divided_entry); + m_total_free_size += this->GetBytesFromOrder(order - 1); } } @@ -281,8 +281,8 @@ namespace ams::fssystem { const auto buddy_entry = this->GetBuddy(cur_entry, cur_order); /* Check whether the buddy is in the relevant free list. */ - if (buddy_entry != nullptr && this->free_lists[cur_order].Remove(buddy_entry)) { - this->total_free_size -= GetBytesFromOrder(cur_order); + if (buddy_entry != nullptr && m_free_lists[cur_order].Remove(buddy_entry)) { + m_total_free_size -= GetBytesFromOrder(cur_order); /* Ensure we coalesce with the correct buddy when page is aligned */ if (!this->IsAlignedToOrder(cur_entry, cur_order + 1)) { @@ -297,8 +297,8 @@ namespace ams::fssystem { } /* Insert the coalesced entry into the free list. */ - this->free_lists[cur_order].PushBack(cur_entry); - this->total_free_size += this->GetBytesFromOrder(cur_order); + m_free_lists[cur_order].PushBack(cur_entry); + m_total_free_size += this->GetBytesFromOrder(cur_order); } FileSystemBuddyHeap::PageEntry *FileSystemBuddyHeap::GetBuddy(PageEntry *page_entry, s32 order) { @@ -311,10 +311,10 @@ namespace ams::fssystem { if (this->IsAlignedToOrder(page_entry, order + 1)) { /* If the page entry is aligned to the next order, return the buddy block to the right of the current entry. */ - return (address + offset < this->heap_start + this->heap_size) ? GetPageEntryFromAddress(address + offset) : nullptr; + return (address + offset < m_heap_start + m_heap_size) ? GetPageEntryFromAddress(address + offset) : nullptr; } else { /* If the page entry isn't aligned, return the buddy block to the left of the current entry. */ - return (this->heap_start <= address - offset) ? GetPageEntryFromAddress(address - offset) : nullptr; + return (m_heap_start <= address - offset) ? GetPageEntryFromAddress(address - offset) : nullptr; } } @@ -324,13 +324,13 @@ namespace ams::fssystem { /* Try orders from low to high until we find a free page entry. */ for (auto cur_order = order; cur_order <= this->GetOrderMax(); cur_order++) { - if (auto &free_list = this->free_lists[cur_order]; !free_list.IsEmpty()) { + if (auto &free_list = m_free_lists[cur_order]; !free_list.IsEmpty()) { /* The current list isn't empty, so grab an entry from it. */ PageEntry *page_entry = free_list.PopFront(); AMS_ASSERT(page_entry != nullptr); /* Update size bookkeeping. */ - this->total_free_size -= GetBytesFromOrder(cur_order); + m_total_free_size -= GetBytesFromOrder(cur_order); /* If we allocated more memory than needed, free the unneeded portion. */ this->DivideBuddies(page_entry, order, cur_order); diff --git a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp index 6ecf3244c..8333d947a 100644 --- a/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp +++ b/libraries/libstratosphere/source/fssystem/buffers/fssystem_file_system_buffer_manager.cpp @@ -19,54 +19,54 @@ namespace ams::fssystem { Result FileSystemBufferManager::CacheHandleTable::Initialize(s32 max_cache_count) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries == nullptr); - AMS_ASSERT(this->internal_entry_buffer == nullptr); + AMS_ASSERT(m_entries == nullptr); + AMS_ASSERT(m_internal_entry_buffer == nullptr); /* If we don't have an external buffer, try to allocate an internal one. */ - if (this->external_entry_buffer == nullptr) { - this->entry_buffer_size = sizeof(Entry) * max_cache_count; - this->internal_entry_buffer = fs::impl::MakeUnique(this->entry_buffer_size); + if (m_external_entry_buffer == nullptr) { + m_entry_buffer_size = sizeof(Entry) * max_cache_count; + m_internal_entry_buffer = fs::impl::MakeUnique(m_entry_buffer_size); } /* We need to have at least one entry buffer. */ - R_UNLESS(this->internal_entry_buffer != nullptr || this->external_entry_buffer != nullptr, fs::ResultAllocationFailureInFileSystemBufferManagerA()); + R_UNLESS(m_internal_entry_buffer != nullptr || m_external_entry_buffer != nullptr, fs::ResultAllocationFailureInFileSystemBufferManagerA()); /* Set entries. */ - this->entries = reinterpret_cast(this->external_entry_buffer != nullptr ? this->external_entry_buffer : this->internal_entry_buffer.get()); - this->entry_count = 0; - this->entry_count_max = max_cache_count; - AMS_ASSERT(this->entries != nullptr); + m_entries = reinterpret_cast(m_external_entry_buffer != nullptr ? m_external_entry_buffer : m_internal_entry_buffer.get()); + m_entry_count = 0; + m_entry_count_max = max_cache_count; + AMS_ASSERT(m_entries != nullptr); - this->cache_count_min = max_cache_count / 16; - this->cache_size_min = this->cache_count_min * 0x100; + m_cache_count_min = max_cache_count / 16; + m_cache_size_min = m_cache_count_min * 0x100; return ResultSuccess(); } void FileSystemBufferManager::CacheHandleTable::Finalize() { - if (this->entries != nullptr) { - AMS_ASSERT(this->entry_count == 0); + if (m_entries != nullptr) { + AMS_ASSERT(m_entry_count == 0); - if (this->external_attr_info_buffer == nullptr) { - auto it = this->attr_list.begin(); - while (it != this->attr_list.end()) { + if (m_external_attr_info_buffer == nullptr) { + auto it = m_attr_list.begin(); + while (it != m_attr_list.end()) { const auto attr_info = std::addressof(*it); - it = this->attr_list.erase(it); + it = m_attr_list.erase(it); delete attr_info; } } - this->internal_entry_buffer.reset(); - this->external_entry_buffer = nullptr; - this->entry_buffer_size = 0; - this->entries = nullptr; - this->total_cache_size = 0; + m_internal_entry_buffer.reset(); + m_external_entry_buffer = nullptr; + m_entry_buffer_size = 0; + m_entries = nullptr; + m_total_cache_size = 0; } } bool FileSystemBufferManager::CacheHandleTable::Register(CacheHandle *out, uintptr_t address, size_t size, const BufferAttribute &attr) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); AMS_ASSERT(out != nullptr); /* Get the entry. */ @@ -85,10 +85,10 @@ namespace ams::fssystem { /* Make a new attr info and add it to the list. */ AttrInfo *new_info = nullptr; - if (this->external_attr_info_buffer == nullptr) { + if (m_external_attr_info_buffer == nullptr) { new_info = new AttrInfo(attr.GetLevel(), 1, size); - } else if (0 <= attr.GetLevel() && attr.GetLevel() < this->external_attr_info_count) { - void *buffer = this->external_attr_info_buffer + attr.GetLevel() * sizeof(AttrInfo); + } else if (0 <= attr.GetLevel() && attr.GetLevel() < m_external_attr_info_count) { + void *buffer = m_external_attr_info_buffer + attr.GetLevel() * sizeof(AttrInfo); new_info = std::construct_at(reinterpret_cast(buffer), attr.GetLevel(), 1, size); } @@ -98,27 +98,27 @@ namespace ams::fssystem { return false; } - this->attr_list.push_back(*new_info); + m_attr_list.push_back(*new_info); } - this->total_cache_size += size; + m_total_cache_size += size; *out = entry->GetHandle(); return true; } bool FileSystemBufferManager::CacheHandleTable::Unregister(uintptr_t *out_address, size_t *out_size, CacheHandle handle) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); AMS_ASSERT(out_address != nullptr); AMS_ASSERT(out_size != nullptr); /* Find the lower bound for the entry. */ - const auto entry = std::lower_bound(this->entries, this->entries + this->entry_count, handle, [](const Entry &entry, CacheHandle handle) { + const auto entry = std::lower_bound(m_entries, m_entries + m_entry_count, handle, [](const Entry &entry, CacheHandle handle) { return entry.GetHandle() < handle; }); /* If the entry is a match, unregister it. */ - if (entry != this->entries + this->entry_count && entry->GetHandle() == handle) { + if (entry != m_entries + m_entry_count && entry->GetHandle() == handle) { this->UnregisterCore(out_address, out_size, entry); return true; } else { @@ -130,12 +130,12 @@ namespace ams::fssystem { AMS_UNUSED(attr, required_size); /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); AMS_ASSERT(out_address != nullptr); AMS_ASSERT(out_size != nullptr); /* If we have no entries, we can't unregister any. */ - if (this->entry_count == 0) { + if (m_entry_count == 0) { return false; } @@ -150,19 +150,19 @@ namespace ams::fssystem { }; /* Find an entry, falling back to the first entry. */ - auto entry = std::find_if(this->entries, this->entries + this->entry_count, CanUnregister); - if (entry == this->entries + this->entry_count) { - entry = this->entries; + auto entry = std::find_if(m_entries, m_entries + m_entry_count, CanUnregister); + if (entry == m_entries + m_entry_count) { + entry = m_entries; } - AMS_ASSERT(entry != this->entries + this->entry_count); + AMS_ASSERT(entry != m_entries + m_entry_count); this->UnregisterCore(out_address, out_size, entry); return true; } void FileSystemBufferManager::CacheHandleTable::UnregisterCore(uintptr_t *out_address, size_t *out_size, Entry *entry) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); AMS_ASSERT(out_address != nullptr); AMS_ASSERT(out_size != nullptr); AMS_ASSERT(entry != nullptr); @@ -178,8 +178,8 @@ namespace ams::fssystem { attr_info->SubtractCacheSize(entry->GetSize()); /* Release from cached size. */ - AMS_ASSERT(this->total_cache_size >= entry->GetSize()); - this->total_cache_size -= entry->GetSize(); + AMS_ASSERT(m_total_cache_size >= entry->GetSize()); + m_total_cache_size -= entry->GetSize(); /* Release the entry. */ *out_address = entry->GetAddress(); @@ -188,24 +188,24 @@ namespace ams::fssystem { } FileSystemBufferManager::CacheHandle FileSystemBufferManager::CacheHandleTable::PublishCacheHandle() { - AMS_ASSERT(this->entries != nullptr); - return (++this->current_handle); + AMS_ASSERT(m_entries != nullptr); + return (++m_current_handle); } size_t FileSystemBufferManager::CacheHandleTable::GetTotalCacheSize() const { - return this->total_cache_size; + return m_total_cache_size; } FileSystemBufferManager::CacheHandleTable::Entry *FileSystemBufferManager::CacheHandleTable::AcquireEntry(uintptr_t address, size_t size, const BufferAttribute &attr) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); Entry *entry = nullptr; - if (this->entry_count < this->entry_count_max) { - entry = this->entries + this->entry_count; + if (m_entry_count < m_entry_count_max) { + entry = m_entries + m_entry_count; entry->Initialize(this->PublishCacheHandle(), address, size, attr); - ++this->entry_count; - AMS_ASSERT(this->entry_count == 1 || (entry-1)->GetHandle() < entry->GetHandle()); + ++m_entry_count; + AMS_ASSERT(m_entry_count == 1 || (entry-1)->GetHandle() < entry->GetHandle()); } return entry; @@ -213,52 +213,52 @@ namespace ams::fssystem { void FileSystemBufferManager::CacheHandleTable::ReleaseEntry(Entry *entry) { /* Validate pre-conditions. */ - AMS_ASSERT(this->entries != nullptr); + AMS_ASSERT(m_entries != nullptr); AMS_ASSERT(entry != nullptr); /* Ensure the entry is valid. */ { - const auto entry_buffer = this->external_entry_buffer != nullptr ? this->external_entry_buffer : this->internal_entry_buffer.get(); + const auto entry_buffer = m_external_entry_buffer != nullptr ? m_external_entry_buffer : m_internal_entry_buffer.get(); AMS_ASSERT(static_cast(entry_buffer) <= static_cast(entry)); - AMS_ASSERT(static_cast(entry) < static_cast(entry_buffer + this->entry_buffer_size)); + AMS_ASSERT(static_cast(entry) < static_cast(entry_buffer + m_entry_buffer_size)); AMS_UNUSED(entry_buffer); } /* Copy the entries back by one. */ - std::memmove(entry, entry + 1, sizeof(Entry) * (this->entry_count - ((entry + 1) - this->entries))); + std::memmove(entry, entry + 1, sizeof(Entry) * (m_entry_count - ((entry + 1) - m_entries))); /* Decrement our entry count. */ - --this->entry_count; + --m_entry_count; } FileSystemBufferManager::CacheHandleTable::AttrInfo *FileSystemBufferManager::CacheHandleTable::FindAttrInfo(const BufferAttribute &attr) { - const auto it = std::find_if(this->attr_list.begin(), this->attr_list.end(), [&attr](const AttrInfo &info) { + const auto it = std::find_if(m_attr_list.begin(), m_attr_list.end(), [&attr](const AttrInfo &info) { return attr.GetLevel() == info.GetLevel(); }); - return it != this->attr_list.end() ? std::addressof(*it) : nullptr; + return it != m_attr_list.end() ? std::addressof(*it) : nullptr; } const std::pair FileSystemBufferManager::AllocateBufferImpl(size_t size, const BufferAttribute &attr) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); std::pair range = {}; - const auto order = this->buddy_heap.GetOrderFromBytes(size); + const auto order = m_buddy_heap.GetOrderFromBytes(size); AMS_ASSERT(order >= 0); while (true) { - if (auto address = this->buddy_heap.AllocateByOrder(order); address != 0) { - const auto allocated_size = this->buddy_heap.GetBytesFromOrder(order); + if (auto address = m_buddy_heap.AllocateByOrder(order); address != 0) { + const auto allocated_size = m_buddy_heap.GetBytesFromOrder(order); AMS_ASSERT(size <= allocated_size); range.first = reinterpret_cast(address); range.second = allocated_size; - const size_t free_size = this->buddy_heap.GetTotalFreeSize(); - this->peak_free_size = std::min(this->peak_free_size, free_size); + const size_t free_size = m_buddy_heap.GetTotalFreeSize(); + m_peak_free_size = std::min(m_peak_free_size, free_size); - const size_t total_allocatable_size = free_size + this->cache_handle_table.GetTotalCacheSize(); - this->peak_total_allocatable_size = std::min(this->peak_total_allocatable_size, total_allocatable_size); + const size_t total_allocatable_size = free_size + m_cache_handle_table.GetTotalCacheSize(); + m_peak_total_allocatable_size = std::min(m_peak_total_allocatable_size, total_allocatable_size); break; } @@ -266,8 +266,8 @@ namespace ams::fssystem { uintptr_t deallocate_address = 0; size_t deallocate_size = 0; - ++this->retried_count; - if (this->cache_handle_table.UnregisterOldest(std::addressof(deallocate_address), std::addressof(deallocate_size), attr, size)) { + ++m_retried_count; + if (m_cache_handle_table.UnregisterOldest(std::addressof(deallocate_address), std::addressof(deallocate_size), attr, size)) { this->DeallocateBuffer(deallocate_address, deallocate_size); } else { break; @@ -280,18 +280,18 @@ namespace ams::fssystem { void FileSystemBufferManager::DeallocateBufferImpl(uintptr_t address, size_t size) { AMS_ASSERT(util::IsPowerOfTwo(size)); - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - this->buddy_heap.Free(reinterpret_cast(address), this->buddy_heap.GetOrderFromBytes(size)); + m_buddy_heap.Free(reinterpret_cast(address), m_buddy_heap.GetOrderFromBytes(size)); } FileSystemBufferManager::CacheHandle FileSystemBufferManager::RegisterCacheImpl(uintptr_t address, size_t size, const BufferAttribute &attr) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); CacheHandle handle = 0; while (true) { /* Try to register the handle. */ - if (this->cache_handle_table.Register(std::addressof(handle), address, size, attr)) { + if (m_cache_handle_table.Register(std::addressof(handle), address, size, attr)) { break; } @@ -299,12 +299,12 @@ namespace ams::fssystem { uintptr_t deallocate_address = 0; size_t deallocate_size = 0; - ++this->retried_count; - if (this->cache_handle_table.UnregisterOldest(std::addressof(deallocate_address), std::addressof(deallocate_size), attr)) { + ++m_retried_count; + if (m_cache_handle_table.UnregisterOldest(std::addressof(deallocate_address), std::addressof(deallocate_size), attr)) { this->DeallocateBuffer(deallocate_address, deallocate_size); } else { this->DeallocateBuffer(address, size); - handle = this->cache_handle_table.PublishCacheHandle(); + handle = m_cache_handle_table.PublishCacheHandle(); break; } } @@ -313,12 +313,12 @@ namespace ams::fssystem { } const std::pair FileSystemBufferManager::AcquireCacheImpl(CacheHandle handle) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); std::pair range = {}; - if (this->cache_handle_table.Unregister(std::addressof(range.first), std::addressof(range.second), handle)) { - const size_t total_allocatable_size = this->buddy_heap.GetTotalFreeSize() + this->cache_handle_table.GetTotalCacheSize(); - this->peak_total_allocatable_size = std::min(this->peak_total_allocatable_size, total_allocatable_size); + if (m_cache_handle_table.Unregister(std::addressof(range.first), std::addressof(range.second), handle)) { + const size_t total_allocatable_size = m_buddy_heap.GetTotalFreeSize() + m_cache_handle_table.GetTotalCacheSize(); + m_peak_total_allocatable_size = std::min(m_peak_total_allocatable_size, total_allocatable_size); } else { range.first = 0; range.second = 0; @@ -328,34 +328,34 @@ namespace ams::fssystem { } size_t FileSystemBufferManager::GetTotalSizeImpl() const { - return this->total_size; + return m_total_size; } size_t FileSystemBufferManager::GetFreeSizeImpl() const { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - return this->buddy_heap.GetTotalFreeSize(); + return m_buddy_heap.GetTotalFreeSize(); } size_t FileSystemBufferManager::GetTotalAllocatableSizeImpl() const { - return this->GetFreeSize() + this->cache_handle_table.GetTotalCacheSize(); + return this->GetFreeSize() + m_cache_handle_table.GetTotalCacheSize(); } size_t FileSystemBufferManager::GetPeakFreeSizeImpl() const { - return this->peak_free_size; + return m_peak_free_size; } size_t FileSystemBufferManager::GetPeakTotalAllocatableSizeImpl() const { - return this->peak_total_allocatable_size; + return m_peak_total_allocatable_size; } size_t FileSystemBufferManager::GetRetriedCountImpl() const { - return this->retried_count; + return m_retried_count; } void FileSystemBufferManager::ClearPeakImpl() { - this->peak_free_size = this->GetFreeSize(); - this->retried_count = 0; + m_peak_free_size = this->GetFreeSize(); + m_retried_count = 0; } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp index db1566142..880d7af55 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp @@ -31,15 +31,15 @@ namespace ams::fssystem { static constexpr size_t KeySize = AesCtrCounterExtendedStorage::KeySize; static constexpr size_t IvSize = AesCtrCounterExtendedStorage::IvSize; private: - AesCtrCounterExtendedStorage::DecryptFunction decrypt_function; - s32 key_index; + AesCtrCounterExtendedStorage::DecryptFunction m_decrypt_function; + s32 m_key_index; public: - ExternalDecryptor(AesCtrCounterExtendedStorage::DecryptFunction df, s32 key_idx) : decrypt_function(df), key_index(key_idx) { - AMS_ASSERT(this->decrypt_function != nullptr); + ExternalDecryptor(AesCtrCounterExtendedStorage::DecryptFunction df, s32 key_idx) : m_decrypt_function(df), m_key_index(key_idx) { + AMS_ASSERT(m_decrypt_function != nullptr); } public: virtual void Decrypt(void *buf, size_t buf_size, const void *enc_key, size_t enc_key_size, void *iv, size_t iv_size) override final; - virtual bool HasExternalDecryptionKey() const override final { return this->key_index < 0; } + virtual bool HasExternalDecryptionKey() const override final { return m_key_index < 0; } }; } @@ -86,22 +86,22 @@ namespace ams::fssystem { AMS_ASSERT(decryptor != nullptr); /* Initialize the bucket tree table. */ - R_TRY(this->table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count)); + R_TRY(m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count)); /* Set members. */ - this->data_storage = data_storage; - std::memcpy(this->key, key, key_size); - this->secure_value = secure_value; - this->counter_offset = counter_offset; - this->decryptor = std::move(decryptor); + m_data_storage = data_storage; + std::memcpy(m_key, key, key_size); + m_secure_value = secure_value; + m_counter_offset = counter_offset; + m_decryptor = std::move(decryptor); return ResultSuccess(); } void AesCtrCounterExtendedStorage::Finalize() { if (this->IsInitialized()) { - this->table.Finalize(); - this->data_storage = fs::SubStorage(); + m_table.Finalize(); + m_data_storage = fs::SubStorage(); } } @@ -117,21 +117,21 @@ namespace ams::fssystem { R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(util::IsAligned(offset, BlockSize), fs::ResultInvalidOffset()); R_UNLESS(util::IsAligned(size, BlockSize), fs::ResultInvalidSize()); - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); /* Read the data. */ - R_TRY(this->data_storage.Read(offset, buffer, size)); + R_TRY(m_data_storage.Read(offset, buffer, size)); /* Temporarily increase our thread priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); /* Find the offset in our tree. */ BucketTree::Visitor visitor; - R_TRY(this->table.Find(std::addressof(visitor), offset)); + R_TRY(m_table.Find(std::addressof(visitor), offset)); { const auto entry_offset = visitor.Get()->GetOffset(); - R_UNLESS(util::IsAligned(entry_offset, BlockSize), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); - R_UNLESS(0 <= entry_offset && this->table.Includes(entry_offset), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); + R_UNLESS(util::IsAligned(entry_offset, BlockSize), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); + R_UNLESS(0 <= entry_offset && m_table.Includes(entry_offset), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); } /* Prepare to read in chunks. */ @@ -152,9 +152,9 @@ namespace ams::fssystem { if (visitor.CanMoveNext()) { R_TRY(visitor.MoveNext()); next_entry_offset = visitor.Get()->GetOffset(); - R_UNLESS(this->table.Includes(next_entry_offset), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); + R_UNLESS(m_table.Includes(next_entry_offset), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); } else { - next_entry_offset = this->table.GetEnd(); + next_entry_offset = m_table.GetEnd(); } R_UNLESS(util::IsAligned(next_entry_offset, BlockSize), fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); R_UNLESS(cur_offset < next_entry_offset, fs::ResultInvalidAesCtrCounterExtendedEntryOffset()); @@ -170,14 +170,14 @@ namespace ams::fssystem { AMS_ASSERT(cur_size <= size); /* Make the CTR for the data we're decrypting. */ - const auto counter_offset = this->counter_offset + cur_entry_offset + data_offset; - NcaAesCtrUpperIv upper_iv = { .part = { .generation = static_cast(cur_entry.generation), .secure_value = this->secure_value } }; + const auto counter_offset = m_counter_offset + cur_entry_offset + data_offset; + NcaAesCtrUpperIv upper_iv = { .part = { .generation = static_cast(cur_entry.generation), .secure_value = m_secure_value } }; u8 iv[IvSize]; AesCtrStorage::MakeIv(iv, IvSize, upper_iv.value, counter_offset); /* Decrypt. */ - this->decryptor->Decrypt(cur_data, cur_size, this->key, KeySize, iv, IvSize); + m_decryptor->Decrypt(cur_data, cur_size, m_key, KeySize, iv, IvSize); /* Advance. */ cur_data += cur_size; @@ -201,13 +201,13 @@ namespace ams::fssystem { /* Validate arguments. */ R_UNLESS(util::IsAligned(offset, BlockSize), fs::ResultInvalidOffset()); R_UNLESS(util::IsAligned(size, BlockSize), fs::ResultInvalidSize()); - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); /* Invalidate our table's cache. */ - R_TRY(this->table.InvalidateCache()); + R_TRY(m_table.InvalidateCache()); /* Operate on our data storage. */ - R_TRY(this->data_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_data_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); return ResultSuccess(); } @@ -230,15 +230,15 @@ namespace ams::fssystem { /* Validate arguments. */ R_UNLESS(util::IsAligned(offset, BlockSize), fs::ResultInvalidOffset()); R_UNLESS(util::IsAligned(size, BlockSize), fs::ResultInvalidSize()); - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); /* Operate on our data storage. */ - R_TRY(this->data_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_data_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); /* Add in new flags. */ fs::QueryRangeInfo new_info; new_info.Clear(); - new_info.aes_ctr_key_type = static_cast(this->decryptor->HasExternalDecryptionKey() ? fs::AesCtrKeyTypeFlag::ExternalKeyForHardwareAes : fs::AesCtrKeyTypeFlag::InternalKeyForHardwareAes); + new_info.aes_ctr_key_type = static_cast(m_decryptor->HasExternalDecryptionKey() ? fs::AesCtrKeyTypeFlag::ExternalKeyForHardwareAes : fs::AesCtrKeyTypeFlag::InternalKeyForHardwareAes); /* Merge in the new info. */ reinterpret_cast(dst)->Merge(new_info); @@ -281,7 +281,7 @@ namespace ams::fssystem { size_t cur_size = std::min(pooled_buffer.GetSize(), remaining_size); u8 *dst = static_cast(buf) + cur_offset; - this->decrypt_function(pooled_buffer.GetBuffer(), cur_size, this->key_index, enc_key, enc_key_size, ctr, IvSize, dst, cur_size); + m_decrypt_function(pooled_buffer.GetBuffer(), cur_size, m_key_index, enc_key, enc_key_size, ctr, IvSize, dst, cur_size); std::memcpy(dst, pooled_buffer.GetBuffer(), cur_size); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp index a93e68a53..3f554969b 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp @@ -30,7 +30,7 @@ namespace ams::fssystem { util::StoreBigEndian(reinterpret_cast(out_addr + sizeof(u64)), static_cast(offset / BlockSize)); } - AesCtrStorage::AesCtrStorage(IStorage *base, const void *key, size_t key_size, const void *iv, size_t iv_size) : base_storage(base) { + AesCtrStorage::AesCtrStorage(IStorage *base, const void *key, size_t key_size, const void *iv, size_t iv_size) : m_base_storage(base) { AMS_ASSERT(base != nullptr); AMS_ASSERT(key != nullptr); AMS_ASSERT(iv != nullptr); @@ -38,8 +38,8 @@ namespace ams::fssystem { AMS_ASSERT(iv_size == IvSize); AMS_UNUSED(key_size, iv_size); - std::memcpy(this->key, key, KeySize); - std::memcpy(this->iv, iv, IvSize); + std::memcpy(m_key, key, KeySize); + std::memcpy(m_iv, iv, IvSize); } Result AesCtrStorage::Read(s64 offset, void *buffer, size_t size) { @@ -54,18 +54,18 @@ namespace ams::fssystem { R_UNLESS(util::IsAligned(size, BlockSize), fs::ResultInvalidArgument()); /* Read the data. */ - R_TRY(this->base_storage->Read(offset, buffer, size)); + R_TRY(m_base_storage->Read(offset, buffer, size)); /* Prepare to decrypt the data, with temporarily increased priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); /* Setup the counter. */ char ctr[IvSize]; - std::memcpy(ctr, this->iv, IvSize); + std::memcpy(ctr, m_iv, IvSize); AddCounter(ctr, IvSize, offset / BlockSize); /* Decrypt, ensure we decrypt correctly. */ - auto dec_size = crypto::DecryptAes128Ctr(buffer, size, this->key, KeySize, ctr, IvSize, buffer, size); + auto dec_size = crypto::DecryptAes128Ctr(buffer, size, m_key, KeySize, ctr, IvSize, buffer, size); R_UNLESS(size == dec_size, fs::ResultUnexpectedInAesCtrStorageA()); return ResultSuccess(); @@ -91,7 +91,7 @@ namespace ams::fssystem { /* Setup the counter. */ char ctr[IvSize]; - std::memcpy(ctr, this->iv, IvSize); + std::memcpy(ctr, m_iv, IvSize); AddCounter(ctr, IvSize, offset / BlockSize); /* Loop until all data is written. */ @@ -106,12 +106,12 @@ namespace ams::fssystem { { ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); - auto enc_size = crypto::EncryptAes128Ctr(write_buf, write_size, this->key, KeySize, ctr, IvSize, reinterpret_cast(buffer) + cur_offset, write_size); + auto enc_size = crypto::EncryptAes128Ctr(write_buf, write_size, m_key, KeySize, ctr, IvSize, reinterpret_cast(buffer) + cur_offset, write_size); R_UNLESS(enc_size == write_size, fs::ResultUnexpectedInAesCtrStorageA()); } /* Write the encrypted data. */ - R_TRY(this->base_storage->Write(offset + cur_offset, write_buf, write_size)); + R_TRY(m_base_storage->Write(offset + cur_offset, write_buf, write_size)); /* Advance. */ cur_offset += write_size; @@ -125,7 +125,7 @@ namespace ams::fssystem { } Result AesCtrStorage::Flush() { - return this->base_storage->Flush(); + return m_base_storage->Flush(); } Result AesCtrStorage::SetSize(s64 size) { @@ -134,7 +134,7 @@ namespace ams::fssystem { } Result AesCtrStorage::GetSize(s64 *out) { - return this->base_storage->GetSize(out); + return m_base_storage->GetSize(out); } Result AesCtrStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -160,7 +160,7 @@ namespace ams::fssystem { R_UNLESS(dst != nullptr, fs::ResultNullptrArgument()); R_UNLESS(dst_size == sizeof(fs::QueryRangeInfo), fs::ResultInvalidSize()); - R_TRY(this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); fs::QueryRangeInfo info; info.Clear(); @@ -171,7 +171,7 @@ namespace ams::fssystem { break; default: { - R_TRY(this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); } break; } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp index 78c1a3f68..2b82edb85 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_xts_storage.cpp @@ -17,19 +17,19 @@ namespace ams::fssystem { - AesXtsStorage::AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size) : base_storage(base), block_size(block_size), mutex() { + AesXtsStorage::AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size) : m_base_storage(base), m_block_size(block_size), m_mutex() { AMS_ASSERT(base != nullptr); AMS_ASSERT(key1 != nullptr); AMS_ASSERT(key2 != nullptr); AMS_ASSERT(iv != nullptr); AMS_ASSERT(key_size == KeySize); AMS_ASSERT(iv_size == IvSize); - AMS_ASSERT(util::IsAligned(this->block_size, AesBlockSize)); + AMS_ASSERT(util::IsAligned(m_block_size, AesBlockSize)); AMS_UNUSED(key_size, iv_size); - std::memcpy(this->key[0], key1, KeySize); - std::memcpy(this->key[1], key2, KeySize); - std::memcpy(this->iv, iv, IvSize); + std::memcpy(m_key[0], key1, KeySize); + std::memcpy(m_key[1], key2, KeySize); + std::memcpy(m_iv, iv, IvSize); } Result AesXtsStorage::Read(s64 offset, void *buffer, size_t size) { @@ -44,48 +44,48 @@ namespace ams::fssystem { R_UNLESS(util::IsAligned(size, AesBlockSize), fs::ResultInvalidArgument()); /* Read the data. */ - R_TRY(this->base_storage->Read(offset, buffer, size)); + R_TRY(m_base_storage->Read(offset, buffer, size)); /* Prepare to decrypt the data, with temporarily increased priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); /* Setup the counter. */ char ctr[IvSize]; - std::memcpy(ctr, this->iv, IvSize); - AddCounter(ctr, IvSize, offset / this->block_size); + std::memcpy(ctr, m_iv, IvSize); + AddCounter(ctr, IvSize, offset / m_block_size); /* Handle any unaligned data before the start. */ size_t processed_size = 0; - if ((offset % this->block_size) != 0) { + if ((offset % m_block_size) != 0) { /* Determine the size of the pre-data read. */ - const size_t skip_size = static_cast(offset - util::AlignDown(offset, this->block_size)); - const size_t data_size = std::min(size, this->block_size - skip_size); + const size_t skip_size = static_cast(offset - util::AlignDown(offset, m_block_size)); + const size_t data_size = std::min(size, m_block_size - skip_size); /* Decrypt into a pooled buffer. */ { - PooledBuffer tmp_buf(this->block_size, this->block_size); - AMS_ASSERT(tmp_buf.GetSize() >= this->block_size); + PooledBuffer tmp_buf(m_block_size, m_block_size); + AMS_ASSERT(tmp_buf.GetSize() >= m_block_size); std::memset(tmp_buf.GetBuffer(), 0, skip_size); std::memcpy(tmp_buf.GetBuffer() + skip_size, buffer, data_size); - const size_t dec_size = crypto::DecryptAes128Xts(tmp_buf.GetBuffer(), this->block_size, this->key[0], this->key[1], KeySize, ctr, IvSize, tmp_buf.GetBuffer(), this->block_size); - R_UNLESS(dec_size == this->block_size, fs::ResultUnexpectedInAesXtsStorageA()); + const size_t dec_size = crypto::DecryptAes128Xts(tmp_buf.GetBuffer(), m_block_size, m_key[0], m_key[1], KeySize, ctr, IvSize, tmp_buf.GetBuffer(), m_block_size); + R_UNLESS(dec_size == m_block_size, fs::ResultUnexpectedInAesXtsStorageA()); std::memcpy(buffer, tmp_buf.GetBuffer() + skip_size, data_size); } AddCounter(ctr, IvSize, 1); processed_size += data_size; - AMS_ASSERT(processed_size == std::min(size, this->block_size - skip_size)); + AMS_ASSERT(processed_size == std::min(size, m_block_size - skip_size)); } /* Decrypt aligned chunks. */ char *cur = static_cast(buffer) + processed_size; size_t remaining = size - processed_size; while (remaining > 0) { - const size_t cur_size = std::min(this->block_size, remaining); - const size_t dec_size = crypto::DecryptAes128Xts(cur, cur_size, this->key[0], this->key[1], KeySize, ctr, IvSize, cur, cur_size); + const size_t cur_size = std::min(m_block_size, remaining); + const size_t dec_size = crypto::DecryptAes128Xts(cur, cur_size, m_key[0], m_key[1], KeySize, ctr, IvSize, cur, cur_size); R_UNLESS(cur_size == dec_size, fs::ResultUnexpectedInAesXtsStorageA()); remaining -= cur_size; @@ -112,45 +112,45 @@ namespace ams::fssystem { PooledBuffer pooled_buffer; const bool use_work_buffer = !IsDeviceAddress(buffer); if (use_work_buffer) { - pooled_buffer.Allocate(size, this->block_size); + pooled_buffer.Allocate(size, m_block_size); } /* Setup the counter. */ char ctr[IvSize]; - std::memcpy(ctr, this->iv, IvSize); - AddCounter(ctr, IvSize, offset / this->block_size); + std::memcpy(ctr, m_iv, IvSize); + AddCounter(ctr, IvSize, offset / m_block_size); /* Handle any unaligned data before the start. */ size_t processed_size = 0; - if ((offset % this->block_size) != 0) { + if ((offset % m_block_size) != 0) { /* Determine the size of the pre-data read. */ - const size_t skip_size = static_cast(offset - util::AlignDown(offset, this->block_size)); - const size_t data_size = std::min(size, this->block_size - skip_size); + const size_t skip_size = static_cast(offset - util::AlignDown(offset, m_block_size)); + const size_t data_size = std::min(size, m_block_size - skip_size); /* Create an encryptor. */ /* NOTE: This is completely unnecessary, because crypto::EncryptAes128Xts is used below. */ /* However, Nintendo does it, so we will too. */ crypto::Aes128XtsEncryptor xts; - xts.Initialize(this->key[0], this->key[1], KeySize, ctr, IvSize); + xts.Initialize(m_key[0], m_key[1], KeySize, ctr, IvSize); /* Encrypt into a pooled buffer. */ { /* NOTE: Nintendo allocates a second pooled buffer here despite having one already allocated above. */ - PooledBuffer tmp_buf(this->block_size, this->block_size); - AMS_ASSERT(tmp_buf.GetSize() >= this->block_size); + PooledBuffer tmp_buf(m_block_size, m_block_size); + AMS_ASSERT(tmp_buf.GetSize() >= m_block_size); std::memset(tmp_buf.GetBuffer(), 0, skip_size); std::memcpy(tmp_buf.GetBuffer() + skip_size, buffer, data_size); - const size_t enc_size = crypto::EncryptAes128Xts(tmp_buf.GetBuffer(), this->block_size, this->key[0], this->key[1], KeySize, ctr, IvSize, tmp_buf.GetBuffer(), this->block_size); - R_UNLESS(enc_size == this->block_size, fs::ResultUnexpectedInAesXtsStorageA()); + const size_t enc_size = crypto::EncryptAes128Xts(tmp_buf.GetBuffer(), m_block_size, m_key[0], m_key[1], KeySize, ctr, IvSize, tmp_buf.GetBuffer(), m_block_size); + R_UNLESS(enc_size == m_block_size, fs::ResultUnexpectedInAesXtsStorageA()); - R_TRY(this->base_storage->Write(offset, tmp_buf.GetBuffer() + skip_size, data_size)); + R_TRY(m_base_storage->Write(offset, tmp_buf.GetBuffer() + skip_size, data_size)); } AddCounter(ctr, IvSize, 1); processed_size += data_size; - AMS_ASSERT(processed_size == std::min(size, this->block_size - skip_size)); + AMS_ASSERT(processed_size == std::min(size, m_block_size - skip_size)); } /* Encrypt aligned chunks. */ @@ -167,11 +167,11 @@ namespace ams::fssystem { size_t remaining_write = write_size; size_t encrypt_offset = 0; while (remaining_write > 0) { - const size_t cur_size = std::min(remaining_write, this->block_size); + const size_t cur_size = std::min(remaining_write, m_block_size); const void *src = static_cast(buffer) + processed_size + encrypt_offset; void *dst = use_work_buffer ? pooled_buffer.GetBuffer() + encrypt_offset : const_cast(src); - const size_t enc_size = crypto::EncryptAes128Xts(dst, cur_size, this->key[0], this->key[1], KeySize, ctr, IvSize, src, cur_size); + const size_t enc_size = crypto::EncryptAes128Xts(dst, cur_size, m_key[0], m_key[1], KeySize, ctr, IvSize, src, cur_size); R_UNLESS(enc_size == cur_size, fs::ResultUnexpectedInAesXtsStorageA()); AddCounter(ctr, IvSize, 1); @@ -183,7 +183,7 @@ namespace ams::fssystem { /* Write the encrypted data. */ const void *write_buf = use_work_buffer ? pooled_buffer.GetBuffer() : static_cast(buffer) + processed_size; - R_TRY(this->base_storage->Write(cur_offset, write_buf, write_size)); + R_TRY(m_base_storage->Write(cur_offset, write_buf, write_size)); /* Advance. */ cur_offset += write_size; @@ -195,17 +195,17 @@ namespace ams::fssystem { } Result AesXtsStorage::Flush() { - return this->base_storage->Flush(); + return m_base_storage->Flush(); } Result AesXtsStorage::SetSize(s64 size) { R_UNLESS(util::IsAligned(size, AesBlockSize), fs::ResultUnexpectedInAesXtsStorageA()); - return this->base_storage->SetSize(size); + return m_base_storage->SetSize(size); } Result AesXtsStorage::GetSize(s64 *out) { - return this->base_storage->GetSize(out); + return m_base_storage->GetSize(out); } Result AesXtsStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { @@ -216,7 +216,7 @@ namespace ams::fssystem { R_UNLESS(util::IsAligned(offset, AesBlockSize), fs::ResultInvalidArgument()); R_UNLESS(util::IsAligned(size, AesBlockSize), fs::ResultInvalidArgument()); - return this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_alignment_matching_storage_impl.cpp b/libraries/libstratosphere/source/fssystem/fssystem_alignment_matching_storage_impl.cpp index c779b669d..e8a8b449f 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_alignment_matching_storage_impl.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_alignment_matching_storage_impl.cpp @@ -203,39 +203,39 @@ namespace ams::fssystem { /* Determine extents. */ const auto offset_end = offset + static_cast(size); - const auto aligned_offset = util::AlignDown(offset, this->data_align); - const auto aligned_offset_end = util::AlignUp(offset_end, this->data_align); + const auto aligned_offset = util::AlignDown(offset, m_data_align); + const auto aligned_offset_end = util::AlignUp(offset_end, m_data_align); const auto aligned_size = static_cast(aligned_offset_end - aligned_offset); /* If we aren't aligned, we need to allocate a buffer. */ PooledBuffer pooled_buffer; if (aligned_offset != offset || aligned_size != size) { if (aligned_size <= pooled_buffer.GetAllocatableSizeMax()) { - pooled_buffer.Allocate(aligned_size, this->data_align); + pooled_buffer.Allocate(aligned_size, m_data_align); if (aligned_size <= pooled_buffer.GetSize()) { - R_TRY(this->base_storage->Read(aligned_offset, pooled_buffer.GetBuffer(), aligned_size)); + R_TRY(m_base_storage->Read(aligned_offset, pooled_buffer.GetBuffer(), aligned_size)); std::memcpy(buffer, pooled_buffer.GetBuffer() + (offset - aligned_offset), size); return ResultSuccess(); } else { - pooled_buffer.Shrink(this->data_align); + pooled_buffer.Shrink(m_data_align); } } else { - pooled_buffer.Allocate(this->data_align, this->data_align); + pooled_buffer.Allocate(m_data_align, m_data_align); } - AMS_ASSERT(pooled_buffer.GetSize() >= static_cast(this->data_align)); + AMS_ASSERT(pooled_buffer.GetSize() >= static_cast(m_data_align)); } /* Determine read extents for the aligned portion. */ - const auto core_offset = util::AlignUp(offset, this->data_align); - const auto core_offset_end = util::AlignDown(offset_end, this->data_align); + const auto core_offset = util::AlignUp(offset, m_data_align); + const auto core_offset_end = util::AlignDown(offset_end, m_data_align); /* Handle any data before the aligned portion. */ if (offset < core_offset) { const auto head_size = static_cast(core_offset - offset); AMS_ASSERT(head_size < size); - R_TRY(this->base_storage->Read(aligned_offset, pooled_buffer.GetBuffer(), this->data_align)); + R_TRY(m_base_storage->Read(aligned_offset, pooled_buffer.GetBuffer(), m_data_align)); std::memcpy(buffer, pooled_buffer.GetBuffer() + (offset - aligned_offset), head_size); } @@ -244,13 +244,13 @@ namespace ams::fssystem { const auto core_buffer = static_cast(buffer) + (core_offset - offset); const auto core_size = static_cast(core_offset_end - core_offset); - R_TRY(this->base_storage->Read(core_offset, core_buffer, core_size)); + R_TRY(m_base_storage->Read(core_offset, core_buffer, core_size)); } /* Handle any data after the aligned portion. */ if (core_offset_end < offset_end) { const auto tail_size = static_cast(offset_end - core_offset_end); - R_TRY(this->base_storage->Read(core_offset_end, pooled_buffer.GetBuffer(), this->data_align)); + R_TRY(m_base_storage->Read(core_offset_end, pooled_buffer.GetBuffer(), m_data_align)); std::memcpy(buffer, pooled_buffer.GetBuffer(), tail_size); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp b/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp index 73b7867b8..e66083f5f 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_bucket_tree.cpp @@ -31,43 +31,43 @@ namespace ams::fssystem { public: using difference_type = s64; private: - s64 offset; - s32 stride; + s64 m_offset; + s32 m_stride; public: - constexpr Offset(s64 offset, s32 stride) : offset(offset), stride(stride) { /* ... */ } + constexpr Offset(s64 offset, s32 stride) : m_offset(offset), m_stride(stride) { /* ... */ } - constexpr Offset &operator++() { this->offset += this->stride; return *this; } - constexpr Offset operator++(int) { Offset ret(*this); this->offset += this->stride; return ret; } + constexpr Offset &operator++() { m_offset += m_stride; return *this; } + constexpr Offset operator++(int) { Offset ret(*this); m_offset += m_stride; return ret; } - constexpr Offset &operator--() { this->offset -= this->stride; return *this; } - constexpr Offset operator--(int) { Offset ret(*this); this->offset -= this->stride; return ret; } + constexpr Offset &operator--() { m_offset -= m_stride; return *this; } + constexpr Offset operator--(int) { Offset ret(*this); m_offset -= m_stride; return ret; } - constexpr difference_type operator-(const Offset &rhs) const { return (this->offset - rhs.offset) / this->stride; } + constexpr difference_type operator-(const Offset &rhs) const { return (m_offset - rhs.m_offset) / m_stride; } - constexpr Offset operator+(difference_type ofs) const { return Offset(this->offset + ofs * this->stride, this->stride); } - constexpr Offset operator-(difference_type ofs) const { return Offset(this->offset - ofs * this->stride, this->stride); } + constexpr Offset operator+(difference_type ofs) const { return Offset(m_offset + ofs * m_stride, m_stride); } + constexpr Offset operator-(difference_type ofs) const { return Offset(m_offset - ofs * m_stride, m_stride); } - constexpr Offset &operator+=(difference_type ofs) { this->offset += ofs * this->stride; return *this; } - constexpr Offset &operator-=(difference_type ofs) { this->offset -= ofs * this->stride; return *this; } + constexpr Offset &operator+=(difference_type ofs) { m_offset += ofs * m_stride; return *this; } + constexpr Offset &operator-=(difference_type ofs) { m_offset -= ofs * m_stride; return *this; } - constexpr bool operator==(const Offset &rhs) const { return this->offset == rhs.offset; } - constexpr bool operator!=(const Offset &rhs) const { return this->offset != rhs.offset; } + constexpr bool operator==(const Offset &rhs) const { return m_offset == rhs.m_offset; } + constexpr bool operator!=(const Offset &rhs) const { return m_offset != rhs.m_offset; } - constexpr s64 Get() const { return this->offset; } + constexpr s64 Get() const { return m_offset; } }; private: - const Offset start; - const s32 count; - s32 index; + const Offset m_start; + const s32 m_count; + s32 m_index; public: - StorageNode(size_t size, s32 count) : start(NodeHeaderSize, static_cast(size)), count(count), index(-1) { /* ... */ } - StorageNode(s64 ofs, size_t size, s32 count) : start(NodeHeaderSize + ofs, static_cast(size)), count(count), index(-1) { /* ... */ } + StorageNode(size_t size, s32 count) : m_start(NodeHeaderSize, static_cast(size)), m_count(count), m_index(-1) { /* ... */ } + StorageNode(s64 ofs, size_t size, s32 count) : m_start(NodeHeaderSize + ofs, static_cast(size)), m_count(count), m_index(-1) { /* ... */ } - s32 GetIndex() const { return this->index; } + s32 GetIndex() const { return m_index; } void Find(const char *buffer, s64 virtual_address) { - s32 end = this->count; - auto pos = this->start; + s32 end = m_count; + auto pos = m_start; while (end > 0) { auto half = end / 2; @@ -84,12 +84,12 @@ namespace ams::fssystem { } } - this->index = static_cast(pos - this->start) - 1; + m_index = static_cast(pos - m_start) - 1; } Result Find(fs::SubStorage &storage, s64 virtual_address) { - s32 end = this->count; - auto pos = this->start; + s32 end = m_count; + auto pos = m_start; while (end > 0) { auto half = end / 2; @@ -106,7 +106,7 @@ namespace ams::fssystem { } } - this->index = static_cast(pos - this->start) - 1; + m_index = static_cast(pos - m_start) - 1; return ResultSuccess(); } }; @@ -153,19 +153,19 @@ namespace ams::fssystem { R_UNLESS(entry_count > 0, fs::ResultInvalidArgument()); /* Allocate node. */ - R_UNLESS(this->node_l1.Allocate(allocator, node_size), fs::ResultBufferAllocationFailed()); - auto node_guard = SCOPE_GUARD { this->node_l1.Free(node_size); }; + R_UNLESS(m_node_l1.Allocate(allocator, node_size), fs::ResultBufferAllocationFailed()); + auto node_guard = SCOPE_GUARD { m_node_l1.Free(node_size); }; /* Read node. */ - R_TRY(node_storage.Read(0, this->node_l1.Get(), node_size)); + R_TRY(node_storage.Read(0, m_node_l1.Get(), node_size)); /* Verify node. */ - R_TRY(this->node_l1->Verify(0, node_size, sizeof(s64))); + R_TRY(m_node_l1->Verify(0, node_size, sizeof(s64))); /* Validate offsets. */ const auto offset_count = GetOffsetCount(node_size); const auto entry_set_count = GetEntrySetCount(node_size, entry_size, entry_count); - const auto * const node = this->node_l1.Get(); + const auto * const node = m_node_l1.Get(); s64 start_offset; if (offset_count < entry_set_count && node->GetCount() < offset_count) { @@ -179,15 +179,15 @@ namespace ams::fssystem { R_UNLESS(start_offset < end_offset, fs::ResultInvalidBucketTreeEntryOffset()); /* Set member variables. */ - this->node_storage = node_storage; - this->entry_storage = entry_storage; - this->node_size = node_size; - this->entry_size = entry_size; - this->entry_count = entry_count; - this->offset_count = offset_count; - this->entry_set_count = entry_set_count; - this->start_offset = start_offset; - this->end_offset = end_offset; + m_node_storage = node_storage; + m_entry_storage = entry_storage; + m_node_size = node_size; + m_entry_size = entry_size; + m_entry_count = entry_count; + m_offset_count = offset_count; + m_entry_set_count = entry_set_count; + m_start_offset = start_offset; + m_end_offset = end_offset; /* Cancel guard. */ node_guard.Cancel(); @@ -200,22 +200,22 @@ namespace ams::fssystem { AMS_ASSERT(end_offset > 0); AMS_ASSERT(!this->IsInitialized()); - this->node_size = node_size; - this->end_offset = end_offset; + m_node_size = node_size; + m_end_offset = end_offset; } void BucketTree::Finalize() { if (this->IsInitialized()) { - this->node_storage = fs::SubStorage(); - this->entry_storage = fs::SubStorage(); - this->node_l1.Free(this->node_size); - this->node_size = 0; - this->entry_size = 0; - this->entry_count = 0; - this->offset_count = 0; - this->entry_set_count = 0; - this->start_offset = 0; - this->end_offset = 0; + m_node_storage = fs::SubStorage(); + m_entry_storage = fs::SubStorage(); + m_node_l1.Free(m_node_size); + m_node_size = 0; + m_entry_size = 0; + m_entry_count = 0; + m_offset_count = 0; + m_entry_set_count = 0; + m_start_offset = 0; + m_end_offset = 0; } } @@ -235,23 +235,23 @@ namespace ams::fssystem { /* Invalidate the node storage cache. */ { s64 storage_size; - R_TRY(this->node_storage.GetSize(std::addressof(storage_size))); - R_TRY(this->node_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size)); + R_TRY(m_node_storage.GetSize(std::addressof(storage_size))); + R_TRY(m_node_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size)); } /* Refresh start/end offsets. */ { /* Read node. */ - R_TRY(node_storage.Read(0, this->node_l1.Get(), this->node_size)); + R_TRY(m_node_storage.Read(0, m_node_l1.Get(), m_node_size)); /* Verify node. */ - R_TRY(this->node_l1->Verify(0, this->node_size, sizeof(s64))); + R_TRY(m_node_l1->Verify(0, m_node_size, sizeof(s64))); /* Validate offsets. */ - const auto * const node = this->node_l1.Get(); + const auto * const node = m_node_l1.Get(); s64 start_offset; - if (offset_count < this->entry_set_count && node->GetCount() < this->offset_count) { + if (m_offset_count < m_entry_set_count && node->GetCount() < m_offset_count) { start_offset = *node->GetEnd(); } else { start_offset = *node->GetBegin(); @@ -262,15 +262,15 @@ namespace ams::fssystem { R_UNLESS(start_offset < end_offset, fs::ResultInvalidBucketTreeEntryOffset()); /* Set refreshed offsets. */ - this->start_offset = start_offset; - this->end_offset = end_offset; + m_start_offset = start_offset; + m_end_offset = end_offset; } /* Invalidate the entry storage cache. */ { s64 storage_size; - R_TRY(this->entry_storage.GetSize(std::addressof(storage_size))); - R_TRY(this->entry_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size)); + R_TRY(m_entry_storage.GetSize(std::addressof(storage_size))); + R_TRY(m_entry_storage.OperateRange(fs::OperationId::Invalidate, 0, storage_size)); } return ResultSuccess(); @@ -278,13 +278,13 @@ namespace ams::fssystem { Result BucketTree::Visitor::Initialize(const BucketTree *tree) { AMS_ASSERT(tree != nullptr); - AMS_ASSERT(this->tree == nullptr || this->tree == tree); + AMS_ASSERT(m_tree == nullptr || m_tree == tree); - if (this->entry == nullptr) { - this->entry = tree->GetAllocator()->Allocate(tree->entry_size); - R_UNLESS(this->entry != nullptr, fs::ResultBufferAllocationFailed()); + if (m_entry == nullptr) { + m_entry = tree->GetAllocator()->Allocate(tree->m_entry_size); + R_UNLESS(m_entry != nullptr, fs::ResultBufferAllocationFailed()); - this->tree = tree; + m_tree = tree; } return ResultSuccess(); @@ -294,35 +294,35 @@ namespace ams::fssystem { R_UNLESS(this->IsValid(), fs::ResultOutOfRange()); /* Invalidate our index, and read the header for the next index. */ - auto entry_index = this->entry_index + 1; - if (entry_index == this->entry_set.info.count) { - const auto entry_set_index = this->entry_set.info.index + 1; - R_UNLESS(entry_set_index < this->entry_set_count, fs::ResultOutOfRange()); + auto entry_index = m_entry_index + 1; + if (entry_index == m_entry_set.info.count) { + const auto entry_set_index = m_entry_set.info.index + 1; + R_UNLESS(entry_set_index < m_entry_set_count, fs::ResultOutOfRange()); - this->entry_index = -1; + m_entry_index = -1; - const auto end = this->entry_set.info.end; + const auto end = m_entry_set.info.end; - const auto entry_set_size = this->tree->node_size; + const auto entry_set_size = m_tree->m_node_size; const auto entry_set_offset = entry_set_index * static_cast(entry_set_size); - R_TRY(this->tree->entry_storage.Read(entry_set_offset, std::addressof(this->entry_set), sizeof(EntrySetHeader))); - R_TRY(this->entry_set.header.Verify(entry_set_index, entry_set_size, this->tree->entry_size)); + R_TRY(m_tree->m_entry_storage.Read(entry_set_offset, std::addressof(m_entry_set), sizeof(EntrySetHeader))); + R_TRY(m_entry_set.header.Verify(entry_set_index, entry_set_size, m_tree->m_entry_size)); - R_UNLESS(this->entry_set.info.start == end && this->entry_set.info.start < this->entry_set.info.end, fs::ResultInvalidBucketTreeEntrySetOffset()); + R_UNLESS(m_entry_set.info.start == end && m_entry_set.info.start < m_entry_set.info.end, fs::ResultInvalidBucketTreeEntrySetOffset()); entry_index = 0; } else { - this->entry_index = 1; + m_entry_index = 1; } /* Read the new entry. */ - const auto entry_size = this->tree->entry_size; - const auto entry_offset = impl::GetBucketTreeEntryOffset(this->entry_set.info.index, this->tree->node_size, entry_size, entry_index); - R_TRY(this->tree->entry_storage.Read(entry_offset, std::addressof(this->entry), entry_size)); + const auto entry_size = m_tree->m_entry_size; + const auto entry_offset = impl::GetBucketTreeEntryOffset(m_entry_set.info.index, m_tree->m_node_size, entry_size, entry_index); + R_TRY(m_tree->m_entry_storage.Read(entry_offset, std::addressof(m_entry), entry_size)); /* Note that we changed index. */ - this->entry_index = entry_index; + m_entry_index = entry_index; return ResultSuccess(); } @@ -330,52 +330,52 @@ namespace ams::fssystem { R_UNLESS(this->IsValid(), fs::ResultOutOfRange()); /* Invalidate our index, and read the heasder for the previous index. */ - auto entry_index = this->entry_index; + auto entry_index = m_entry_index; if (entry_index == 0) { - R_UNLESS(this->entry_set.info.index > 0, fs::ResultOutOfRange()); + R_UNLESS(m_entry_set.info.index > 0, fs::ResultOutOfRange()); - this->entry_index = -1; + m_entry_index = -1; - const auto start = this->entry_set.info.start; + const auto start = m_entry_set.info.start; - const auto entry_set_size = this->tree->node_size; - const auto entry_set_index = this->entry_set.info.index - 1; + const auto entry_set_size = m_tree->m_node_size; + const auto entry_set_index = m_entry_set.info.index - 1; const auto entry_set_offset = entry_set_index * static_cast(entry_set_size); - R_TRY(this->tree->entry_storage.Read(entry_set_offset, std::addressof(this->entry_set), sizeof(EntrySetHeader))); - R_TRY(this->entry_set.header.Verify(entry_set_index, entry_set_size, this->tree->entry_size)); + R_TRY(m_tree->m_entry_storage.Read(entry_set_offset, std::addressof(m_entry_set), sizeof(EntrySetHeader))); + R_TRY(m_entry_set.header.Verify(entry_set_index, entry_set_size, m_tree->m_entry_size)); - R_UNLESS(this->entry_set.info.end == start && this->entry_set.info.start < this->entry_set.info.end, fs::ResultInvalidBucketTreeEntrySetOffset()); + R_UNLESS(m_entry_set.info.end == start && m_entry_set.info.start < m_entry_set.info.end, fs::ResultInvalidBucketTreeEntrySetOffset()); - entry_index = this->entry_set.info.count; + entry_index = m_entry_set.info.count; } else { - this->entry_index = -1; + m_entry_index = -1; } --entry_index; /* Read the new entry. */ - const auto entry_size = this->tree->entry_size; - const auto entry_offset = impl::GetBucketTreeEntryOffset(this->entry_set.info.index, this->tree->node_size, entry_size, entry_index); - R_TRY(this->tree->entry_storage.Read(entry_offset, std::addressof(this->entry), entry_size)); + const auto entry_size = m_tree->m_entry_size; + const auto entry_offset = impl::GetBucketTreeEntryOffset(m_entry_set.info.index, m_tree->m_node_size, entry_size, entry_index); + R_TRY(m_tree->m_entry_storage.Read(entry_offset, std::addressof(m_entry), entry_size)); /* Note that we changed index. */ - this->entry_index = entry_index; + m_entry_index = entry_index; return ResultSuccess(); } Result BucketTree::Visitor::Find(s64 virtual_address) { - AMS_ASSERT(this->tree != nullptr); + AMS_ASSERT(m_tree != nullptr); /* Get the node. */ - const auto * const node = this->tree->node_l1.Get(); + const auto * const node = m_tree->m_node_l1.Get(); R_UNLESS(virtual_address < node->GetEndOffset(), fs::ResultOutOfRange()); /* Get the entry set index. */ s32 entry_set_index = -1; - if (this->tree->IsExistOffsetL2OnL1() && virtual_address < node->GetBeginOffset()) { + if (m_tree->IsExistOffsetL2OnL1() && virtual_address < node->GetBeginOffset()) { const auto start = node->GetEnd(); - const auto end = node->GetBegin() + tree->offset_count; + const auto end = node->GetBegin() + m_tree->m_offset_count; auto pos = std::upper_bound(start, end, virtual_address); R_UNLESS(start < pos, fs::ResultOutOfRange()); @@ -390,9 +390,9 @@ namespace ams::fssystem { R_UNLESS(start < pos, fs::ResultOutOfRange()); --pos; - if (this->tree->IsExistL2()) { + if (m_tree->IsExistL2()) { const auto node_index = static_cast(pos - start); - R_UNLESS(0 <= node_index && node_index < this->tree->offset_count, fs::ResultInvalidBucketTreeNodeOffset()); + R_UNLESS(0 <= node_index && node_index < m_tree->m_offset_count, fs::ResultInvalidBucketTreeNodeOffset()); R_TRY(this->FindEntrySet(std::addressof(entry_set_index), virtual_address, node_index)); } else { @@ -401,18 +401,18 @@ namespace ams::fssystem { } /* Validate the entry set index. */ - R_UNLESS(0 <= entry_set_index && entry_set_index < this->tree->entry_set_count, fs::ResultInvalidBucketTreeNodeOffset()); + R_UNLESS(0 <= entry_set_index && entry_set_index < m_tree->m_entry_set_count, fs::ResultInvalidBucketTreeNodeOffset()); /* Find the entry. */ R_TRY(this->FindEntry(virtual_address, entry_set_index)); /* Set count. */ - this->entry_set_count = this->tree->entry_set_count; + m_entry_set_count = m_tree->m_entry_set_count; return ResultSuccess(); } Result BucketTree::Visitor::FindEntrySet(s32 *out_index, s64 virtual_address, s32 node_index) { - const auto node_size = this->tree->node_size; + const auto node_size = m_tree->m_node_size; PooledBuffer pool(node_size, 1); if (node_size <= pool.GetSize()) { @@ -425,9 +425,9 @@ namespace ams::fssystem { Result BucketTree::Visitor::FindEntrySetWithBuffer(s32 *out_index, s64 virtual_address, s32 node_index, char *buffer) { /* Calculate node extents. */ - const auto node_size = this->tree->node_size; - const auto node_offset = (node_index + 1) * static_cast(node_size); - fs::SubStorage &storage = tree->node_storage; + const auto node_size = m_tree->m_node_size; + const auto node_offset = (node_index + 1) * static_cast(node_size); + fs::SubStorage &storage = m_tree->m_node_storage; /* Read the node. */ R_TRY(storage.Read(node_offset, buffer, node_size)); @@ -443,15 +443,15 @@ namespace ams::fssystem { R_UNLESS(node.GetIndex() >= 0, fs::ResultInvalidBucketTreeVirtualOffset()); /* Return the index. */ - *out_index = this->tree->GetEntrySetIndex(header.index, node.GetIndex()); + *out_index = m_tree->GetEntrySetIndex(header.index, node.GetIndex()); return ResultSuccess(); } Result BucketTree::Visitor::FindEntrySetWithoutBuffer(s32 *out_index, s64 virtual_address, s32 node_index) { /* Calculate node extents. */ - const auto node_size = this->tree->node_size; - const auto node_offset = (node_index + 1) * static_cast(node_size); - fs::SubStorage &storage = tree->node_storage; + const auto node_size = m_tree->m_node_size; + const auto node_offset = (node_index + 1) * static_cast(node_size); + fs::SubStorage &storage = m_tree->m_node_storage; /* Read and validate the header. */ NodeHeader header; @@ -464,12 +464,12 @@ namespace ams::fssystem { R_UNLESS(node.GetIndex() >= 0, fs::ResultOutOfRange()); /* Return the index. */ - *out_index = this->tree->GetEntrySetIndex(header.index, node.GetIndex()); + *out_index = m_tree->GetEntrySetIndex(header.index, node.GetIndex()); return ResultSuccess(); } Result BucketTree::Visitor::FindEntry(s64 virtual_address, s32 entry_set_index) { - const auto entry_set_size = this->tree->node_size; + const auto entry_set_size = m_tree->m_node_size; PooledBuffer pool(entry_set_size, 1); if (entry_set_size <= pool.GetSize()) { @@ -482,10 +482,10 @@ namespace ams::fssystem { Result BucketTree::Visitor::FindEntryWithBuffer(s64 virtual_address, s32 entry_set_index, char *buffer) { /* Calculate entry set extents. */ - const auto entry_size = this->tree->entry_size; - const auto entry_set_size = this->tree->node_size; + const auto entry_size = m_tree->m_entry_size; + const auto entry_set_size = m_tree->m_node_size; const auto entry_set_offset = entry_set_index * static_cast(entry_set_size); - fs::SubStorage &storage = tree->entry_storage; + fs::SubStorage &storage = m_tree->m_entry_storage; /* Read the entry set. */ R_TRY(storage.Read(entry_set_offset, buffer, entry_set_size)); @@ -503,21 +503,21 @@ namespace ams::fssystem { /* Copy the data into entry. */ const auto entry_index = node.GetIndex(); const auto entry_offset = impl::GetBucketTreeEntryOffset(0, entry_size, entry_index); - std::memcpy(this->entry, buffer + entry_offset, entry_size); + std::memcpy(m_entry, buffer + entry_offset, entry_size); /* Set our entry set/index. */ - this->entry_set = entry_set; - this->entry_index = entry_index; + m_entry_set = entry_set; + m_entry_index = entry_index; return ResultSuccess(); } Result BucketTree::Visitor::FindEntryWithoutBuffer(s64 virtual_address, s32 entry_set_index) { /* Calculate entry set extents. */ - const auto entry_size = this->tree->entry_size; - const auto entry_set_size = this->tree->node_size; + const auto entry_size = m_tree->m_entry_size; + const auto entry_set_size = m_tree->m_node_size; const auto entry_set_offset = entry_set_index * static_cast(entry_set_size); - fs::SubStorage &storage = tree->entry_storage; + fs::SubStorage &storage = m_tree->m_entry_storage; /* Read and validate the entry_set. */ EntrySetHeader entry_set; @@ -532,11 +532,11 @@ namespace ams::fssystem { /* Copy the data into entry. */ const auto entry_index = node.GetIndex(); const auto entry_offset = impl::GetBucketTreeEntryOffset(entry_set_offset, entry_size, entry_index); - R_TRY(storage.Read(entry_offset, this->entry, entry_size)); + R_TRY(storage.Read(entry_offset, m_entry, entry_size)); /* Set our entry set/index. */ - this->entry_set = entry_set; - this->entry_index = entry_index; + m_entry_set = entry_set; + m_entry_index = entry_index; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp index 33fe18286..b8be9c3d3 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp @@ -20,25 +20,25 @@ namespace ams::fssystem { DirectoryRedirectionFileSystem::DirectoryRedirectionFileSystem(std::shared_ptr fs, const char *before, const char *after, bool unc) : PathResolutionFileSystem(fs, unc) { - this->before_dir = nullptr; - this->after_dir = nullptr; + m_before_dir = nullptr; + m_after_dir = nullptr; R_ABORT_UNLESS(this->Initialize(before, after)); } DirectoryRedirectionFileSystem::DirectoryRedirectionFileSystem(std::unique_ptr fs, const char *before, const char *after, bool unc) : PathResolutionFileSystem(std::move(fs), unc) { - this->before_dir = nullptr; - this->after_dir = nullptr; + m_before_dir = nullptr; + m_after_dir = nullptr; R_ABORT_UNLESS(this->Initialize(before, after)); } DirectoryRedirectionFileSystem::~DirectoryRedirectionFileSystem() { - if (this->before_dir != nullptr) { - fs::impl::Deallocate(this->before_dir, this->before_dir_len); + if (m_before_dir != nullptr) { + fs::impl::Deallocate(m_before_dir, m_before_dir_len); } - if (this->after_dir != nullptr) { - fs::impl::Deallocate(this->after_dir, this->after_dir_len); + if (m_after_dir != nullptr) { + fs::impl::Deallocate(m_after_dir, m_after_dir_len); } } @@ -82,8 +82,8 @@ namespace ams::fssystem { Result DirectoryRedirectionFileSystem::Initialize(const char *before, const char *after) { /* Normalize both directories. */ - this->GetNormalizedDirectoryPath(std::addressof(this->before_dir), std::addressof(this->before_dir_len), before); - this->GetNormalizedDirectoryPath(std::addressof(this->after_dir), std::addressof(this->after_dir_len), after); + this->GetNormalizedDirectoryPath(std::addressof(m_before_dir), std::addressof(m_before_dir_len), before); + this->GetNormalizedDirectoryPath(std::addressof(m_after_dir), std::addressof(m_after_dir_len), after); return ResultSuccess(); } @@ -91,29 +91,29 @@ namespace ams::fssystem { Result DirectoryRedirectionFileSystem::ResolveFullPath(char *out, size_t out_size, const char *relative_path) { /* Check pre-conditions. */ AMS_ASSERT(relative_path[0] == '/'); - AMS_ASSERT(this->before_dir_len >= 2); - AMS_ASSERT(this->after_dir_len >= 2); - AMS_ASSERT(this->after_dir_len <= out_size); - AMS_ASSERT(fs::PathNormalizer::IsNullTerminator(this->before_dir[this->before_dir_len - 1])); - AMS_ASSERT(fs::PathNormalizer::IsSeparator(this->before_dir[this->before_dir_len - 2])); - AMS_ASSERT(fs::PathNormalizer::IsNullTerminator(this->after_dir[this->after_dir_len - 1])); - AMS_ASSERT(fs::PathNormalizer::IsSeparator(this->after_dir[this->after_dir_len - 2])); + AMS_ASSERT(m_before_dir_len >= 2); + AMS_ASSERT(m_after_dir_len >= 2); + AMS_ASSERT(m_after_dir_len <= out_size); + AMS_ASSERT(fs::PathNormalizer::IsNullTerminator(m_before_dir[m_before_dir_len - 1])); + AMS_ASSERT(fs::PathNormalizer::IsSeparator(m_before_dir[m_before_dir_len - 2])); + AMS_ASSERT(fs::PathNormalizer::IsNullTerminator(m_after_dir[m_after_dir_len - 1])); + AMS_ASSERT(fs::PathNormalizer::IsSeparator(m_after_dir[m_after_dir_len - 2])); /* Normalize the relative path. */ char normalized_rel_path[fs::EntryNameLengthMax + 1]; size_t normalized_rel_path_len; R_TRY(fs::PathNormalizer::Normalize(normalized_rel_path, std::addressof(normalized_rel_path_len), relative_path, sizeof(normalized_rel_path), this->IsUncPreserved(), false)); - const bool is_prefixed = std::memcmp(normalized_rel_path, this->before_dir, this->before_dir_len - 2) == 0 && - (fs::PathNormalizer::IsSeparator(normalized_rel_path[this->before_dir_len - 2]) || fs::PathNormalizer::IsNullTerminator(normalized_rel_path[this->before_dir_len - 2])); + const bool is_prefixed = std::memcmp(normalized_rel_path, m_before_dir, m_before_dir_len - 2) == 0 && + (fs::PathNormalizer::IsSeparator(normalized_rel_path[m_before_dir_len - 2]) || fs::PathNormalizer::IsNullTerminator(normalized_rel_path[m_before_dir_len - 2])); if (is_prefixed) { - const size_t before_prefix_len = this->before_dir_len - 2; - const size_t after_prefix_len = this->after_dir_len - 2; + const size_t before_prefix_len = m_before_dir_len - 2; + const size_t after_prefix_len = m_after_dir_len - 2; const size_t final_str_len = after_prefix_len + normalized_rel_path_len - before_prefix_len; R_UNLESS(final_str_len < out_size, fs::ResultTooLongPath()); /* Copy normalized path. */ - std::memcpy(out, this->after_dir, after_prefix_len); + std::memcpy(out, m_after_dir, after_prefix_len); std::memcpy(out + after_prefix_len, normalized_rel_path + before_prefix_len, normalized_rel_path_len - before_prefix_len); out[final_str_len] = fs::StringTraits::NullTerminator; } else { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 7a1d8a3b0..152c6d10b 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -27,60 +27,60 @@ namespace ams::fssystem { class DirectorySaveDataFile : public fs::fsa::IFile { private: - std::unique_ptr base_file; - DirectorySaveDataFileSystem *parent_fs; - fs::OpenMode open_mode; + std::unique_ptr m_base_file; + DirectorySaveDataFileSystem *m_parent_fs; + fs::OpenMode m_open_mode; public: - DirectorySaveDataFile(std::unique_ptr f, DirectorySaveDataFileSystem *p, fs::OpenMode m) : base_file(std::move(f)), parent_fs(p), open_mode(m) { + DirectorySaveDataFile(std::unique_ptr f, DirectorySaveDataFileSystem *p, fs::OpenMode m) : m_base_file(std::move(f)), m_parent_fs(p), m_open_mode(m) { /* ... */ } virtual ~DirectorySaveDataFile() { /* Observe closing of writable file. */ - if (this->open_mode & fs::OpenMode_Write) { - this->parent_fs->OnWritableFileClose(); + if (m_open_mode & fs::OpenMode_Write) { + m_parent_fs->OnWritableFileClose(); } } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override { - return this->base_file->Read(out, offset, buffer, size, option); + return m_base_file->Read(out, offset, buffer, size, option); } virtual Result DoGetSize(s64 *out) override { - return this->base_file->GetSize(out); + return m_base_file->GetSize(out); } virtual Result DoFlush() override { - return this->base_file->Flush(); + return m_base_file->Flush(); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override { - return this->base_file->Write(offset, buffer, size, option); + return m_base_file->Write(offset, buffer, size, option); } virtual Result DoSetSize(s64 size) override { - return this->base_file->SetSize(size); + return m_base_file->SetSize(size); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return this->base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return this->base_file->GetDomainObjectId(); + return m_base_file->GetDomainObjectId(); } }; } DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::shared_ptr fs) - : PathResolutionFileSystem(fs), accessor_mutex(), open_writable_files(0) + : PathResolutionFileSystem(fs), m_accessor_mutex(), m_open_writable_files(0) { /* ... */ } DirectorySaveDataFileSystem::DirectorySaveDataFileSystem(std::unique_ptr fs) - : PathResolutionFileSystem(std::move(fs)), accessor_mutex(), open_writable_files(0) + : PathResolutionFileSystem(std::move(fs)), m_accessor_mutex(), m_open_writable_files(0) { /* ... */ } @@ -91,25 +91,25 @@ namespace ams::fssystem { Result DirectorySaveDataFileSystem::Initialize() { /* Nintendo does not acquire the lock here, but I think we probably should. */ - std::scoped_lock lk(this->accessor_mutex); + std::scoped_lock lk(m_accessor_mutex); fs::DirectoryEntryType type; /* Check that the working directory exists. */ - R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) { + R_TRY_CATCH(m_base_fs->GetEntryType(std::addressof(type), WorkingDirectoryPath)) { /* If path isn't found, create working directory and committed directory. */ R_CATCH(fs::ResultPathNotFound) { - R_TRY(this->base_fs->CreateDirectory(WorkingDirectoryPath)); - R_TRY(this->base_fs->CreateDirectory(CommittedDirectoryPath)); + R_TRY(m_base_fs->CreateDirectory(WorkingDirectoryPath)); + R_TRY(m_base_fs->CreateDirectory(CommittedDirectoryPath)); } } R_END_TRY_CATCH; /* Now check for the committed directory. */ - R_TRY_CATCH(this->base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) { + R_TRY_CATCH(m_base_fs->GetEntryType(std::addressof(type), CommittedDirectoryPath)) { /* Committed doesn't exist, so synchronize and rename. */ R_CATCH(fs::ResultPathNotFound) { R_TRY(this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath)); - R_TRY(this->base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath)); + R_TRY(m_base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath)); return ResultSuccess(); } } R_END_TRY_CATCH; @@ -139,11 +139,11 @@ namespace ams::fssystem { Result DirectorySaveDataFileSystem::SynchronizeDirectory(const char *dst, const char *src) { /* Delete destination dir and recreate it. */ - R_TRY_CATCH(this->base_fs->DeleteDirectoryRecursively(dst)) { + R_TRY_CATCH(m_base_fs->DeleteDirectoryRecursively(dst)) { R_CATCH(fs::ResultPathNotFound) { /* Nintendo returns error unconditionally, but I think that's a bug in their code. */} } R_END_TRY_CATCH; - R_TRY(this->base_fs->CreateDirectory(dst)); + R_TRY(m_base_fs->CreateDirectory(dst)); /* Get a work buffer to work with. */ std::unique_ptr work_buf; @@ -151,7 +151,7 @@ namespace ams::fssystem { R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize)); /* Copy the directory recursively. */ - return fssystem::CopyDirectoryRecursively(this->base_fs, dst, src, work_buf.get(), work_buf_size); + return fssystem::CopyDirectoryRecursively(m_base_fs, dst, src, work_buf.get(), work_buf_size); } Result DirectorySaveDataFileSystem::ResolveFullPath(char *out, size_t out_size, const char *relative_path) { @@ -169,11 +169,11 @@ namespace ams::fssystem { } void DirectorySaveDataFileSystem::OnWritableFileClose() { - std::scoped_lock lk(this->accessor_mutex); - this->open_writable_files--; + std::scoped_lock lk(m_accessor_mutex); + m_open_writable_files--; /* Nintendo does not check this, but I think it's sensible to do so. */ - AMS_ABORT_UNLESS(this->open_writable_files >= 0); + AMS_ABORT_UNLESS(m_open_writable_files >= 0); } Result DirectorySaveDataFileSystem::CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs) { @@ -186,7 +186,7 @@ namespace ams::fssystem { R_TRY(this->AllocateWorkBuffer(std::addressof(work_buf), std::addressof(work_buf_size), IdealWorkBufferSize)); /* Copy the directory recursively. */ - R_TRY(fssystem::CopyDirectoryRecursively(this->base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size)); + R_TRY(fssystem::CopyDirectoryRecursively(m_base_fs, save_fs, fs::PathNormalizer::RootPath, fs::PathNormalizer::RootPath, work_buf.get(), work_buf_size)); return this->Commit(); } @@ -196,15 +196,15 @@ namespace ams::fssystem { char full_path[fs::EntryNameLengthMax + 1]; R_TRY(this->ResolveFullPath(full_path, sizeof(full_path), path)); - std::scoped_lock lk(this->accessor_mutex); + std::scoped_lock lk(m_accessor_mutex); std::unique_ptr base_file; - R_TRY(this->base_fs->OpenFile(std::addressof(base_file), full_path, mode)); + R_TRY(m_base_fs->OpenFile(std::addressof(base_file), full_path, mode)); std::unique_ptr file(new (std::nothrow) DirectorySaveDataFile(std::move(base_file), this, mode)); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem()); if (mode & fs::OpenMode_Write) { - this->open_writable_files++; + m_open_writable_files++; } *out_file = std::move(file); @@ -216,13 +216,13 @@ namespace ams::fssystem { /* - Rename Committed -> Synchronizing. */ /* - Synchronize Working -> Synchronizing (deleting Synchronizing). */ /* - Rename Synchronizing -> Committed. */ - std::scoped_lock lk(this->accessor_mutex); + std::scoped_lock lk(m_accessor_mutex); - R_UNLESS(this->open_writable_files == 0, fs::ResultPreconditionViolation()); + R_UNLESS(m_open_writable_files == 0, fs::ResultPreconditionViolation()); - const auto RenameCommitedDir = [&]() { return this->base_fs->RenameDirectory(CommittedDirectoryPath, SynchronizingDirectoryPath); }; + const auto RenameCommitedDir = [&]() { return m_base_fs->RenameDirectory(CommittedDirectoryPath, SynchronizingDirectoryPath); }; const auto SynchronizeWorkingDir = [&]() { return this->SynchronizeDirectory(SynchronizingDirectoryPath, WorkingDirectoryPath); }; - const auto RenameSynchronizingDir = [&]() { return this->base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath); }; + const auto RenameSynchronizingDir = [&]() { return m_base_fs->RenameDirectory(SynchronizingDirectoryPath, CommittedDirectoryPath); }; /* Rename Committed -> Synchronizing. */ R_TRY(fssystem::RetryFinitelyForTargetLocked(std::move(RenameCommitedDir))); @@ -233,7 +233,7 @@ namespace ams::fssystem { /* - Rename Synchronizing -> Committed. */ R_TRY(fssystem::RetryFinitelyForTargetLocked(std::move(RenameSynchronizingDir))); - /* TODO: Should I call this->base_fs->Commit()? Nintendo does not. */ + /* TODO: Should I call m_base_fs->Commit()? Nintendo does not. */ return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp index 256a5e95a..ebabc2fee 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.cpp @@ -41,21 +41,21 @@ namespace ams::fssystem { AMS_UNUSED(layer_count); /* Set size tracking members. */ - this->hash_target_block_size = htbs; - this->log_size_ratio = Log2(this->hash_target_block_size / HashSize); + m_hash_target_block_size = htbs; + m_log_size_ratio = Log2(m_hash_target_block_size / HashSize); /* Get the base storage size. */ - R_TRY(base_storages[2]->GetSize(std::addressof(this->base_storage_size))); + R_TRY(base_storages[2]->GetSize(std::addressof(m_base_storage_size))); { - auto size_guard = SCOPE_GUARD { this->base_storage_size = 0; }; - R_UNLESS(this->base_storage_size <= static_cast(HashSize) << log_size_ratio << log_size_ratio, fs::ResultHierarchicalSha256BaseStorageTooLarge()); + auto size_guard = SCOPE_GUARD { m_base_storage_size = 0; }; + R_UNLESS(m_base_storage_size <= static_cast(HashSize) << m_log_size_ratio << m_log_size_ratio, fs::ResultHierarchicalSha256BaseStorageTooLarge()); size_guard.Cancel(); } /* Set hash buffer tracking members. */ - this->base_storage = base_storages[2]; - this->hash_buffer = static_cast(hash_buf); - this->hash_buffer_size = hash_buf_size; + m_base_storage = base_storages[2]; + m_hash_buffer = static_cast(hash_buf); + m_hash_buffer_size = hash_buf_size; /* Read the master hash. */ u8 master_hash[HashSize]; @@ -65,14 +65,14 @@ namespace ams::fssystem { s64 hash_storage_size; R_TRY(base_storages[1]->GetSize(std::addressof(hash_storage_size))); AMS_ASSERT(util::IsAligned(hash_storage_size, HashSize)); - AMS_ASSERT(hash_storage_size <= this->hash_target_block_size); - AMS_ASSERT(hash_storage_size <= static_cast(this->hash_buffer_size)); + AMS_ASSERT(hash_storage_size <= m_hash_target_block_size); + AMS_ASSERT(hash_storage_size <= static_cast(m_hash_buffer_size)); - R_TRY(base_storages[1]->Read(0, this->hash_buffer, static_cast(hash_storage_size))); + R_TRY(base_storages[1]->Read(0, m_hash_buffer, static_cast(hash_storage_size))); /* Calculate and verify the master hash. */ u8 calc_hash[HashSize]; - crypto::GenerateSha256Hash(calc_hash, sizeof(calc_hash), this->hash_buffer, static_cast(hash_storage_size)); + crypto::GenerateSha256Hash(calc_hash, sizeof(calc_hash), m_hash_buffer, static_cast(hash_storage_size)); R_UNLESS(crypto::IsSameBytes(master_hash, calc_hash, HashSize), fs::ResultHierarchicalSha256HashVerificationFailed()); return ResultSuccess(); @@ -86,12 +86,12 @@ namespace ams::fssystem { R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); /* Validate preconditions. */ - R_UNLESS(util::IsAligned(offset, this->hash_target_block_size), fs::ResultInvalidArgument()); - R_UNLESS(util::IsAligned(size, this->hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(offset, m_hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(size, m_hash_target_block_size), fs::ResultInvalidArgument()); /* Read the data. */ - const size_t reduced_size = static_cast(std::min(this->base_storage_size, util::AlignUp(offset + size, this->hash_target_block_size) - offset)); - R_TRY(this->base_storage->Read(offset, buffer, reduced_size)); + const size_t reduced_size = static_cast(std::min(m_base_storage_size, util::AlignUp(offset + size, m_hash_target_block_size) - offset)); + R_TRY(m_base_storage->Read(offset, buffer, reduced_size)); /* Temporarily increase our thread priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); @@ -102,17 +102,17 @@ namespace ams::fssystem { while (remaining_size > 0) { /* Generate the hash of the region we're validating. */ u8 hash[HashSize]; - const auto cur_size = static_cast(std::min(this->hash_target_block_size, remaining_size)); + const auto cur_size = static_cast(std::min(m_hash_target_block_size, remaining_size)); crypto::GenerateSha256Hash(hash, sizeof(hash), static_cast(buffer) + (cur_offset - offset), cur_size); - AMS_ASSERT(static_cast(cur_offset >> this->log_size_ratio) < this->hash_buffer_size); + AMS_ASSERT(static_cast(cur_offset >> m_log_size_ratio) < m_hash_buffer_size); /* Check the hash. */ { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); auto clear_guard = SCOPE_GUARD { std::memset(buffer, 0, size); }; - R_UNLESS(crypto::IsSameBytes(hash, std::addressof(this->hash_buffer[cur_offset >> this->log_size_ratio]), HashSize), fs::ResultHierarchicalSha256HashVerificationFailed()); + R_UNLESS(crypto::IsSameBytes(hash, std::addressof(m_hash_buffer[cur_offset >> m_log_size_ratio]), HashSize), fs::ResultHierarchicalSha256HashVerificationFailed()); clear_guard.Cancel(); } @@ -133,17 +133,17 @@ namespace ams::fssystem { R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); /* Validate preconditions. */ - R_UNLESS(util::IsAligned(offset, this->hash_target_block_size), fs::ResultInvalidArgument()); - R_UNLESS(util::IsAligned(size, this->hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(offset, m_hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(size, m_hash_target_block_size), fs::ResultInvalidArgument()); /* Setup tracking variables. */ - const size_t reduced_size = static_cast(std::min(this->base_storage_size, util::AlignUp(offset + size, this->hash_target_block_size) - offset)); + const size_t reduced_size = static_cast(std::min(m_base_storage_size, util::AlignUp(offset + size, m_hash_target_block_size) - offset)); auto cur_offset = offset; auto remaining_size = reduced_size; while (remaining_size > 0) { /* Generate the hash of the region we're validating. */ u8 hash[HashSize]; - const auto cur_size = static_cast(std::min(this->hash_target_block_size, remaining_size)); + const auto cur_size = static_cast(std::min(m_hash_target_block_size, remaining_size)); { /* Temporarily increase our thread priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); @@ -151,12 +151,12 @@ namespace ams::fssystem { } /* Write the data. */ - R_TRY(this->base_storage->Write(cur_offset, static_cast(buffer) + (cur_offset - offset), cur_size)); + R_TRY(m_base_storage->Write(cur_offset, static_cast(buffer) + (cur_offset - offset), cur_size)); /* Write the hash. */ { - std::scoped_lock lk(this->mutex); - std::memcpy(std::addressof(this->hash_buffer[cur_offset >> this->log_size_ratio]), hash, HashSize); + std::scoped_lock lk(m_mutex); + std::memcpy(std::addressof(m_hash_buffer[cur_offset >> m_log_size_ratio]), hash, HashSize); } /* Advance. */ @@ -172,14 +172,14 @@ namespace ams::fssystem { R_SUCCEED_IF(size == 0); /* Validate preconditions. */ - R_UNLESS(util::IsAligned(offset, this->hash_target_block_size), fs::ResultInvalidArgument()); - R_UNLESS(util::IsAligned(size, this->hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(offset, m_hash_target_block_size), fs::ResultInvalidArgument()); + R_UNLESS(util::IsAligned(size, m_hash_target_block_size), fs::ResultInvalidArgument()); /* Determine size to use. */ - const auto reduced_size = std::min(this->base_storage_size, util::AlignUp(offset + size, this->hash_target_block_size) - offset); + const auto reduced_size = std::min(m_base_storage_size, util::AlignUp(offset + size, m_hash_target_block_size) - offset); /* Operate on the base storage. */ - return this->base_storage->OperateRange(dst, dst_size, op_id, offset, reduced_size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, offset, reduced_size, src, src_size); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp index 351219ff1..43ab21de3 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp @@ -25,15 +25,15 @@ namespace ams::fssystem { static constexpr s32 LayerCount = 3; static constexpr size_t HashSize = crypto::Sha256Generator::HashSize; private: - os::SdkMutex mutex; - IStorage *base_storage; - s64 base_storage_size; - char *hash_buffer; - size_t hash_buffer_size; - s32 hash_target_block_size; - s32 log_size_ratio; + os::SdkMutex m_mutex; + IStorage *m_base_storage; + s64 m_base_storage_size; + char *m_hash_buffer; + size_t m_hash_buffer_size; + s32 m_hash_target_block_size; + s32 m_log_size_ratio; public: - HierarchicalSha256Storage() : mutex() { /* ... */ } + HierarchicalSha256Storage() : m_mutex() { /* ... */ } Result Initialize(IStorage **base_storages, s32 layer_count, size_t htbs, void *hash_buf, size_t hash_buf_size); @@ -42,7 +42,7 @@ namespace ams::fssystem { virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override; virtual Result GetSize(s64 *out) override { - return this->base_storage->GetSize(out); + return m_base_storage->GetSize(out); } virtual Result Flush() override { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp index 91d470d42..fc88f965d 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp @@ -35,9 +35,9 @@ namespace ams::fssystem { void IndirectStorage::Finalize() { if (this->IsInitialized()) { - this->table.Finalize(); + m_table.Finalize(); for (auto i = 0; i < StorageCount; i++) { - this->data_storage[i] = fs::SubStorage(); + m_data_storage[i] = fs::SubStorage(); } } } @@ -59,14 +59,14 @@ namespace ams::fssystem { R_UNLESS(out_entries != nullptr || entry_count == 0, fs::ResultNullptrArgument()); /* Check that our range is valid. */ - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); /* Find the offset in our tree. */ BucketTree::Visitor visitor; - R_TRY(this->table.Find(std::addressof(visitor), offset)); + R_TRY(m_table.Find(std::addressof(visitor), offset)); { const auto entry_offset = visitor.Get()->GetVirtualOffset(); - R_UNLESS(0 <= entry_offset && this->table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset()); + R_UNLESS(0 <= entry_offset && m_table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset()); } /* Prepare to loop over entries. */ @@ -124,10 +124,10 @@ namespace ams::fssystem { { if (size > 0) { /* Validate arguments. */ - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); - if (!this->table.IsEmpty()) { + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); + if (!m_table.IsEmpty()) { /* Invalidate our table's cache. */ - R_TRY(this->table.InvalidateCache()); + R_TRY(m_table.InvalidateCache()); /* Operate on our entries. */ R_TRY(this->OperatePerEntry(offset, size, [=](fs::IStorage *storage, s64 data_offset, s64 cur_offset, s64 cur_size) -> Result { @@ -148,8 +148,8 @@ namespace ams::fssystem { if (size > 0) { /* Validate arguments. */ - R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange()); - if (!this->table.IsEmpty()) { + R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange()); + if (!m_table.IsEmpty()) { /* Create a new info. */ fs::QueryRangeInfo merged_info; merged_info.Clear(); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp index f72f660cf..64789a0c0 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp @@ -22,24 +22,24 @@ namespace ams::fssystem { AMS_ASSERT(bm != nullptr); /* Set master hash. */ - this->master_hash = master_hash; - this->master_hash_storage = std::make_unique(std::addressof(this->master_hash), sizeof(Hash)); - R_UNLESS(this->master_hash_storage != nullptr, fs::ResultAllocationFailureInIntegrityRomFsStorageA()); + m_master_hash = master_hash; + m_master_hash_storage = std::make_unique(std::addressof(m_master_hash), sizeof(Hash)); + R_UNLESS(m_master_hash_storage != nullptr, fs::ResultAllocationFailureInIntegrityRomFsStorageA()); /* Set the master hash storage. */ - storage_info[0] = fs::SubStorage(this->master_hash_storage.get(), 0, sizeof(Hash)); + storage_info[0] = fs::SubStorage(m_master_hash_storage.get(), 0, sizeof(Hash)); /* Set buffers. */ - for (size_t i = 0; i < util::size(this->buffers.buffers); ++i) { - this->buffers.buffers[i] = bm; + for (size_t i = 0; i < util::size(m_buffers.buffers); ++i) { + m_buffers.buffers[i] = bm; } /* Initialize our integrity storage. */ - return this->integrity_storage.Initialize(level_hash_info, storage_info, std::addressof(this->buffers), std::addressof(this->mutex), fs::StorageType_RomFs); + return m_integrity_storage.Initialize(level_hash_info, storage_info, std::addressof(m_buffers), std::addressof(m_mutex), fs::StorageType_RomFs); } void IntegrityRomFsStorage::Finalize() { - this->integrity_storage.Finalize(); + m_integrity_storage.Finalize(); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp b/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp index 8ee7cedc9..d1edb9ba3 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_key_slot_cache.hpp @@ -22,12 +22,12 @@ namespace ams::fssystem { NON_COPYABLE(KeySlotCacheAccessor); NON_MOVEABLE(KeySlotCacheAccessor); private: - util::unique_lock lk; - const s32 slot_index; + util::unique_lock m_lk; + const s32 m_slot_index; public: - KeySlotCacheAccessor(s32 idx, util::unique_lock &&l) : lk(std::move(l)), slot_index(idx) { /* ... */ } + KeySlotCacheAccessor(s32 idx, util::unique_lock &&l) : m_lk(std::move(l)), m_slot_index(idx) { /* ... */ } - s32 GetKeySlotIndex() const { return this->slot_index; } + s32 GetKeySlotIndex() const { return m_slot_index; } }; class KeySlotCacheEntry : public util::IntrusiveListBaseNode { @@ -36,27 +36,27 @@ namespace ams::fssystem { public: static constexpr size_t KeySize = crypto::AesDecryptor128::KeySize; private: - const s32 slot_index; - u8 key1[KeySize]; - s32 key2; + const s32 m_slot_index; + u8 m_key1[KeySize]; + s32 m_key2; public: - explicit KeySlotCacheEntry(s32 idx) : slot_index(idx), key2(-1) { - std::memset(this->key1, 0, sizeof(this->key1)); + explicit KeySlotCacheEntry(s32 idx) : m_slot_index(idx), m_key2(-1) { + std::memset(m_key1, 0, sizeof(m_key1)); } bool Contains(const void *key, size_t key_size, s32 key2) const { AMS_ASSERT(key_size == KeySize); AMS_UNUSED(key_size); - return key2 == this->key2 && std::memcmp(this->key1, key, KeySize) == 0; + return key2 == m_key2 && std::memcmp(m_key1, key, KeySize) == 0; } - s32 GetKeySlotIndex() const { return this->slot_index; } + s32 GetKeySlotIndex() const { return m_slot_index; } void SetKey(const void *key, size_t key_size, s32 key2) { AMS_ASSERT(key_size == KeySize); - std::memcpy(this->key1, key, key_size); - this->key2 = key2; + std::memcpy(m_key1, key, key_size); + m_key2 = key2; } }; @@ -66,24 +66,24 @@ namespace ams::fssystem { private: using KeySlotCacheEntryList = util::IntrusiveListBaseTraits::ListType; private: - os::SdkMutex mutex; - KeySlotCacheEntryList high_priority_mru_list; - KeySlotCacheEntryList low_priority_mru_list; + os::SdkMutex m_mutex; + KeySlotCacheEntryList m_high_priority_mru_list; + KeySlotCacheEntryList m_low_priority_mru_list; public: - constexpr KeySlotCache() : mutex(), high_priority_mru_list(), low_priority_mru_list() { /* ... */ } + constexpr KeySlotCache() : m_mutex(), m_high_priority_mru_list(), m_low_priority_mru_list() { /* ... */ } Result AllocateHighPriority(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { - return this->AllocateFromLru(out, this->high_priority_mru_list, key, key_size, key2); + return this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2); } Result AllocateLowPriority(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { - return this->AllocateFromLru(out, this->high_priority_mru_list, key, key_size, key2); + return this->AllocateFromLru(out, m_high_priority_mru_list, key, key_size, key2); } Result Find(std::unique_ptr *out, const void *key, size_t key_size, s32 key2) { - util::unique_lock lk(this->mutex); + util::unique_lock lk(m_mutex); - KeySlotCacheEntryList *lists[2] = { std::addressof(this->high_priority_mru_list), std::addressof(this->low_priority_mru_list) }; + KeySlotCacheEntryList *lists[2] = { std::addressof(m_high_priority_mru_list), std::addressof(m_low_priority_mru_list) }; for (auto list : lists) { for (auto it = list->begin(); it != list->end(); ++it) { if (it->Contains(key, key_size, key2)) { @@ -102,14 +102,14 @@ namespace ams::fssystem { } void AddEntry(KeySlotCacheEntry *entry) { - util::unique_lock lk(this->mutex); - this->low_priority_mru_list.push_front(*entry); + util::unique_lock lk(m_mutex); + m_low_priority_mru_list.push_front(*entry); } private: Result AllocateFromLru(std::unique_ptr *out, KeySlotCacheEntryList &dst_list, const void *key, size_t key_size, s32 key2) { - util::unique_lock lk(this->mutex); + util::unique_lock lk(m_mutex); - KeySlotCacheEntryList &src_list = this->low_priority_mru_list.empty() ? this->high_priority_mru_list : this->low_priority_mru_list; + KeySlotCacheEntryList &src_list = m_low_priority_mru_list.empty() ? m_high_priority_mru_list : m_low_priority_mru_list; AMS_ASSERT(!src_list.empty()); auto it = src_list.rbegin(); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_lru_list_cache.hpp b/libraries/libstratosphere/source/fssystem/fssystem_lru_list_cache.hpp index 4db29b77c..68bf127bd 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_lru_list_cache.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_lru_list_cache.hpp @@ -27,26 +27,26 @@ namespace ams::fssystem { NON_COPYABLE(Node); NON_MOVEABLE(Node); public: - Key key; - Value value; - util::IntrusiveListNode mru_list_node; + Key m_key; + Value m_value; + util::IntrusiveListNode m_mru_list_node; public: - explicit Node(const Value &value) : value(value) { /* ... */ } + explicit Node(const Value &value) : m_value(value) { /* ... */ } }; private: - using MruList = typename util::IntrusiveListMemberTraits<&Node::mru_list_node>::ListType; + using MruList = typename util::IntrusiveListMemberTraits<&Node::m_mru_list_node>::ListType; private: - MruList mru_list; + MruList m_mru_list; public: - constexpr LruListCache() : mru_list() { /* ... */ } + constexpr LruListCache() : m_mru_list() { /* ... */ } bool FindValueAndUpdateMru(Value *out, const Key &key) { - for (auto it = this->mru_list.begin(); it != this->mru_list.end(); ++it) { - if (it->key == key) { - *out = it->value; + for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) { + if (it->m_key == key) { + *out = it->m_value; - this->mru_list.erase(it); - this->mru_list.push_front(*it); + m_mru_list.erase(it); + m_mru_list.push_front(*it); return true; } @@ -56,33 +56,33 @@ namespace ams::fssystem { } std::unique_ptr PopLruNode() { - AMS_ABORT_UNLESS(!this->mru_list.empty()); - Node *lru = std::addressof(*this->mru_list.rbegin()); - this->mru_list.pop_back(); + AMS_ABORT_UNLESS(!m_mru_list.empty()); + Node *lru = std::addressof(*m_mru_list.rbegin()); + m_mru_list.pop_back(); return std::unique_ptr(lru); } void PushMruNode(std::unique_ptr &&node, const Key &key) { - node->key = key; - this->mru_list.push_front(*node); + node->m_key = key; + m_mru_list.push_front(*node); node.release(); } void DeleteAllNodes() { - while (!this->mru_list.empty()) { - Node *lru = std::addressof(*this->mru_list.rbegin()); - this->mru_list.erase(this->mru_list.iterator_to(*lru)); + while (!m_mru_list.empty()) { + Node *lru = std::addressof(*m_mru_list.rbegin()); + m_mru_list.erase(m_mru_list.iterator_to(*lru)); delete lru; } } size_t GetSize() const { - return this->mru_list.size(); + return m_mru_list.size(); } bool IsEmpty() const { - return this->mru_list.empty(); + return m_mru_list.empty(); } }; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp index 918129e4c..188446052 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp @@ -33,38 +33,38 @@ namespace ams::fssystem { class BufferHolder { NON_COPYABLE(BufferHolder); private: - MemoryResource *allocator; - char *buffer; - size_t buffer_size; + MemoryResource *m_allocator; + char *m_buffer; + size_t m_buffer_size; public: - BufferHolder() : allocator(), buffer(), buffer_size() { /* ... */ } - BufferHolder(MemoryResource *a, size_t sz) : allocator(a), buffer(static_cast(a->Allocate(sz))), buffer_size(sz) { /* ... */ } + BufferHolder() : m_allocator(), m_buffer(), m_buffer_size() { /* ... */ } + BufferHolder(MemoryResource *a, size_t sz) : m_allocator(a), m_buffer(static_cast(a->Allocate(sz))), m_buffer_size(sz) { /* ... */ } ~BufferHolder() { - if (this->buffer != nullptr) { - this->allocator->Deallocate(this->buffer, this->buffer_size); - this->buffer = nullptr; + if (m_buffer != nullptr) { + m_allocator->Deallocate(m_buffer, m_buffer_size); + m_buffer = nullptr; } } - BufferHolder(BufferHolder &&rhs) : allocator(rhs.allocator), buffer(rhs.buffer), buffer_size(rhs.buffer_size) { - rhs.buffer = nullptr; + BufferHolder(BufferHolder &&rhs) : m_allocator(rhs.m_allocator), m_buffer(rhs.m_buffer), m_buffer_size(rhs.m_buffer_size) { + rhs.m_buffer = nullptr; } BufferHolder &operator=(BufferHolder &&rhs) { if (this != std::addressof(rhs)) { - AMS_ASSERT(this->buffer == nullptr); - this->allocator = rhs.allocator; - this->buffer = rhs.buffer; - this->buffer_size = rhs.buffer_size; + AMS_ASSERT(m_buffer == nullptr); + m_allocator = rhs.m_allocator; + m_buffer = rhs.m_buffer; + m_buffer_size = rhs.m_buffer_size; - rhs.buffer = nullptr; + rhs.m_buffer = nullptr; } return *this; } - bool IsValid() const { return this->buffer != nullptr; } - char *Get() const { return this->buffer; } - size_t GetSize() const { return this->buffer_size; } + bool IsValid() const { return m_buffer != nullptr; } + char *Get() const { return m_buffer; } + size_t GetSize() const { return m_buffer_size; } }; template @@ -79,24 +79,24 @@ namespace ams::fssystem { template using IndexedStoragePointer = StoragePointer; private: - std::shared_ptr nca_reader; - std::array storages; + std::shared_ptr m_nca_reader; + std::array m_storages; private: template void SetImpl(IndexedStoragePointer &&ptr) { static_assert(N < sizeof...(Is)); - this->storages[N] = std::move(ptr); + m_storages[N] = std::move(ptr); } public: - DerivedStorageHolderImpl() : Base(), nca_reader(), storages() { /* ... */ } - explicit DerivedStorageHolderImpl(std::shared_ptr nr) : Base(), nca_reader(nr), storages() { /* ... */ } + DerivedStorageHolderImpl() : Base(), m_nca_reader(), m_storages() { /* ... */ } + explicit DerivedStorageHolderImpl(std::shared_ptr nr) : Base(), m_nca_reader(nr), m_storages() { /* ... */ } - #define DEFINE_CONSTRUCTORS(n) \ - template \ - explicit DerivedStorageHolderImpl(AMS_UTIL_VARIADIC_TEMPLATE_ARGUMENTS##n (T, t)) : Base(AMS_UTIL_VARIADIC_TEMPLATE_FORWARDS##n (T, t)), nca_reader(), storages() { /* ... */ } \ - template \ - explicit DerivedStorageHolderImpl(AMS_UTIL_VARIADIC_TEMPLATE_ARGUMENTS##n (T, t), std::shared_ptr nr) : Base(AMS_UTIL_VARIADIC_TEMPLATE_FORWARDS##n (T, t)), nca_reader(nr), storages() { /* ... */ } + #define DEFINE_CONSTRUCTORS(n) \ + template \ + explicit DerivedStorageHolderImpl(AMS_UTIL_VARIADIC_TEMPLATE_ARGUMENTS##n (T, t)) : Base(AMS_UTIL_VARIADIC_TEMPLATE_FORWARDS##n (T, t)), m_nca_reader(), m_storages() { /* ... */ } \ + template \ + explicit DerivedStorageHolderImpl(AMS_UTIL_VARIADIC_TEMPLATE_ARGUMENTS##n (T, t), std::shared_ptr nr) : Base(AMS_UTIL_VARIADIC_TEMPLATE_FORWARDS##n (T, t)), m_nca_reader(nr), m_storages() { /* ... */ } AMS_UTIL_VARIADIC_INVOKE_MACRO(DEFINE_CONSTRUCTORS) @@ -116,17 +116,17 @@ namespace ams::fssystem { private: using BaseHolder = DerivedStorageHolder; private: - BufferHolder buffer; + BufferHolder m_buffer; public: - DerivedStorageHolderWithBuffer() : BaseHolder(), buffer() { /* ... */ } + DerivedStorageHolderWithBuffer() : BaseHolder(), m_buffer() { /* ... */ } template - DerivedStorageHolderWithBuffer(Args &&... args) : BaseHolder(std::forward(args)...), buffer() { /* ... */ } + DerivedStorageHolderWithBuffer(Args &&... args) : BaseHolder(std::forward(args)...), m_buffer() { /* ... */ } using BaseHolder::Set; void Set(BufferHolder &&buf) { - this->buffer = std::move(buf); + m_buffer = std::move(buf); } }; @@ -138,21 +138,21 @@ namespace ams::fssystem { static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize; static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize; private: - IStorage * const base_storage; - u8 iv[IvSize]; - DecryptAesCtrFunction decrypt_function; - s32 key_index; - u8 encrypted_key[KeySize]; + IStorage * const m_base_storage; + u8 m_iv[IvSize]; + DecryptAesCtrFunction m_decrypt_function; + s32 m_key_index; + u8 m_encrypted_key[KeySize]; public: - AesCtrStorageExternal(fs::IStorage *bs, const void *enc_key, size_t enc_key_size, const void *iv, size_t iv_size, DecryptAesCtrFunction df, s32 kidx) : base_storage(bs), decrypt_function(df), key_index(kidx) { + AesCtrStorageExternal(fs::IStorage *bs, const void *enc_key, size_t enc_key_size, const void *iv, size_t iv_size, DecryptAesCtrFunction df, s32 kidx) : m_base_storage(bs), m_decrypt_function(df), m_key_index(kidx) { AMS_ASSERT(bs != nullptr); AMS_ASSERT(enc_key_size == KeySize); AMS_ASSERT(iv != nullptr); AMS_ASSERT(iv_size == IvSize); AMS_UNUSED(iv_size); - std::memcpy(this->iv, iv, IvSize); - std::memcpy(this->encrypted_key, enc_key, enc_key_size); + std::memcpy(m_iv, iv, IvSize); + std::memcpy(m_encrypted_key, enc_key, enc_key_size); } virtual Result Read(s64 offset, void *buffer, size_t size) override { @@ -166,7 +166,7 @@ namespace ams::fssystem { R_UNLESS(util::IsAligned(size, BlockSize), fs::ResultInvalidArgument()); /* Read the data. */ - R_TRY(this->base_storage->Read(offset, buffer, size)); + R_TRY(m_base_storage->Read(offset, buffer, size)); /* Temporarily increase our thread priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); @@ -178,7 +178,7 @@ namespace ams::fssystem { /* Setup the counter. */ u8 ctr[IvSize]; - std::memcpy(ctr, this->iv, IvSize); + std::memcpy(ctr, m_iv, IvSize); AddCounter(ctr, IvSize, offset / BlockSize); /* Setup tracking. */ @@ -191,7 +191,7 @@ namespace ams::fssystem { char *dst = static_cast(buffer) + cur_offset; /* Decrypt into the temporary buffer */ - this->decrypt_function(pooled_buffer.GetBuffer(), cur_size, this->key_index, this->encrypted_key, KeySize, ctr, IvSize, dst, cur_size); + m_decrypt_function(pooled_buffer.GetBuffer(), cur_size, m_key_index, m_encrypted_key, KeySize, ctr, IvSize, dst, cur_size); /* Copy to the destination. */ std::memcpy(dst, pooled_buffer.GetBuffer(), cur_size); @@ -216,12 +216,12 @@ namespace ams::fssystem { R_UNLESS(dst_size == sizeof(fs::QueryRangeInfo), fs::ResultInvalidSize()); /* Operate on our base storage. */ - R_TRY(this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); /* Add in new flags. */ fs::QueryRangeInfo new_info; new_info.Clear(); - new_info.aes_ctr_key_type = static_cast(this->key_index >= 0 ? fs::AesCtrKeyTypeFlag::InternalKeyForHardwareAes : fs::AesCtrKeyTypeFlag::ExternalKeyForHardwareAes); + new_info.aes_ctr_key_type = static_cast(m_key_index >= 0 ? fs::AesCtrKeyTypeFlag::InternalKeyForHardwareAes : fs::AesCtrKeyTypeFlag::ExternalKeyForHardwareAes); /* Merge the new info in. */ reinterpret_cast(dst)->Merge(new_info); @@ -230,14 +230,14 @@ namespace ams::fssystem { default: { /* Operate on our base storage. */ - R_TRY(this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); return ResultSuccess(); } } } virtual Result GetSize(s64 *out) override { - return this->base_storage->GetSize(out); + return m_base_storage->GetSize(out); } virtual Result Flush() override { @@ -260,15 +260,15 @@ namespace ams::fssystem { NON_COPYABLE(SwitchStorage); NON_MOVEABLE(SwitchStorage); private: - std::unique_ptr true_storage; - std::unique_ptr false_storage; - F truth_function; + std::unique_ptr m_true_storage; + std::unique_ptr m_false_storage; + F m_truth_function; private: ALWAYS_INLINE std::unique_ptr &SelectStorage() { - return this->truth_function() ? this->true_storage : this->false_storage; + return m_truth_function() ? m_true_storage : m_false_storage; } public: - SwitchStorage(std::unique_ptr &&t, std::unique_ptr &&f, F func) : true_storage(std::move(t)), false_storage(std::move(f)), truth_function(func) { /* ... */ } + SwitchStorage(std::unique_ptr &&t, std::unique_ptr &&f, F func) : m_true_storage(std::move(t)), m_false_storage(std::move(f)), m_truth_function(func) { /* ... */ } virtual Result Read(s64 offset, void *buffer, size_t size) override { return this->SelectStorage()->Read(offset, buffer, size); @@ -278,8 +278,8 @@ namespace ams::fssystem { switch (op_id) { case fs::OperationId::Invalidate: { - R_TRY(this->true_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); - R_TRY(this->false_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_true_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_false_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); return ResultSuccess(); } case fs::OperationId::QueryRange: @@ -344,15 +344,15 @@ namespace ams::fssystem { /* Validate preconditions. */ AMS_ASSERT(out != nullptr); AMS_ASSERT(0 <= fs_index && fs_index < NcaHeader::FsCountMax); - AMS_ASSERT(this->reader != nullptr); + AMS_ASSERT(m_reader != nullptr); /* Get storage extents. */ - const auto storage_offset = GetFsOffset(*this->reader, fs_index); - const auto storage_size = GetFsEndOffset(*this->reader, fs_index) - storage_offset; + const auto storage_offset = GetFsOffset(*m_reader, fs_index); + const auto storage_size = GetFsEndOffset(*m_reader, fs_index) - storage_offset; R_UNLESS(storage_size > 0, fs::ResultInvalidNcaHeader()); /* Allocate a substorage. */ - *out = AllocateShared>(this->reader->GetBodyStorage(), storage_offset, storage_size, this->reader); + *out = AllocateShared>(m_reader->GetBodyStorage(), storage_offset, storage_size, m_reader); R_UNLESS(*out != nullptr, fs::ResultAllocationFailureInAllocateShared()); return ResultSuccess(); @@ -375,15 +375,15 @@ namespace ams::fssystem { /* Validate preconditions. */ AMS_ASSERT(out != nullptr); AMS_ASSERT(option != nullptr); - AMS_ASSERT(this->reader != nullptr); + AMS_ASSERT(m_reader != nullptr); /* Get and validate fs index. */ const auto fs_index = option->GetFsIndex(); - R_UNLESS(this->reader->HasFsInfo(fs_index), fs::ResultPartitionNotFound()); + R_UNLESS(m_reader->HasFsInfo(fs_index), fs::ResultPartitionNotFound()); /* Initialize a reader for the fs header. */ auto &header_reader = option->GetHeaderReader(); - R_TRY(header_reader.Initialize(*this->reader, fs_index)); + R_TRY(header_reader.Initialize(*m_reader, fs_index)); /* Create the storage. */ std::unique_ptr storage; @@ -404,16 +404,16 @@ namespace ams::fssystem { /* Validate preconditions. */ AMS_ASSERT(out != nullptr); AMS_ASSERT(option != nullptr); - AMS_ASSERT(this->reader != nullptr); + AMS_ASSERT(m_reader != nullptr); /* Get and validate fs index. */ const auto fs_index = option->GetFsIndex(); - R_UNLESS(this->reader->HasFsInfo(fs_index), fs::ResultPartitionNotFound()); + R_UNLESS(m_reader->HasFsInfo(fs_index), fs::ResultPartitionNotFound()); /* Initialize a reader for the fs header. */ auto &header_reader = option->GetHeaderReader(); if (!header_reader.IsInitialized()) { - R_TRY(header_reader.Initialize(*this->reader, fs_index)); + R_TRY(header_reader.Initialize(*m_reader, fs_index)); } /* Create the storage. */ @@ -476,8 +476,8 @@ namespace ams::fssystem { const auto &header_reader = option->GetHeaderReader(); /* Get storage extents. */ - const auto storage_offset = GetFsOffset(*this->reader, fs_index); - const auto storage_size = GetFsEndOffset(*this->reader, fs_index) - storage_offset; + const auto storage_offset = GetFsOffset(*m_reader, fs_index); + const auto storage_size = GetFsEndOffset(*m_reader, fs_index) - storage_offset; R_UNLESS(storage_size > 0, fs::ResultInvalidNcaHeader()); /* Set up the sparse storage if we need to, otherwise use body storage directly. */ @@ -490,7 +490,7 @@ namespace ams::fssystem { R_TRY(header.Verify()); /* Create a new holder for the storages. */ - std::unique_ptr storage = std::make_unique>(this->reader); + std::unique_ptr storage = std::make_unique>(m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* If there are no entries, there's nothing to actually do. */ @@ -498,7 +498,7 @@ namespace ams::fssystem { storage->Initialize(storage_size); } else { /* Prepare to create the decryptable storage. */ - const auto raw_storage = this->reader->GetBodyStorage(); + const auto raw_storage = m_reader->GetBodyStorage(); const auto raw_storage_offset = sparse_info.physical_offset; const auto raw_storage_size = sparse_info.GetPhysicalSize(); @@ -521,7 +521,7 @@ namespace ams::fssystem { R_UNLESS(table_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the table storage. */ - R_TRY(table_storage->Initialize(fs::SubStorage(decryptable_storage.get(), 0, raw_storage_size), this->buffer_manager, SparseTableCacheBlockSize, SparseTableCacheCount)); + R_TRY(table_storage->Initialize(fs::SubStorage(decryptable_storage.get(), 0, raw_storage_size), m_buffer_manager, SparseTableCacheBlockSize, SparseTableCacheCount)); /* Determine storage extents. */ const auto node_offset = sparse_info.bucket.offset; @@ -530,7 +530,7 @@ namespace ams::fssystem { const auto entry_size = SparseStorage::QueryEntryStorageSize(header.entry_count); /* Initialize the storage. */ - R_TRY(storage->Initialize(this->allocator, fs::SubStorage(table_storage.get(), node_offset, node_size), fs::SubStorage(table_storage.get(), entry_offset, entry_size), header.entry_count)); + R_TRY(storage->Initialize(m_allocator, fs::SubStorage(table_storage.get(), node_offset, node_size), fs::SubStorage(table_storage.get(), entry_offset, entry_size), header.entry_count)); /* Set the data/decryptable storage. */ storage->SetDataStorage(raw_storage, raw_storage_offset, node_offset); @@ -545,11 +545,11 @@ namespace ams::fssystem { } else { /* Validate that we're within range. */ s64 body_storage_size; - R_TRY(this->reader->GetBodyStorage()->GetSize(std::addressof(body_storage_size))); + R_TRY(m_reader->GetBodyStorage()->GetSize(std::addressof(body_storage_size))); R_UNLESS(storage_offset + storage_size <= body_storage_size, fs::ResultNcaBaseStorageOutOfRangeB()); /* Set the out storage. */ - out->SetStorage(this->reader->GetBodyStorage(), storage_offset, storage_size); + out->SetStorage(m_reader->GetBodyStorage(), storage_offset, storage_size); } /* Set the crypto variables. */ @@ -604,13 +604,13 @@ namespace ams::fssystem { R_UNLESS(raw_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Make the aes xts storage. */ - const auto *key1 = this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts1); - const auto *key2 = this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts2); + const auto *key1 = m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts1); + const auto *key2 = m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts2); std::unique_ptr xts_storage = std::make_unique(raw_storage.get(), key1, key2, AesXtsStorage::KeySize, iv, AesXtsStorage::IvSize, NcaHeader::XtsBlockSize); R_UNLESS(xts_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Make the out storage. */ - std::unique_ptr storage = std::make_unique, 2>>(xts_storage.get(), this->reader); + std::unique_ptr storage = std::make_unique, 2>>(xts_storage.get(), m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Set the substorages. */ @@ -634,22 +634,22 @@ namespace ams::fssystem { std::unique_ptr raw_storage = base_storage->MakeStorage(); /* Create the decrypt storage. */ - const bool has_external_key = reader->HasExternalDecryptionKey(); + const bool has_external_key = m_reader->HasExternalDecryptionKey(); std::unique_ptr decrypt_storage; if (has_external_key) { - decrypt_storage = std::make_unique(raw_storage.get(), this->reader->GetExternalDecryptionKey(), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, this->reader->GetExternalDecryptAesCtrFunctionForExternalKey(), -1); + decrypt_storage = std::make_unique(raw_storage.get(), m_reader->GetExternalDecryptionKey(), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, m_reader->GetExternalDecryptAesCtrFunctionForExternalKey(), -1); R_UNLESS(decrypt_storage != nullptr, fs::ResultAllocationFailureInNew()); } else { /* Check if we have a hardware key. */ - const bool has_hardware_key = this->reader->HasInternalDecryptionKeyForAesHardwareSpeedEmulation(); + const bool has_hardware_key = m_reader->HasInternalDecryptionKeyForAesHardwareSpeedEmulation(); /* Create the software decryption storage. */ - std::unique_ptr aes_ctr_sw_storage = std::make_unique(raw_storage.get(), this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorage::KeySize, iv, AesCtrStorage::IvSize); + std::unique_ptr aes_ctr_sw_storage = std::make_unique(raw_storage.get(), m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorage::KeySize, iv, AesCtrStorage::IvSize); R_UNLESS(aes_ctr_sw_storage != nullptr, fs::ResultAllocationFailureInNew()); /* If we have a hardware key and should use it, make the hardware decryption storage. */ - if (has_hardware_key && !this->reader->IsSoftwareAesPrioritized()) { - std::unique_ptr aes_ctr_hw_storage = std::make_unique(raw_storage.get(), this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, this->reader->GetExternalDecryptAesCtrFunction(), GetKeyTypeValue(this->reader->GetKeyIndex(), this->reader->GetKeyGeneration())); + if (has_hardware_key && !m_reader->IsSoftwareAesPrioritized()) { + std::unique_ptr aes_ctr_hw_storage = std::make_unique(raw_storage.get(), m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, m_reader->GetExternalDecryptAesCtrFunction(), GetKeyTypeValue(m_reader->GetKeyIndex(), m_reader->GetKeyGeneration())); R_UNLESS(aes_ctr_hw_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Create the selection storage. */ @@ -662,7 +662,7 @@ namespace ams::fssystem { } /* Create the storage holder. */ - std::unique_ptr storage = std::make_unique, 2>>(decrypt_storage.get(), this->reader); + std::unique_ptr storage = std::make_unique, 2>>(decrypt_storage.get(), m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Set the storage holder's storages. */ @@ -716,7 +716,7 @@ namespace ams::fssystem { R_UNLESS(buffered_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the buffered storage. */ - R_TRY(buffered_storage->Initialize(fs::SubStorage(table_storage.get(), 0, table_size), this->buffer_manager, AesCtrExTableCacheBlockSize, AesCtrExTableCacheCount)); + R_TRY(buffered_storage->Initialize(fs::SubStorage(table_storage.get(), 0, table_size), m_buffer_manager, AesCtrExTableCacheBlockSize, AesCtrExTableCacheCount)); /* Create an aligned storage for the buffered storage. */ using AlignedStorage = AlignmentMatchingStorage; @@ -742,18 +742,18 @@ namespace ams::fssystem { /* Create the aes ctr ex storage. */ std::unique_ptr aes_ctr_ex_storage; - const bool has_external_key = this->reader->HasExternalDecryptionKey(); + const bool has_external_key = m_reader->HasExternalDecryptionKey(); if (has_external_key) { /* Create the decryptor. */ std::unique_ptr decryptor; - R_TRY(AesCtrCounterExtendedStorage::CreateExternalDecryptor(std::addressof(decryptor), this->reader->GetExternalDecryptAesCtrFunctionForExternalKey(), -1)); + R_TRY(AesCtrCounterExtendedStorage::CreateExternalDecryptor(std::addressof(decryptor), m_reader->GetExternalDecryptAesCtrFunctionForExternalKey(), -1)); /* Create the aes ctr ex storage. */ std::unique_ptr impl_storage = std::make_unique(); R_UNLESS(impl_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the aes ctr ex storage. */ - R_TRY(impl_storage->Initialize(this->allocator, this->reader->GetExternalDecryptionKey(), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(decryptor))); + R_TRY(impl_storage->Initialize(m_allocator, m_reader->GetExternalDecryptionKey(), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(decryptor))); /* Set the option's aes ctr ex storage. */ option->SetAesCtrExStorageRaw(impl_storage.get()); @@ -761,7 +761,7 @@ namespace ams::fssystem { aes_ctr_ex_storage = std::move(impl_storage); } else { /* Check if we have a hardware key. */ - const bool has_hardware_key = this->reader->HasInternalDecryptionKeyForAesHardwareSpeedEmulation(); + const bool has_hardware_key = m_reader->HasInternalDecryptionKeyForAesHardwareSpeedEmulation(); /* Create the software decryptor. */ std::unique_ptr sw_decryptor; @@ -772,23 +772,23 @@ namespace ams::fssystem { R_UNLESS(sw_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the software storage. */ - R_TRY(sw_storage->Initialize(this->allocator, this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(sw_decryptor))); + R_TRY(sw_storage->Initialize(m_allocator, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(sw_decryptor))); /* Set the option's aes ctr ex storage. */ option->SetAesCtrExStorageRaw(sw_storage.get()); /* If we have a hardware key and should use it, make the hardware decryption storage. */ - if (has_hardware_key && !this->reader->IsSoftwareAesPrioritized()) { + if (has_hardware_key && !m_reader->IsSoftwareAesPrioritized()) { /* Create the hardware decryptor. */ std::unique_ptr hw_decryptor; - R_TRY(AesCtrCounterExtendedStorage::CreateExternalDecryptor(std::addressof(hw_decryptor), this->reader->GetExternalDecryptAesCtrFunction(), GetKeyTypeValue(this->reader->GetKeyIndex(), this->reader->GetKeyGeneration()))); + R_TRY(AesCtrCounterExtendedStorage::CreateExternalDecryptor(std::addressof(hw_decryptor), m_reader->GetExternalDecryptAesCtrFunction(), GetKeyTypeValue(m_reader->GetKeyIndex(), m_reader->GetKeyGeneration()))); /* Create the hardware storage. */ std::unique_ptr hw_storage = std::make_unique(); R_UNLESS(hw_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the hardware storage. */ - R_TRY(hw_storage->Initialize(this->allocator, this->reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(hw_decryptor))); + R_TRY(hw_storage->Initialize(m_allocator, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorage::KeySize, secure_value, base_storage_offset, data_storage, node_storage, entry_storage, entry_count, std::move(hw_decryptor))); /* Create the selection storage. */ std::unique_ptr switch_storage = std::make_unique>(std::move(hw_storage), std::move(sw_storage), IsUsingHardwareAesCtrForSpeedEmulation); @@ -803,7 +803,7 @@ namespace ams::fssystem { } /* Create the storage holder. */ - std::unique_ptr storage = std::make_unique>(aes_ctr_ex_storage.get(), this->reader); + std::unique_ptr storage = std::make_unique>(aes_ctr_ex_storage.get(), m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Set the aes ctr ex storages in the option. */ @@ -848,11 +848,11 @@ namespace ams::fssystem { { const s32 fs_index = header_reader.GetFsIndex(); - if (this->original_reader != nullptr && this->original_reader->HasFsInfo(fs_index)) { + if (m_original_reader != nullptr && m_original_reader->HasFsInfo(fs_index)) { NcaFsHeaderReader original_header_reader; - R_TRY(original_header_reader.Initialize(*this->original_reader, fs_index)); + R_TRY(original_header_reader.Initialize(*m_original_reader, fs_index)); - NcaFileSystemDriver original_driver(this->original_reader, this->allocator, this->buffer_manager); + NcaFileSystemDriver original_driver(m_original_reader, m_allocator, m_buffer_manager); StorageOption original_option(std::addressof(original_header_reader), fs_index); BaseStorage original_base_storage; @@ -877,21 +877,21 @@ namespace ams::fssystem { R_UNLESS(indirect_table_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the indirect table storage. */ - R_TRY(indirect_table_storage->Initialize(fs::SubStorage(base_storage.get(), indirect_data_size, node_size + entry_size), this->buffer_manager, IndirectTableCacheBlockSize, IndirectTableCacheCount)); + R_TRY(indirect_table_storage->Initialize(fs::SubStorage(base_storage.get(), indirect_data_size, node_size + entry_size), m_buffer_manager, IndirectTableCacheBlockSize, IndirectTableCacheCount)); /* Create the indirect data storage. */ std::unique_ptr indirect_data_storage = std::make_unique(); R_UNLESS(indirect_data_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the indirect data storage. */ - R_TRY(indirect_data_storage->Initialize(fs::SubStorage(base_storage.get(), 0, indirect_data_size), this->buffer_manager, IndirectDataCacheBlockSize, IndirectDataCacheCount)); + R_TRY(indirect_data_storage->Initialize(fs::SubStorage(base_storage.get(), 0, indirect_data_size), m_buffer_manager, IndirectDataCacheBlockSize, IndirectDataCacheCount)); /* Create the storage holder. */ - std::unique_ptr storage = std::make_unique>(this->reader); + std::unique_ptr storage = std::make_unique>(m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the storage holder. */ - R_TRY(storage->Initialize(this->allocator, fs::SubStorage(indirect_table_storage.get(), 0, node_size), fs::SubStorage(indirect_table_storage.get(), node_size, entry_size), header.entry_count)); + R_TRY(storage->Initialize(m_allocator, fs::SubStorage(indirect_table_storage.get(), 0, node_size), fs::SubStorage(indirect_table_storage.get(), node_size, entry_size), header.entry_count)); /* Set the storage holder's storages. */ storage->SetStorage(0, original_storage.get(), 0, original_data_size); @@ -955,7 +955,7 @@ namespace ams::fssystem { const auto total_buffer_size = hash_buffer_size + cache_buffer_size; /* Make a buffer holder. */ - BufferHolder buffer_holder(this->allocator, total_buffer_size); + BufferHolder buffer_holder(m_allocator, total_buffer_size); R_UNLESS(buffer_holder.IsValid(), fs::ResultAllocationFailureInNcaFileSystemDriverI()); /* Make the data storage. */ @@ -983,7 +983,7 @@ namespace ams::fssystem { R_UNLESS(cache_storage != nullptr, fs::ResultAllocationFailureInNew()); /* Make the storage holder. */ - std::unique_ptr storage = std::make_unique(cache_storage.get(), hash_data.hash_block_size, this->reader); + std::unique_ptr storage = std::make_unique(cache_storage.get(), hash_data.hash_block_size, m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Set the storage holder's data. */ @@ -1026,11 +1026,11 @@ namespace ams::fssystem { storage_info.SetDataStorage(fs::SubStorage(base_storage.get(), layer_info.offset, layer_info.size)); /* Make the storage holder. */ - std::unique_ptr storage = std::make_unique(this->reader); + std::unique_ptr storage = std::make_unique(m_reader); R_UNLESS(storage != nullptr, fs::ResultAllocationFailureInNew()); /* Initialize the integrity storage. */ - R_TRY(storage->Initialize(level_hash_info, hash_data.master_hash, storage_info, this->buffer_manager)); + R_TRY(storage->Initialize(level_hash_info, hash_data.master_hash, storage_info, m_buffer_manager)); /* Set the storage holder's data. */ storage->Set(std::move(base_storage)); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp b/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp index ff011fbc2..ea1aab1d0 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_nca_reader.cpp @@ -35,10 +35,10 @@ namespace ams::fssystem { } - NcaReader::NcaReader() : shared_base_storage(), header_storage(), body_storage(), decrypt_aes_ctr(), decrypt_aes_ctr_external(), is_software_aes_prioritized(false), header_encryption_type(NcaHeader::EncryptionType::Auto) { - std::memset(std::addressof(this->header), 0, sizeof(this->header)); - std::memset(std::addressof(this->decryption_keys), 0, sizeof(this->decryption_keys)); - std::memset(std::addressof(this->external_decryption_key), 0, sizeof(this->external_decryption_key)); + NcaReader::NcaReader() : m_shared_base_storage(), m_header_storage(), m_body_storage(), m_decrypt_aes_ctr(), m_decrypt_aes_ctr_external(), m_is_software_aes_prioritized(false), m_header_encryption_type(NcaHeader::EncryptionType::Auto) { + std::memset(std::addressof(m_header), 0, sizeof(m_header)); + std::memset(std::addressof(m_decryption_keys), 0, sizeof(m_decryption_keys)); + std::memset(std::addressof(m_external_decryption_key), 0, sizeof(m_external_decryption_key)); } NcaReader::~NcaReader() { @@ -46,14 +46,14 @@ namespace ams::fssystem { } Result NcaReader::Initialize(std::shared_ptr base_storage, const NcaCryptoConfiguration &crypto_cfg) { - this->shared_base_storage = base_storage; - return this->Initialize(this->shared_base_storage.get(), crypto_cfg); + m_shared_base_storage = base_storage; + return this->Initialize(m_shared_base_storage.get(), crypto_cfg); } Result NcaReader::Initialize(fs::IStorage *base_storage, const NcaCryptoConfiguration &crypto_cfg) { /* Validate preconditions. */ AMS_ASSERT(base_storage != nullptr); - AMS_ASSERT(this->body_storage == nullptr); + AMS_ASSERT(m_body_storage == nullptr); R_UNLESS(crypto_cfg.generate_key != nullptr, fs::ResultInvalidArgument()); /* Generate keys for header. */ @@ -68,16 +68,16 @@ namespace ams::fssystem { R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationFailureInNcaReaderA()); /* Read the header. */ - R_TRY(work_header_storage->Read(0, std::addressof(this->header), sizeof(this->header))); + R_TRY(work_header_storage->Read(0, std::addressof(m_header), sizeof(m_header))); /* Validate the magic. */ - if (Result magic_result = CheckNcaMagic(this->header.magic); R_FAILED(magic_result)) { + if (Result magic_result = CheckNcaMagic(m_header.magic); R_FAILED(magic_result)) { /* If we're not allowed to use plaintext headers, stop here. */ R_UNLESS(crypto_cfg.is_plaintext_header_available, magic_result); /* Try to use a plaintext header. */ - R_TRY(base_storage->Read(0, std::addressof(this->header), sizeof(this->header))); - R_UNLESS(R_SUCCEEDED(CheckNcaMagic(this->header.magic)), magic_result); + R_TRY(base_storage->Read(0, std::addressof(m_header), sizeof(m_header))); + R_UNLESS(R_SUCCEEDED(CheckNcaMagic(m_header.magic)), magic_result); /* Configure to use the plaintext header. */ s64 base_storage_size; @@ -85,103 +85,103 @@ namespace ams::fssystem { work_header_storage.reset(new fs::SubStorage(base_storage, 0, base_storage_size)); R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationFailureInNcaReaderA()); - this->header_encryption_type = NcaHeader::EncryptionType::None; + m_header_encryption_type = NcaHeader::EncryptionType::None; } /* Validate the fixed key signature. */ - R_UNLESS(this->header.header1_signature_key_generation <= NcaCryptoConfiguration::Header1SignatureKeyGenerationMax, fs::ResultInvalidNcaHeader1SignatureKeyGeneration()); - const u8 *header_1_sign_key_modulus = crypto_cfg.header_1_sign_key_moduli[this->header.header1_signature_key_generation]; + R_UNLESS(m_header.header1_signature_key_generation <= NcaCryptoConfiguration::Header1SignatureKeyGenerationMax, fs::ResultInvalidNcaHeader1SignatureKeyGeneration()); + const u8 *header_1_sign_key_modulus = crypto_cfg.header_1_sign_key_moduli[m_header.header1_signature_key_generation]; AMS_ABORT_UNLESS(header_1_sign_key_modulus != nullptr); { - const u8 *sig = this->header.header_sign_1; + const u8 *sig = m_header.header_sign_1; const size_t sig_size = NcaHeader::HeaderSignSize; const u8 *mod = header_1_sign_key_modulus; const size_t mod_size = NcaCryptoConfiguration::Rsa2048KeyModulusSize; const u8 *exp = crypto_cfg.header_1_sign_key_public_exponent; const size_t exp_size = NcaCryptoConfiguration::Rsa2048KeyPublicExponentSize; - const u8 *msg = static_cast(static_cast(std::addressof(this->header.magic))); + const u8 *msg = static_cast(static_cast(std::addressof(m_header.magic))); const size_t msg_size = NcaHeader::Size - NcaHeader::HeaderSignSize * NcaHeader::HeaderSignCount; const bool is_signature_valid = crypto::VerifyRsa2048PssSha256(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); R_UNLESS(is_signature_valid, fs::ResultNcaHeaderSignature1VerificationFailed()); } /* Validate the sdk version. */ - R_UNLESS(this->header.sdk_addon_version >= SdkAddonVersionMin, fs::ResultUnsupportedSdkVersion()); + R_UNLESS(m_header.sdk_addon_version >= SdkAddonVersionMin, fs::ResultUnsupportedSdkVersion()); /* Validate the key index. */ - R_UNLESS(this->header.key_index < NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, fs::ResultInvalidNcaKeyIndex()); + R_UNLESS(m_header.key_index < NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, fs::ResultInvalidNcaKeyIndex()); /* Check if we have a rights id. */ constexpr const u8 ZeroRightsId[NcaHeader::RightsIdSize] = {}; - if (crypto::IsSameBytes(ZeroRightsId, this->header.rights_id, NcaHeader::RightsIdSize)) { + if (crypto::IsSameBytes(ZeroRightsId, m_header.rights_id, NcaHeader::RightsIdSize)) { /* If we do, then we don't have an external key, so we need to generate decryption keys. */ - crypto_cfg.generate_key(this->decryption_keys[NcaHeader::DecryptionKey_AesCtr], crypto::AesDecryptor128::KeySize, this->header.encrypted_key_area + NcaHeader::DecryptionKey_AesCtr * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize, GetKeyTypeValue(this->header.key_index, this->header.GetProperKeyGeneration()), crypto_cfg); + crypto_cfg.generate_key(m_decryption_keys[NcaHeader::DecryptionKey_AesCtr], crypto::AesDecryptor128::KeySize, m_header.encrypted_key_area + NcaHeader::DecryptionKey_AesCtr * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize, GetKeyTypeValue(m_header.key_index, m_header.GetProperKeyGeneration()), crypto_cfg); /* Copy the hardware speed emulation key. */ - std::memcpy(this->decryption_keys[NcaHeader::DecryptionKey_AesCtrHw], this->header.encrypted_key_area + NcaHeader::DecryptionKey_AesCtrHw * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize); + std::memcpy(m_decryption_keys[NcaHeader::DecryptionKey_AesCtrHw], m_header.encrypted_key_area + NcaHeader::DecryptionKey_AesCtrHw * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize); } /* Clear the external decryption key. */ - std::memset(this->external_decryption_key, 0, sizeof(this->external_decryption_key)); + std::memset(m_external_decryption_key, 0, sizeof(m_external_decryption_key)); /* Set our decryptor functions. */ - this->decrypt_aes_ctr = crypto_cfg.decrypt_aes_ctr; - this->decrypt_aes_ctr_external = crypto_cfg.decrypt_aes_ctr_external; + m_decrypt_aes_ctr = crypto_cfg.decrypt_aes_ctr; + m_decrypt_aes_ctr_external = crypto_cfg.decrypt_aes_ctr_external; /* Set our storages. */ - this->header_storage = std::move(work_header_storage); - this->body_storage = base_storage; + m_header_storage = std::move(work_header_storage); + m_body_storage = base_storage; return ResultSuccess(); } fs::IStorage *NcaReader::GetBodyStorage() { - return this->body_storage; + return m_body_storage; } u32 NcaReader::GetMagic() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.magic; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.magic; } NcaHeader::DistributionType NcaReader::GetDistributionType() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.distribution_type; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.distribution_type; } NcaHeader::ContentType NcaReader::GetContentType() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.content_type; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.content_type; } u8 NcaReader::GetKeyGeneration() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.GetProperKeyGeneration(); + AMS_ASSERT(m_body_storage != nullptr); + return m_header.GetProperKeyGeneration(); } u8 NcaReader::GetKeyIndex() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.key_index; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.key_index; } u64 NcaReader::GetContentSize() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.content_size; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.content_size; } u64 NcaReader::GetProgramId() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.program_id; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.program_id; } u32 NcaReader::GetContentIndex() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.content_index; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.content_index; } u32 NcaReader::GetSdkAddonVersion() const { - AMS_ASSERT(this->body_storage != nullptr); - return this->header.sdk_addon_version; + AMS_ASSERT(m_body_storage != nullptr); + return m_header.sdk_addon_version; } void NcaReader::GetRightsId(u8 *dst, size_t dst_size) const { @@ -189,16 +189,16 @@ namespace ams::fssystem { AMS_ASSERT(dst_size >= NcaHeader::RightsIdSize); AMS_UNUSED(dst_size); - std::memcpy(dst, this->header.rights_id, NcaHeader::RightsIdSize); + std::memcpy(dst, m_header.rights_id, NcaHeader::RightsIdSize); } bool NcaReader::HasFsInfo(s32 index) const { AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); - return this->header.fs_info[index].start_sector != 0 || this->header.fs_info[index].end_sector != 0; + return m_header.fs_info[index].start_sector != 0 || m_header.fs_info[index].end_sector != 0; } s32 NcaReader::GetFsCount() const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); for (s32 i = 0; i < NcaHeader::FsCountMax; i++) { if (!this->HasFsInfo(i)) { return i; @@ -208,62 +208,62 @@ namespace ams::fssystem { } const Hash &NcaReader::GetFsHeaderHash(s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); - return this->header.fs_header_hash[index]; + return m_header.fs_header_hash[index]; } void NcaReader::GetFsHeaderHash(Hash *dst, s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); AMS_ASSERT(dst != nullptr); - std::memcpy(dst, std::addressof(this->header.fs_header_hash[index]), sizeof(*dst)); + std::memcpy(dst, std::addressof(m_header.fs_header_hash[index]), sizeof(*dst)); } void NcaReader::GetFsInfo(NcaHeader::FsInfo *dst, s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); AMS_ASSERT(dst != nullptr); - std::memcpy(dst, std::addressof(this->header.fs_info[index]), sizeof(*dst)); + std::memcpy(dst, std::addressof(m_header.fs_info[index]), sizeof(*dst)); } u64 NcaReader::GetFsOffset(s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); - return NcaHeader::SectorToByte(this->header.fs_info[index].start_sector); + return NcaHeader::SectorToByte(m_header.fs_info[index].start_sector); } u64 NcaReader::GetFsEndOffset(s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); - return NcaHeader::SectorToByte(this->header.fs_info[index].end_sector); + return NcaHeader::SectorToByte(m_header.fs_info[index].end_sector); } u64 NcaReader::GetFsSize(s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); - return NcaHeader::SectorToByte(this->header.fs_info[index].end_sector - this->header.fs_info[index].start_sector); + return NcaHeader::SectorToByte(m_header.fs_info[index].end_sector - m_header.fs_info[index].start_sector); } void NcaReader::GetEncryptedKey(void *dst, size_t size) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(dst != nullptr); AMS_ASSERT(size >= NcaHeader::EncryptedKeyAreaSize); AMS_UNUSED(size); - std::memcpy(dst, this->header.encrypted_key_area, NcaHeader::EncryptedKeyAreaSize); + std::memcpy(dst, m_header.encrypted_key_area, NcaHeader::EncryptedKeyAreaSize); } const void *NcaReader::GetDecryptionKey(s32 index) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(0 <= index && index < NcaHeader::DecryptionKey_Count); - return this->decryption_keys[index]; + return m_decryption_keys[index]; } bool NcaReader::HasValidInternalKey() const { constexpr const u8 ZeroKey[crypto::AesDecryptor128::KeySize] = {}; for (s32 i = 0; i < NcaHeader::DecryptionKey_Count; i++) { - if (!crypto::IsSameBytes(ZeroKey, this->header.encrypted_key_area + i * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize)) { + if (!crypto::IsSameBytes(ZeroKey, m_header.encrypted_key_area + i * crypto::AesDecryptor128::KeySize, crypto::AesDecryptor128::KeySize)) { return true; } } @@ -276,11 +276,11 @@ namespace ams::fssystem { } bool NcaReader::IsSoftwareAesPrioritized() const { - return this->is_software_aes_prioritized; + return m_is_software_aes_prioritized; } void NcaReader::PrioritizeSoftwareAes() { - this->is_software_aes_prioritized = true; + m_is_software_aes_prioritized = true; } bool NcaReader::HasExternalDecryptionKey() const { @@ -289,38 +289,38 @@ namespace ams::fssystem { } const void *NcaReader::GetExternalDecryptionKey() const { - return this->external_decryption_key; + return m_external_decryption_key; } void NcaReader::SetExternalDecryptionKey(const void *src, size_t size) { AMS_ASSERT(src != nullptr); - AMS_ASSERT(size == sizeof(this->external_decryption_key)); + AMS_ASSERT(size == sizeof(m_external_decryption_key)); AMS_UNUSED(size); - std::memcpy(this->external_decryption_key, src, sizeof(this->external_decryption_key)); + std::memcpy(m_external_decryption_key, src, sizeof(m_external_decryption_key)); } void NcaReader::GetRawData(void *dst, size_t dst_size) const { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); AMS_ASSERT(dst != nullptr); AMS_ASSERT(dst_size >= sizeof(NcaHeader)); AMS_UNUSED(dst_size); - std::memcpy(dst, std::addressof(this->header), sizeof(NcaHeader)); + std::memcpy(dst, std::addressof(m_header), sizeof(NcaHeader)); } DecryptAesCtrFunction NcaReader::GetExternalDecryptAesCtrFunction() const { - AMS_ASSERT(this->decrypt_aes_ctr != nullptr); - return this->decrypt_aes_ctr; + AMS_ASSERT(m_decrypt_aes_ctr != nullptr); + return m_decrypt_aes_ctr; } DecryptAesCtrFunction NcaReader::GetExternalDecryptAesCtrFunctionForExternalKey() const { - AMS_ASSERT(this->decrypt_aes_ctr_external != nullptr); - return this->decrypt_aes_ctr_external; + AMS_ASSERT(m_decrypt_aes_ctr_external != nullptr); + return m_decrypt_aes_ctr_external; } NcaHeader::EncryptionType NcaReader::GetEncryptionType() const { - return this->header_encryption_type; + return m_header_encryption_type; } Result NcaReader::ReadHeader(NcaFsHeader *dst, s32 index) const { @@ -328,18 +328,18 @@ namespace ams::fssystem { AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); const s64 offset = sizeof(NcaHeader) + sizeof(NcaFsHeader) * index; - return this->header_storage->Read(offset, dst, sizeof(NcaFsHeader)); + return m_header_storage->Read(offset, dst, sizeof(NcaFsHeader)); } Result NcaReader::VerifyHeaderSign2(const void *mod, size_t mod_size) { - AMS_ASSERT(this->body_storage != nullptr); + AMS_ASSERT(m_body_storage != nullptr); constexpr const u8 HeaderSign2KeyPublicExponent[] = { 0x01, 0x00, 0x01 }; - const u8 *sig = this->header.header_sign_2; + const u8 *sig = m_header.header_sign_2; const size_t sig_size = NcaHeader::HeaderSignSize; const u8 *exp = HeaderSign2KeyPublicExponent; const size_t exp_size = sizeof(HeaderSign2KeyPublicExponent); - const u8 *msg = static_cast(static_cast(std::addressof(this->header.magic))); + const u8 *msg = static_cast(static_cast(std::addressof(m_header.magic))); const size_t msg_size = NcaHeader::Size - NcaHeader::HeaderSignSize * NcaHeader::HeaderSignCount; const bool is_signature_valid = crypto::VerifyRsa2048PssSha256(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size); R_UNLESS(is_signature_valid, fs::ResultNcaHeaderSignature2VerificationFailed()); @@ -349,20 +349,20 @@ namespace ams::fssystem { Result NcaFsHeaderReader::Initialize(const NcaReader &reader, s32 index) { /* Reset ourselves to uninitialized. */ - this->fs_index = -1; + m_fs_index = -1; /* Read the header. */ - R_TRY(reader.ReadHeader(std::addressof(this->data), index)); + R_TRY(reader.ReadHeader(std::addressof(m_data), index)); /* Generate the hash. */ Hash hash; - crypto::GenerateSha256Hash(std::addressof(hash), sizeof(hash), std::addressof(this->data), sizeof(NcaFsHeader)); + crypto::GenerateSha256Hash(std::addressof(hash), sizeof(hash), std::addressof(m_data), sizeof(NcaFsHeader)); /* Validate the hash. */ R_UNLESS(crypto::IsSameBytes(std::addressof(reader.GetFsHeaderHash(index)), std::addressof(hash), sizeof(Hash)), fs::ResultNcaFsHeaderHashVerificationFailed()); /* Set our index. */ - this->fs_index = index; + m_fs_index = index; return ResultSuccess(); } @@ -372,72 +372,72 @@ namespace ams::fssystem { AMS_ASSERT(dst_size >= sizeof(NcaFsHeader)); AMS_UNUSED(dst_size); - std::memcpy(dst, std::addressof(this->data), sizeof(NcaFsHeader)); + std::memcpy(dst, std::addressof(m_data), sizeof(NcaFsHeader)); } NcaFsHeader::HashData &NcaFsHeaderReader::GetHashData() { AMS_ASSERT(this->IsInitialized()); - return this->data.hash_data; + return m_data.hash_data; } const NcaFsHeader::HashData &NcaFsHeaderReader::GetHashData() const { AMS_ASSERT(this->IsInitialized()); - return this->data.hash_data; + return m_data.hash_data; } u16 NcaFsHeaderReader::GetVersion() const { AMS_ASSERT(this->IsInitialized()); - return this->data.version; + return m_data.version; } s32 NcaFsHeaderReader::GetFsIndex() const { AMS_ASSERT(this->IsInitialized()); - return this->fs_index; + return m_fs_index; } NcaFsHeader::FsType NcaFsHeaderReader::GetFsType() const { AMS_ASSERT(this->IsInitialized()); - return this->data.fs_type; + return m_data.fs_type; } NcaFsHeader::HashType NcaFsHeaderReader::GetHashType() const { AMS_ASSERT(this->IsInitialized()); - return this->data.hash_type; + return m_data.hash_type; } NcaFsHeader::EncryptionType NcaFsHeaderReader::GetEncryptionType() const { AMS_ASSERT(this->IsInitialized()); - return this->data.encryption_type; + return m_data.encryption_type; } NcaPatchInfo &NcaFsHeaderReader::GetPatchInfo() { AMS_ASSERT(this->IsInitialized()); - return this->data.patch_info; + return m_data.patch_info; } const NcaPatchInfo &NcaFsHeaderReader::GetPatchInfo() const { AMS_ASSERT(this->IsInitialized()); - return this->data.patch_info; + return m_data.patch_info; } const NcaAesCtrUpperIv NcaFsHeaderReader::GetAesCtrUpperIv() const { AMS_ASSERT(this->IsInitialized()); - return this->data.aes_ctr_upper_iv; + return m_data.aes_ctr_upper_iv; } bool NcaFsHeaderReader::ExistsSparseLayer() const { AMS_ASSERT(this->IsInitialized()); - return this->data.sparse_info.generation != 0; + return m_data.sparse_info.generation != 0; } NcaSparseInfo &NcaFsHeaderReader::GetSparseInfo() { AMS_ASSERT(this->IsInitialized()); - return this->data.sparse_info; + return m_data.sparse_info; } const NcaSparseInfo &NcaFsHeaderReader::GetSparseInfo() const { AMS_ASSERT(this->IsInitialized()); - return this->data.sparse_info; + return m_data.sparse_info; } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp index 764a69fb5..1e323dcda 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp @@ -43,46 +43,46 @@ namespace ams::fssystem { template class PartitionFileSystemCore::PartitionFile : public fs::fsa::IFile, public fs::impl::Newable { private: - const typename MetaType::PartitionEntry *partition_entry; - const PartitionFileSystemCore *parent; - const fs::OpenMode mode; + const typename MetaType::PartitionEntry *m_partition_entry; + const PartitionFileSystemCore *m_parent; + const fs::OpenMode m_mode; public: - PartitionFile(PartitionFileSystemCore *parent, const typename MetaType::PartitionEntry *partition_entry, fs::OpenMode mode) : partition_entry(partition_entry), parent(parent), mode(mode) { /* ... */ } + PartitionFile(PartitionFileSystemCore *parent, const typename MetaType::PartitionEntry *partition_entry, fs::OpenMode mode) : m_partition_entry(partition_entry), m_parent(parent), m_mode(mode) { /* ... */ } private: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final; virtual Result DoGetSize(s64 *out) override final { - *out = this->partition_entry->size; + *out = m_partition_entry->size; return ResultSuccess(); } virtual Result DoFlush() override final { /* Nothing to do if writing disallowed. */ - R_SUCCEED_IF((this->mode & fs::OpenMode_Write) == 0); + R_SUCCEED_IF((m_mode & fs::OpenMode_Write) == 0); /* Flush base storage. */ - return this->parent->base_storage->Flush(); + return m_parent->m_base_storage->Flush(); } virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final { /* Ensure appending is not required. */ bool needs_append; - R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, this->mode)); + R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, m_mode)); R_UNLESS(!needs_append, fs::ResultUnsupportedOperationInPartitionFileA()); /* Appending is prohibited. */ - AMS_ASSERT((this->mode & fs::OpenMode_AllowAppend) == 0); + AMS_ASSERT((m_mode & fs::OpenMode_AllowAppend) == 0); /* Validate offset and size. */ - R_UNLESS(offset <= static_cast(this->partition_entry->size), fs::ResultOutOfRange()); - R_UNLESS(static_cast(offset + size) <= static_cast(this->partition_entry->size), fs::ResultInvalidSize()); + R_UNLESS(offset <= static_cast(m_partition_entry->size), fs::ResultOutOfRange()); + R_UNLESS(static_cast(offset + size) <= static_cast(m_partition_entry->size), fs::ResultInvalidSize()); /* Write to the base storage. */ - return this->parent->base_storage->Write(this->parent->meta_data_size + this->partition_entry->offset + offset, buffer, size); + return m_parent->m_base_storage->Write(m_parent->m_meta_data_size + m_partition_entry->offset + offset, buffer, size); } virtual Result DoSetSize(s64 size) override final { - R_TRY(this->DrySetSize(size, this->mode)); + R_TRY(this->DrySetSize(size, m_mode)); return fs::ResultUnsupportedOperationInPartitionFileA(); } @@ -90,8 +90,8 @@ namespace ams::fssystem { /* Validate preconditions for operation. */ switch (op_id) { case fs::OperationId::Invalidate: - R_UNLESS((this->mode & fs::OpenMode_Read) != 0, fs::ResultReadNotPermitted()); - R_UNLESS((this->mode & fs::OpenMode_Write) == 0, fs::ResultUnsupportedOperationInPartitionFileB()); + R_UNLESS((m_mode & fs::OpenMode_Read) != 0, fs::ResultReadNotPermitted()); + R_UNLESS((m_mode & fs::OpenMode_Write) == 0, fs::ResultUnsupportedOperationInPartitionFileB()); break; case fs::OperationId::QueryRange: break; @@ -100,12 +100,12 @@ namespace ams::fssystem { } /* Validate offset and size. */ - R_UNLESS(offset >= 0, fs::ResultOutOfRange()); - R_UNLESS(offset <= static_cast(this->partition_entry->size), fs::ResultOutOfRange()); - R_UNLESS(static_cast(offset + size) <= static_cast(this->partition_entry->size), fs::ResultInvalidSize()); - R_UNLESS(static_cast(offset + size) >= offset, fs::ResultInvalidSize()); + R_UNLESS(offset >= 0, fs::ResultOutOfRange()); + R_UNLESS(offset <= static_cast(m_partition_entry->size), fs::ResultOutOfRange()); + R_UNLESS(static_cast(offset + size) <= static_cast(m_partition_entry->size), fs::ResultInvalidSize()); + R_UNLESS(static_cast(offset + size) >= offset, fs::ResultInvalidSize()); - return this->parent->base_storage->OperateRange(dst, dst_size, op_id, this->parent->meta_data_size + this->partition_entry->offset + offset, size, src, src_size); + return m_parent->m_base_storage->OperateRange(dst, dst_size, op_id, m_parent->m_meta_data_size + m_partition_entry->offset + offset, size, src, src_size); } public: virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { @@ -118,10 +118,10 @@ namespace ams::fssystem { Result PartitionFileSystemCore::PartitionFile::DoRead(size_t *out, s64 offset, void *dst, size_t dst_size, const fs::ReadOption &option) { /* Perform a dry read. */ size_t read_size = 0; - R_TRY(this->DryRead(std::addressof(read_size), offset, dst_size, option, this->mode)); + R_TRY(this->DryRead(std::addressof(read_size), offset, dst_size, option, m_mode)); /* Read from the base storage. */ - R_TRY(this->parent->base_storage->Read(this->parent->meta_data_size + this->partition_entry->offset + offset, dst, read_size)); + R_TRY(m_parent->m_base_storage->Read(m_parent->m_meta_data_size + m_partition_entry->offset + offset, dst, read_size)); /* Set output size. */ *out = read_size; @@ -132,22 +132,22 @@ namespace ams::fssystem { Result PartitionFileSystemCore::PartitionFile::DoRead(size_t *out, s64 offset, void *dst, size_t dst_size, const fs::ReadOption &option) { /* Perform a dry read. */ size_t read_size = 0; - R_TRY(this->DryRead(std::addressof(read_size), offset, dst_size, option, this->mode)); + R_TRY(this->DryRead(std::addressof(read_size), offset, dst_size, option, m_mode)); - const s64 entry_start = this->parent->meta_data_size + this->partition_entry->offset; + const s64 entry_start = m_parent->m_meta_data_size + m_partition_entry->offset; const s64 read_end = static_cast(offset + read_size); - const s64 hash_start = static_cast(this->partition_entry->hash_target_offset); - const s64 hash_end = hash_start + this->partition_entry->hash_target_size; + const s64 hash_start = static_cast(m_partition_entry->hash_target_offset); + const s64 hash_end = hash_start + m_partition_entry->hash_target_size; if (read_end <= hash_start || hash_end <= offset) { /* We aren't reading hashed data, so we can just read from the base storage. */ - R_TRY(this->parent->base_storage->Read(entry_start + offset, dst, read_size)); + R_TRY(m_parent->m_base_storage->Read(entry_start + offset, dst, read_size)); } else { /* Only hash target offset == 0 is supported. */ R_UNLESS(hash_start == 0, fs::ResultInvalidSha256PartitionHashTarget()); /* Ensure that the hash region is valid. */ - R_UNLESS(this->partition_entry->hash_target_offset + this->partition_entry->hash_target_size <= this->partition_entry->size, fs::ResultInvalidSha256PartitionHashTarget()); + R_UNLESS(m_partition_entry->hash_target_offset + m_partition_entry->hash_target_size <= m_partition_entry->size, fs::ResultInvalidSha256PartitionHashTarget()); /* Validate our read offset. */ const s64 read_offset = entry_start + offset; @@ -167,11 +167,11 @@ namespace ams::fssystem { if (hash_in_read) { /* Easy case: hash region is contained within the bounds. */ - R_TRY(this->parent->base_storage->Read(entry_start + offset, dst, read_size)); - generator.Update(static_cast(dst) + hash_start - offset, this->partition_entry->hash_target_size); + R_TRY(m_parent->m_base_storage->Read(entry_start + offset, dst, read_size)); + generator.Update(static_cast(dst) + hash_start - offset, m_partition_entry->hash_target_size); } else /* if (read_in_hash) */ { /* We're reading a portion of what's hashed. */ - s64 remaining_hash_size = this->partition_entry->hash_target_size; + s64 remaining_hash_size = m_partition_entry->hash_target_size; s64 hash_offset = entry_start + hash_start; s64 remaining_size = read_size; s64 copy_offset = 0; @@ -180,7 +180,7 @@ namespace ams::fssystem { constexpr size_t HashBufferSize = 0x200; char hash_buffer[HashBufferSize]; size_t cur_size = static_cast(std::min(static_cast(HashBufferSize), remaining_hash_size)); - R_TRY(this->parent->base_storage->Read(hash_offset, hash_buffer, cur_size)); + R_TRY(m_parent->m_base_storage->Read(hash_offset, hash_buffer, cur_size)); /* Update the hash. */ generator.Update(hash_buffer, cur_size); @@ -205,7 +205,7 @@ namespace ams::fssystem { /* Validate the hash. */ auto hash_guard = SCOPE_GUARD { std::memset(dst, 0, read_size); }; - R_UNLESS(crypto::IsSameBytes(this->partition_entry->hash, hash, sizeof(hash)), fs::ResultSha256PartitionHashVerificationFailed()); + R_UNLESS(crypto::IsSameBytes(m_partition_entry->hash, hash, sizeof(hash)), fs::ResultSha256PartitionHashVerificationFailed()); /* We successfully completed our read. */ hash_guard.Cancel(); @@ -219,30 +219,30 @@ namespace ams::fssystem { template class PartitionFileSystemCore::PartitionDirectory : public fs::fsa::IDirectory, public fs::impl::Newable { private: - u32 cur_index; - const PartitionFileSystemCore *parent; - const fs::OpenDirectoryMode mode; + u32 m_cur_index; + const PartitionFileSystemCore *m_parent; + const fs::OpenDirectoryMode m_mode; public: - PartitionDirectory(PartitionFileSystemCore *parent, fs::OpenDirectoryMode mode) : cur_index(0), parent(parent), mode(mode) { /* ... */ } + PartitionDirectory(PartitionFileSystemCore *parent, fs::OpenDirectoryMode mode) : m_cur_index(0), m_parent(parent), m_mode(mode) { /* ... */ } public: virtual Result DoRead(s64 *out_count, fs::DirectoryEntry *out_entries, s64 max_entries) override final { /* There are no subdirectories. */ - if ((this->mode & fs::OpenDirectoryMode_File) == 0) { + if ((m_mode & fs::OpenDirectoryMode_File) == 0) { *out_count = 0; return ResultSuccess(); } /* Calculate number of entries. */ - const s64 entry_count = std::min(max_entries, static_cast(this->parent->meta_data->GetEntryCount() - this->cur_index)); + const s64 entry_count = std::min(max_entries, static_cast(m_parent->m_meta_data->GetEntryCount() - m_cur_index)); /* Populate output directory entries. */ - for (auto i = 0; i < entry_count; i++, this->cur_index++) { + for (auto i = 0; i < entry_count; i++, m_cur_index++) { fs::DirectoryEntry &dir_entry = out_entries[i]; /* Setup the output directory entry. */ dir_entry.type = fs::DirectoryEntryType_File; - dir_entry.file_size = this->parent->meta_data->GetEntry(this->cur_index)->size; - std::strncpy(dir_entry.name, this->parent->meta_data->GetEntryName(this->cur_index), sizeof(dir_entry.name) - 1); + dir_entry.file_size = m_parent->m_meta_data->GetEntry(m_cur_index)->size; + std::strncpy(dir_entry.name, m_parent->m_meta_data->GetEntryName(m_cur_index), sizeof(dir_entry.name) - 1); dir_entry.name[sizeof(dir_entry.name) - 1] = fs::StringTraits::NullTerminator; } @@ -252,8 +252,8 @@ namespace ams::fssystem { virtual Result DoGetEntryCount(s64 *out) override final { /* Output the parent meta data entry count for files, otherwise 0. */ - if (this->mode & fs::OpenDirectoryMode_File) { - *out = this->parent->meta_data->GetEntryCount(); + if (m_mode & fs::OpenDirectoryMode_File) { + *out = m_parent->m_meta_data->GetEntryCount(); } else { *out = 0; } @@ -268,7 +268,7 @@ namespace ams::fssystem { }; template - PartitionFileSystemCore::PartitionFileSystemCore() : initialized(false) { + PartitionFileSystemCore::PartitionFileSystemCore() : m_initialized(false) { /* ... */ } @@ -280,40 +280,40 @@ namespace ams::fssystem { template Result PartitionFileSystemCore::Initialize(fs::IStorage *base_storage, MemoryResource *allocator) { /* Validate preconditions. */ - R_UNLESS(!this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(!m_initialized, fs::ResultPreconditionViolation()); /* Allocate meta data. */ - this->unique_meta_data = std::make_unique(); - R_UNLESS(this->unique_meta_data != nullptr, fs::ResultAllocationFailureInPartitionFileSystemA()); + m_unique_meta_data = std::make_unique(); + R_UNLESS(m_unique_meta_data != nullptr, fs::ResultAllocationFailureInPartitionFileSystemA()); /* Initialize meta data. */ - R_TRY(this->unique_meta_data->Initialize(base_storage, allocator)); + R_TRY(m_unique_meta_data->Initialize(base_storage, allocator)); /* Initialize members. */ - this->meta_data = this->unique_meta_data.get(); - this->base_storage = base_storage; - this->meta_data_size = this->meta_data->GetMetaDataSize(); - this->initialized = true; + m_meta_data = m_unique_meta_data.get(); + m_base_storage = base_storage; + m_meta_data_size = m_meta_data->GetMetaDataSize(); + m_initialized = true; return ResultSuccess(); } template Result PartitionFileSystemCore::Initialize(std::unique_ptr &&meta_data, std::shared_ptr base_storage) { - this->unique_meta_data = std::move(meta_data); - return this->Initialize(this->unique_meta_data.get(), base_storage); + m_unique_meta_data = std::move(meta_data); + return this->Initialize(m_unique_meta_data.get(), base_storage); } template Result PartitionFileSystemCore::Initialize(MetaType *meta_data, std::shared_ptr base_storage) { /* Validate preconditions. */ - R_UNLESS(!this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(!m_initialized, fs::ResultPreconditionViolation()); /* Initialize members. */ - this->shared_storage = std::move(base_storage); - this->base_storage = this->shared_storage.get(); - this->meta_data = meta_data; - this->meta_data_size = this->meta_data->GetMetaDataSize(); - this->initialized = true; + m_shared_storage = std::move(base_storage); + m_base_storage = m_shared_storage.get(); + m_meta_data = meta_data; + m_meta_data_size = m_meta_data->GetMetaDataSize(); + m_initialized = true; return ResultSuccess(); } @@ -324,34 +324,34 @@ namespace ams::fssystem { template Result PartitionFileSystemCore::Initialize(std::shared_ptr base_storage) { - this->shared_storage = std::move(base_storage); - return this->Initialize(this->shared_storage.get()); + m_shared_storage = std::move(base_storage); + return this->Initialize(m_shared_storage.get()); } template Result PartitionFileSystemCore::Initialize(std::shared_ptr base_storage, MemoryResource *allocator) { - this->shared_storage = std::move(base_storage); - return this->Initialize(this->shared_storage.get(), allocator); + m_shared_storage = std::move(base_storage); + return this->Initialize(m_shared_storage.get(), allocator); } template Result PartitionFileSystemCore::GetFileBaseOffset(s64 *out_offset, const char *path) { /* Validate preconditions. */ - R_UNLESS(this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(m_initialized, fs::ResultPreconditionViolation()); /* Obtain and validate the entry index. */ - const s32 entry_index = this->meta_data->GetEntryIndex(path + 1); + const s32 entry_index = m_meta_data->GetEntryIndex(path + 1); R_UNLESS(entry_index >= 0, fs::ResultPathNotFound()); /* Output offset. */ - *out_offset = this->meta_data_size + this->meta_data->GetEntry(entry_index)->offset; + *out_offset = m_meta_data_size + m_meta_data->GetEntry(entry_index)->offset; return ResultSuccess(); } template Result PartitionFileSystemCore::DoGetEntryType(fs::DirectoryEntryType *out, const char *path) { /* Validate preconditions. */ - R_UNLESS(this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(m_initialized, fs::ResultPreconditionViolation()); R_UNLESS(fs::PathNormalizer::IsSeparator(path[0]), fs::ResultInvalidPathFormat()); /* Check if the path is for a directory. */ @@ -361,7 +361,7 @@ namespace ams::fssystem { } /* Ensure that path is for a file. */ - R_UNLESS(this->meta_data->GetEntryIndex(path + 1) >= 0, fs::ResultPathNotFound()); + R_UNLESS(m_meta_data->GetEntryIndex(path + 1) >= 0, fs::ResultPathNotFound()); *out = fs::DirectoryEntryType_File; return ResultSuccess(); @@ -370,14 +370,14 @@ namespace ams::fssystem { template Result PartitionFileSystemCore::DoOpenFile(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) { /* Validate preconditions. */ - R_UNLESS(this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(m_initialized, fs::ResultPreconditionViolation()); /* Obtain and validate the entry index. */ - const s32 entry_index = this->meta_data->GetEntryIndex(path + 1); + const s32 entry_index = m_meta_data->GetEntryIndex(path + 1); R_UNLESS(entry_index >= 0, fs::ResultPathNotFound()); /* Create and output the file directory. */ - std::unique_ptr file = std::make_unique(this, this->meta_data->GetEntry(entry_index), mode); + std::unique_ptr file = std::make_unique(this, m_meta_data->GetEntry(entry_index), mode); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInPartitionFileSystemB()); *out_file = std::move(file); return ResultSuccess(); @@ -386,7 +386,7 @@ namespace ams::fssystem { template Result PartitionFileSystemCore::DoOpenDirectory(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) { /* Validate preconditions. */ - R_UNLESS(this->initialized, fs::ResultPreconditionViolation()); + R_UNLESS(m_initialized, fs::ResultPreconditionViolation()); R_UNLESS(std::strncmp(path, fs::PathNormalizer::RootPath, sizeof(fs::PathNormalizer::RootPath)) == 0, fs::ResultPathNotFound()); /* Create and output the partition directory. */ diff --git a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp index 9580a135c..17bfd2274 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system_meta.cpp @@ -38,16 +38,16 @@ namespace ams::fssystem { AMS_ASSERT(allocator != nullptr); /* Determine the meta data size. */ - R_TRY(this->QueryMetaDataSize(std::addressof(this->meta_data_size), storage)); + R_TRY(this->QueryMetaDataSize(std::addressof(m_meta_data_size), storage)); /* Deallocate any old meta buffer and allocate a new one. */ this->DeallocateBuffer(); - this->allocator = allocator; - this->buffer = static_cast(this->allocator->Allocate(this->meta_data_size)); - R_UNLESS(this->buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaA()); + m_allocator = allocator; + m_buffer = static_cast(m_allocator->Allocate(m_meta_data_size)); + R_UNLESS(m_buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaA()); /* Perform regular initialization. */ - return this->Initialize(storage, this->buffer, this->meta_data_size); + return this->Initialize(storage, m_buffer, m_meta_data_size); } template @@ -59,46 +59,46 @@ namespace ams::fssystem { R_TRY(storage->Read(0, meta, sizeof(PartitionFileSystemHeader))); /* Set and validate the header. */ - this->header = reinterpret_cast(meta); - R_UNLESS(crypto::IsSameBytes(this->header->signature, Format::VersionSignature, sizeof(Format::VersionSignature)), typename Format::ResultSignatureVerificationFailed()); + m_header = reinterpret_cast(meta); + R_UNLESS(crypto::IsSameBytes(m_header->signature, Format::VersionSignature, sizeof(Format::VersionSignature)), typename Format::ResultSignatureVerificationFailed()); /* Setup entries and name table. */ - const size_t entries_size = this->header->entry_count * sizeof(typename Format::PartitionEntry); - this->entries = reinterpret_cast(static_cast(meta) + sizeof(PartitionFileSystemHeader)); - this->name_table = static_cast(meta) + sizeof(PartitionFileSystemHeader) + entries_size; + const size_t entries_size = m_header->entry_count * sizeof(typename Format::PartitionEntry); + m_entries = reinterpret_cast(static_cast(meta) + sizeof(PartitionFileSystemHeader)); + m_name_table = static_cast(meta) + sizeof(PartitionFileSystemHeader) + entries_size; /* Validate size for header + entries + name table. */ - R_UNLESS(meta_size >= sizeof(PartitionFileSystemHeader) + entries_size + this->header->name_table_size, fs::ResultInvalidSize()); + R_UNLESS(meta_size >= sizeof(PartitionFileSystemHeader) + entries_size + m_header->name_table_size, fs::ResultInvalidSize()); /* Read entries and name table. */ - R_TRY(storage->Read(sizeof(PartitionFileSystemHeader), this->entries, entries_size + this->header->name_table_size)); + R_TRY(storage->Read(sizeof(PartitionFileSystemHeader), m_entries, entries_size + m_header->name_table_size)); /* Mark as initialized. */ - this->initialized = true; + m_initialized = true; return ResultSuccess(); } template void PartitionFileSystemMetaCore::DeallocateBuffer() { - if (this->buffer != nullptr) { - AMS_ABORT_UNLESS(this->allocator != nullptr); - this->allocator->Deallocate(this->buffer, this->meta_data_size); - this->buffer = nullptr; + if (m_buffer != nullptr) { + AMS_ABORT_UNLESS(m_allocator != nullptr); + m_allocator->Deallocate(m_buffer, m_meta_data_size); + m_buffer = nullptr; } } template const typename Format::PartitionEntry *PartitionFileSystemMetaCore::GetEntry(s32 index) const { - if (this->initialized && 0 <= index && index < static_cast(this->header->entry_count)) { - return std::addressof(this->entries[index]); + if (m_initialized && 0 <= index && index < static_cast(m_header->entry_count)) { + return std::addressof(m_entries[index]); } return nullptr; } template s32 PartitionFileSystemMetaCore::GetEntryCount() const { - if (this->initialized) { - return this->header->entry_count; + if (m_initialized) { + return m_header->entry_count; } return 0; } @@ -106,21 +106,21 @@ namespace ams::fssystem { template s32 PartitionFileSystemMetaCore::GetEntryIndex(const char *name) const { /* Fail if not initialized. */ - if (!this->initialized) { + if (!m_initialized) { return 0; } - for (s32 i = 0; i < static_cast(this->header->entry_count); i++) { - const auto &entry = this->entries[i]; + for (s32 i = 0; i < static_cast(m_header->entry_count); i++) { + const auto &entry = m_entries[i]; /* Name offset is invalid. */ - if (entry.name_offset >= this->header->name_table_size) { + if (entry.name_offset >= m_header->name_table_size) { return 0; } /* Compare to input name. */ - const s32 max_name_len = this->header->name_table_size - entry.name_offset; - if (std::strncmp(std::addressof(this->name_table[entry.name_offset]), name, max_name_len) == 0) { + const s32 max_name_len = m_header->name_table_size - entry.name_offset; + if (std::strncmp(std::addressof(m_name_table[entry.name_offset]), name, max_name_len) == 0) { return i; } } @@ -131,8 +131,8 @@ namespace ams::fssystem { template const char *PartitionFileSystemMetaCore::GetEntryName(s32 index) const { - if (this->initialized && index < static_cast(this->header->entry_count)) { - return std::addressof(this->name_table[this->GetEntry(index)->name_offset]); + if (m_initialized && index < static_cast(m_header->entry_count)) { + return std::addressof(m_name_table[this->GetEntry(index)->name_offset]); } return nullptr; } @@ -144,7 +144,7 @@ namespace ams::fssystem { template size_t PartitionFileSystemMetaCore::GetMetaDataSize() const { - return this->meta_data_size; + return m_meta_data_size; } template @@ -167,25 +167,25 @@ namespace ams::fssystem { R_UNLESS(hash_size == crypto::Sha256Generator::HashSize, fs::ResultPreconditionViolation()); /* Get metadata size. */ - R_TRY(QueryMetaDataSize(std::addressof(this->meta_data_size), base_storage)); + R_TRY(QueryMetaDataSize(std::addressof(m_meta_data_size), base_storage)); /* Ensure we have no buffer. */ this->DeallocateBuffer(); /* Set allocator and allocate buffer. */ - this->allocator = allocator; - this->buffer = static_cast(this->allocator->Allocate(this->meta_data_size)); - R_UNLESS(this->buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaB()); + m_allocator = allocator; + m_buffer = static_cast(m_allocator->Allocate(m_meta_data_size)); + R_UNLESS(m_buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaB()); /* Read metadata. */ - R_TRY(base_storage->Read(0, this->buffer, this->meta_data_size)); + R_TRY(base_storage->Read(0, m_buffer, m_meta_data_size)); /* Calculate hash. */ char calc_hash[crypto::Sha256Generator::HashSize]; { crypto::Sha256Generator generator; generator.Initialize(); - generator.Update(this->buffer, this->meta_data_size); + generator.Update(m_buffer, m_meta_data_size); if (suffix) { u8 suffix_val = *suffix; generator.Update(std::addressof(suffix_val), 1); @@ -200,19 +200,19 @@ namespace ams::fssystem { using Format = impl::Sha256PartitionFileSystemFormat; /* Set header. */ - this->header = reinterpret_cast(this->buffer); - R_UNLESS(crypto::IsSameBytes(this->header->signature, Format::VersionSignature, sizeof(Format::VersionSignature)), typename Format::ResultSignatureVerificationFailed()); + m_header = reinterpret_cast(m_buffer); + R_UNLESS(crypto::IsSameBytes(m_header->signature, Format::VersionSignature, sizeof(Format::VersionSignature)), typename Format::ResultSignatureVerificationFailed()); /* Validate size for entries and name table. */ - const size_t entries_size = this->header->entry_count * sizeof(typename Format::PartitionEntry); - R_UNLESS(this->meta_data_size >= sizeof(PartitionFileSystemHeader) + entries_size + this->header->name_table_size, fs::ResultInvalidSha256PartitionMetaDataSize()); + const size_t entries_size = m_header->entry_count * sizeof(typename Format::PartitionEntry); + R_UNLESS(m_meta_data_size >= sizeof(PartitionFileSystemHeader) + entries_size + m_header->name_table_size, fs::ResultInvalidSha256PartitionMetaDataSize()); /* Set entries and name table. */ - this->entries = reinterpret_cast(this->buffer + sizeof(PartitionFileSystemHeader)); - this->name_table = this->buffer + sizeof(PartitionFileSystemHeader) + entries_size; + m_entries = reinterpret_cast(m_buffer + sizeof(PartitionFileSystemHeader)); + m_name_table = m_buffer + sizeof(PartitionFileSystemHeader) + entries_size; /* We initialized. */ - this->initialized = true; + m_initialized = true; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp b/libraries/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp index ca2b29e6e..fdd94a5ae 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_pooled_buffer.cpp @@ -21,40 +21,40 @@ namespace ams::fssystem { class AdditionalDeviceAddressEntry { private: - os::SdkMutex mutex; - bool is_registered; - uintptr_t address; - size_t size; + os::SdkMutex m_mutex; + bool m_is_registered; + uintptr_t m_address; + size_t m_size; public: - constexpr AdditionalDeviceAddressEntry() : mutex(), is_registered(), address(), size() { /* ... */ } + constexpr AdditionalDeviceAddressEntry() : m_mutex(), m_is_registered(), m_address(), m_size() { /* ... */ } void Register(uintptr_t addr, size_t sz) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - AMS_ASSERT(!this->is_registered); - if (!this->is_registered) { - this->is_registered = true; - this->address = addr; - this->size = sz; + AMS_ASSERT(!m_is_registered); + if (!m_is_registered) { + m_is_registered = true; + m_address = addr; + m_size = sz; } } void Unregister(uintptr_t addr) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - if (this->is_registered && this->address == addr) { - this->is_registered = false; - this->address = 0; - this->size = 0; + if (m_is_registered && m_address == addr) { + m_is_registered = false; + m_address = 0; + m_size = 0; } } bool Includes(const void *ptr) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - if (this->is_registered) { + if (m_is_registered) { const uintptr_t addr = reinterpret_cast(ptr); - return this->address <= addr && addr < this->address + this->size; + return m_address <= addr && addr < m_address + m_size; } else { return false; } @@ -97,7 +97,7 @@ namespace ams::fssystem { void PooledBuffer::AllocateCore(size_t ideal_size, size_t required_size, bool large) { /* Ensure preconditions. */ AMS_ASSERT(g_heap_buffer != nullptr); - AMS_ASSERT(this->buffer == nullptr); + AMS_ASSERT(m_buffer == nullptr); AMS_ASSERT(g_heap.GetBlockSize() == HeapBlockSize); /* Check that we can allocate this size. */ @@ -123,13 +123,13 @@ namespace ams::fssystem { const auto order = g_heap.GetOrderFromBytes(std::min(target_size, allocatable_size)); /* Allocate and get the size. */ - this->buffer = reinterpret_cast(g_heap.AllocateByOrder(order)); - this->size = g_heap.GetBytesFromOrder(order); + m_buffer = reinterpret_cast(g_heap.AllocateByOrder(order)); + m_size = g_heap.GetBytesFromOrder(order); } } /* Check if we allocated. */ - if (this->buffer != nullptr) { + if (m_buffer != nullptr) { /* If we need to trim the end, do so. */ if (this->GetSize() >= target_size + HeapAllocatableSizeTrim) { this->Shrink(util::AlignUp(target_size, HeapAllocatableSizeTrim)); @@ -163,9 +163,9 @@ namespace ams::fssystem { AMS_ASSERT(ideal_size <= GetAllocatableSizeMaxCore(true)); /* Check if we actually need to shrink. */ - if (this->size > ideal_size) { + if (m_size > ideal_size) { /* If we do, we need to have a buffer allocated from the heap. */ - AMS_ASSERT(this->buffer != nullptr); + AMS_ASSERT(m_buffer != nullptr); AMS_ASSERT(g_heap.GetBlockSize() == HeapBlockSize); const size_t new_size = util::AlignUp(ideal_size, HeapBlockSize); @@ -174,10 +174,10 @@ namespace ams::fssystem { { std::scoped_lock lk(g_heap_mutex); - while (new_size < this->size) { + while (new_size < m_size) { /* Determine the size and order to free. */ - const size_t tail_align = util::LeastSignificantOneBit(this->size); - const size_t free_size = std::min(util::FloorPowerOfTwo(this->size - new_size), tail_align); + const size_t tail_align = util::LeastSignificantOneBit(m_size); + const size_t free_size = std::min(util::FloorPowerOfTwo(m_size - new_size), tail_align); const s32 free_order = g_heap.GetOrderFromBytes(free_size); /* Ensure we determined size correctly. */ @@ -185,14 +185,14 @@ namespace ams::fssystem { AMS_ASSERT(free_size == g_heap.GetBytesFromOrder(free_order)); /* Actually free the memory. */ - g_heap.Free(this->buffer + this->size - free_size, free_order); - this->size -= free_size; + g_heap.Free(m_buffer + m_size - free_size, free_order); + m_size -= free_size; } } /* Shrinking to zero means that we have no buffer. */ - if (this->size == 0) { - this->buffer = nullptr; + if (m_size == 0) { + m_buffer = nullptr; } } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp index efc98f732..5f5f12e27 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp @@ -25,46 +25,46 @@ namespace ams::fssystem { private: using BlockCache = LruListCache; private: - os::SdkMutex mutex; - BlockCache block_cache; - fs::IStorage * const base_storage; - s32 block_size; + os::SdkMutex m_mutex; + BlockCache m_block_cache; + fs::IStorage * const m_base_storage; + s32 m_block_size; public: - ReadOnlyBlockCacheStorage(IStorage *bs, s32 bsz, char *buf, size_t buf_size, s32 cache_block_count) : mutex(), base_storage(bs), block_size(bsz) { + ReadOnlyBlockCacheStorage(IStorage *bs, s32 bsz, char *buf, size_t buf_size, s32 cache_block_count) : m_mutex(), m_block_cache(), m_base_storage(bs), m_block_size(bsz) { /* Validate preconditions. */ - AMS_ASSERT(buf_size >= static_cast(this->block_size)); - AMS_ASSERT(util::IsPowerOfTwo(this->block_size)); + AMS_ASSERT(buf_size >= static_cast(m_block_size)); + AMS_ASSERT(util::IsPowerOfTwo(m_block_size)); AMS_ASSERT(cache_block_count > 0); - AMS_ASSERT(buf_size >= static_cast(this->block_size * cache_block_count)); + AMS_ASSERT(buf_size >= static_cast(m_block_size * cache_block_count)); AMS_UNUSED(buf_size); /* Create a node for each cache block. */ for (auto i = 0; i < cache_block_count; i++) { - std::unique_ptr node = std::make_unique(buf + this->block_size * i); + std::unique_ptr node = std::make_unique(buf + m_block_size * i); AMS_ASSERT(node != nullptr); if (node != nullptr) { - this->block_cache.PushMruNode(std::move(node), -1); + m_block_cache.PushMruNode(std::move(node), -1); } } } ~ReadOnlyBlockCacheStorage() { - this->block_cache.DeleteAllNodes(); + m_block_cache.DeleteAllNodes(); } virtual Result Read(s64 offset, void *buffer, size_t size) override { /* Validate preconditions. */ - AMS_ASSERT(util::IsAligned(offset, this->block_size)); - AMS_ASSERT(util::IsAligned(size, this->block_size)); + AMS_ASSERT(util::IsAligned(offset, m_block_size)); + AMS_ASSERT(util::IsAligned(size, m_block_size)); - if (size == static_cast(this->block_size)) { + if (size == static_cast(m_block_size)) { char *cached_buffer = nullptr; /* Try to find a cached copy of the data. */ { - std::scoped_lock lk(this->mutex); - bool found = this->block_cache.FindValueAndUpdateMru(std::addressof(cached_buffer), offset / this->block_size); + std::scoped_lock lk(m_mutex); + bool found = m_block_cache.FindValueAndUpdateMru(std::addressof(cached_buffer), offset / m_block_size); if (found) { std::memcpy(buffer, cached_buffer, size); return ResultSuccess(); @@ -72,56 +72,56 @@ namespace ams::fssystem { } /* We failed to get a cache hit, so read in the data. */ - R_TRY(this->base_storage->Read(offset, buffer, size)); + R_TRY(m_base_storage->Read(offset, buffer, size)); /* Add the block to the cache. */ { - std::scoped_lock lk(this->mutex); - auto lru = this->block_cache.PopLruNode(); - std::memcpy(lru->value, buffer, this->block_size); - this->block_cache.PushMruNode(std::move(lru), offset / this->block_size); + std::scoped_lock lk(m_mutex); + auto lru = m_block_cache.PopLruNode(); + std::memcpy(lru->m_value, buffer, m_block_size); + m_block_cache.PushMruNode(std::move(lru), offset / m_block_size); } return ResultSuccess(); } else { - return this->base_storage->Read(offset, buffer, size); + return m_base_storage->Read(offset, buffer, size); } } virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { /* Validate preconditions. */ - AMS_ASSERT(util::IsAligned(offset, this->block_size)); - AMS_ASSERT(util::IsAligned(size, this->block_size)); + AMS_ASSERT(util::IsAligned(offset, m_block_size)); + AMS_ASSERT(util::IsAligned(size, m_block_size)); /* If invalidating cache, invalidate our blocks. */ if (op_id == fs::OperationId::Invalidate) { R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - const size_t cache_block_count = this->block_cache.GetSize(); + const size_t cache_block_count = m_block_cache.GetSize(); BlockCache valid_cache; for (size_t count = 0; count < cache_block_count; ++count) { - auto lru = this->block_cache.PopLruNode(); - if (offset <= lru->key && lru->key < offset + size) { - this->block_cache.PushMruNode(std::move(lru), -1); + auto lru = m_block_cache.PopLruNode(); + if (offset <= lru->m_key && lru->m_key < offset + size) { + m_block_cache.PushMruNode(std::move(lru), -1); } else { - valid_cache.PushMruNode(std::move(lru), lru->key); + valid_cache.PushMruNode(std::move(lru), lru->m_key); } } while (!valid_cache.IsEmpty()) { auto lru = valid_cache.PopLruNode(); - this->block_cache.PushMruNode(std::move(lru), lru->key); + m_block_cache.PushMruNode(std::move(lru), lru->m_key); } } /* Operate on the base storage. */ - return this->base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } virtual Result GetSize(s64 *out) override { - return this->base_storage->GetSize(out); + return m_base_storage->GetSize(out); } virtual Result Flush() override { diff --git a/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp index 339b0836c..cacfe8f18 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp @@ -25,15 +25,15 @@ namespace ams::fssystem { class RomFsFile : public ams::fs::fsa::IFile, public ams::fs::impl::Newable { private: - RomFsFileSystem *parent; - s64 start; - s64 end; + RomFsFileSystem *m_parent; + s64 m_start; + s64 m_end; private: s64 GetSize() const { - return this->end - this->start; + return m_end - m_start; } public: - RomFsFile(RomFsFileSystem *p, s64 s, s64 e) : parent(p), start(s), end(e) { /* ... */ } + RomFsFile(RomFsFileSystem *p, s64 s, s64 e) : m_parent(p), m_start(s), m_end(e) { /* ... */ } virtual ~RomFsFile() { /* ... */ } public: virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override { @@ -41,7 +41,7 @@ namespace ams::fssystem { size_t read_size = 0; R_TRY(this->DryRead(std::addressof(read_size), offset, size, option, fs::OpenMode_Read)); - R_TRY(this->parent->GetBaseStorage()->Read(offset + this->start, buffer, read_size)); + R_TRY(m_parent->GetBaseStorage()->Read(offset + m_start, buffer, read_size)); *out = read_size; return ResultSuccess(); @@ -88,7 +88,7 @@ namespace ams::fssystem { } R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([=, this]() -> Result { - R_TRY(this->parent->GetBaseStorage()->OperateRange(dst, dst_size, op_id, this->start + offset, operate_size, src, src_size)); + R_TRY(m_parent->GetBaseStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size)); return ResultSuccess(); }, AMS_CURRENT_FUNCTION_NAME)); return ResultSuccess(); @@ -107,23 +107,23 @@ namespace ams::fssystem { private: using FindPosition = RomFsFileSystem::RomFileTable::FindPosition; private: - RomFsFileSystem *parent; - FindPosition current_find; - FindPosition first_find; - fs::OpenDirectoryMode mode; + RomFsFileSystem *m_parent; + FindPosition m_current_find; + FindPosition m_first_find; + fs::OpenDirectoryMode m_mode; public: - RomFsDirectory(RomFsFileSystem *p, const FindPosition &f, fs::OpenDirectoryMode m) : parent(p), current_find(f), first_find(f), mode(m) { /* ... */ } + RomFsDirectory(RomFsFileSystem *p, const FindPosition &f, fs::OpenDirectoryMode m) : m_parent(p), m_current_find(f), m_first_find(f), m_mode(m) { /* ... */ } virtual ~RomFsDirectory() override { /* ... */ } public: virtual Result DoRead(s64 *out_count, fs::DirectoryEntry *out_entries, s64 max_entries) { R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([=, this]() -> Result { - return this->ReadInternal(out_count, std::addressof(this->current_find), out_entries, max_entries); + return this->ReadInternal(out_count, std::addressof(m_current_find), out_entries, max_entries); }, AMS_CURRENT_FUNCTION_NAME)); return ResultSuccess(); } virtual Result DoGetEntryCount(s64 *out) { - FindPosition find = this->first_find; + FindPosition find = m_first_find; R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([&]() -> Result { R_TRY(this->ReadInternal(out, std::addressof(find), nullptr, 0)); @@ -137,9 +137,9 @@ namespace ams::fssystem { fs::RomPathChar name[NameBufferSize]; s32 i = 0; - if (this->mode & fs::OpenDirectoryMode_Directory) { + if (m_mode & fs::OpenDirectoryMode_Directory) { while (i < max_entries || out_entries == nullptr) { - R_TRY_CATCH(this->parent->GetRomFileTable()->FindNextDirectory(name, find, NameBufferSize)) { + R_TRY_CATCH(m_parent->GetRomFileTable()->FindNextDirectory(name, find, NameBufferSize)) { R_CATCH(fs::ResultDbmFindFinished) { break; } } R_END_TRY_CATCH; @@ -155,11 +155,11 @@ namespace ams::fssystem { } } - if (this->mode & fs::OpenDirectoryMode_File) { + if (m_mode & fs::OpenDirectoryMode_File) { while (i < max_entries || out_entries == nullptr) { auto file_pos = find->next_file; - R_TRY_CATCH(this->parent->GetRomFileTable()->FindNextFile(name, find, NameBufferSize)) { + R_TRY_CATCH(m_parent->GetRomFileTable()->FindNextFile(name, find, NameBufferSize)) { R_CATCH(fs::ResultDbmFindFinished) { break; } } R_END_TRY_CATCH; @@ -170,7 +170,7 @@ namespace ams::fssystem { out_entries[i].type = fs::DirectoryEntryType_File; RomFsFileSystem::RomFileTable::FileInfo file_info; - R_TRY(this->parent->GetRomFileTable()->OpenFile(std::addressof(file_info), this->parent->GetRomFileTable()->PositionToFileId(file_pos))); + R_TRY(m_parent->GetRomFileTable()->OpenFile(std::addressof(file_info), m_parent->GetRomFileTable()->PositionToFileId(file_pos))); out_entries[i].file_size = file_info.size.Get(); } @@ -190,7 +190,7 @@ namespace ams::fssystem { } - RomFsFileSystem::RomFsFileSystem() : base_storage() { + RomFsFileSystem::RomFsFileSystem() : m_base_storage() { /* ... */ } @@ -199,11 +199,11 @@ namespace ams::fssystem { } fs::IStorage *RomFsFileSystem::GetBaseStorage() { - return this->base_storage; + return m_base_storage; } RomFsFileSystem::RomFileTable *RomFsFileSystem::GetRomFileTable() { - return std::addressof(this->rom_file_table); + return std::addressof(m_rom_file_table); } Result RomFsFileSystem::GetRequiredWorkingMemorySize(size_t *out, fs::IStorage *storage) { @@ -246,43 +246,43 @@ namespace ams::fssystem { R_TRY(base->Read(header.file_bucket_offset, file_bucket_buf, static_cast(header.file_bucket_size))); R_TRY(base->Read(header.file_entry_offset, file_entry_buf, static_cast(header.file_entry_size))); - this->dir_bucket_storage.reset(new fs::MemoryStorage(dir_bucket_buf, header.directory_bucket_size)); - this->dir_entry_storage.reset(new fs::MemoryStorage(dir_entry_buf, header.directory_entry_size)); - this->file_bucket_storage.reset(new fs::MemoryStorage(file_bucket_buf, header.file_bucket_size)); - this->file_entry_storage.reset(new fs::MemoryStorage(file_entry_buf, header.file_entry_size)); + m_dir_bucket_storage.reset(new fs::MemoryStorage(dir_bucket_buf, header.directory_bucket_size)); + m_dir_entry_storage.reset(new fs::MemoryStorage(dir_entry_buf, header.directory_entry_size)); + m_file_bucket_storage.reset(new fs::MemoryStorage(file_bucket_buf, header.file_bucket_size)); + m_file_entry_storage.reset(new fs::MemoryStorage(file_entry_buf, header.file_entry_size)); } else { - this->dir_bucket_storage.reset(new fs::SubStorage(base, header.directory_bucket_offset, header.directory_bucket_size)); - this->dir_entry_storage.reset(new fs::SubStorage(base, header.directory_entry_offset, header.directory_entry_size)); - this->file_bucket_storage.reset(new fs::SubStorage(base, header.file_bucket_offset, header.file_bucket_size)); - this->file_entry_storage.reset(new fs::SubStorage(base, header.file_entry_offset, header.file_entry_size)); + m_dir_bucket_storage.reset(new fs::SubStorage(base, header.directory_bucket_offset, header.directory_bucket_size)); + m_dir_entry_storage.reset(new fs::SubStorage(base, header.directory_entry_offset, header.directory_entry_size)); + m_file_bucket_storage.reset(new fs::SubStorage(base, header.file_bucket_offset, header.file_bucket_size)); + m_file_entry_storage.reset(new fs::SubStorage(base, header.file_entry_offset, header.file_entry_size)); } /* Ensure we allocated storages successfully. */ - R_UNLESS(this->dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); - R_UNLESS(this->dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); - R_UNLESS(this->file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); - R_UNLESS(this->file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); + R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); + R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); + R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); + R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB()); /* Initialize the rom table. */ - R_TRY(this->rom_file_table.Initialize(fs::SubStorage(this->dir_bucket_storage.get(), 0, static_cast(header.directory_bucket_size)), - fs::SubStorage(this->dir_entry_storage.get(), 0, static_cast(header.directory_entry_size)), - fs::SubStorage(this->file_bucket_storage.get(), 0, static_cast(header.file_bucket_size)), - fs::SubStorage(this->file_entry_storage.get(), 0, static_cast(header.file_entry_size)))); + R_TRY(m_rom_file_table.Initialize(fs::SubStorage(m_dir_bucket_storage.get(), 0, static_cast(header.directory_bucket_size)), + fs::SubStorage(m_dir_entry_storage.get(), 0, static_cast(header.directory_entry_size)), + fs::SubStorage(m_file_bucket_storage.get(), 0, static_cast(header.file_bucket_size)), + fs::SubStorage(m_file_entry_storage.get(), 0, static_cast(header.file_entry_size)))); /* Set members. */ - this->entry_size = header.body_offset; - this->base_storage = base; + m_entry_size = header.body_offset; + m_base_storage = base; return ResultSuccess(); } Result RomFsFileSystem::Initialize(std::shared_ptr base, void *work, size_t work_size, bool use_cache) { - this->shared_storage = std::move(base); - return this->Initialize(this->shared_storage.get(), work, work_size, use_cache); + m_shared_storage = std::move(base); + return this->Initialize(m_shared_storage.get(), work, work_size, use_cache); } Result RomFsFileSystem::GetFileInfo(RomFileTable::FileInfo *out, const char *path) { R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([=, this]() -> Result { - R_TRY_CATCH(this->rom_file_table.OpenFile(out, path)) { + R_TRY_CATCH(m_rom_file_table.OpenFile(out, path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()); } R_END_TRY_CATCH; @@ -295,7 +295,7 @@ namespace ams::fssystem { Result RomFsFileSystem::GetFileBaseOffset(s64 *out, const char *path) { RomFileTable::FileInfo info; R_TRY(this->GetFileInfo(std::addressof(info), path)); - *out = this->entry_size + info.offset.Get(); + *out = m_entry_size + info.offset.Get(); return ResultSuccess(); } @@ -338,7 +338,7 @@ namespace ams::fssystem { R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([=, this]() -> Result { fs::RomDirectoryInfo dir_info; - R_TRY_CATCH(this->rom_file_table.GetDirectoryInformation(std::addressof(dir_info), path)) { + R_TRY_CATCH(m_rom_file_table.GetDirectoryInformation(std::addressof(dir_info), path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()) R_CATCH(fs::ResultDbmInvalidOperation) { RomFileTable::FileInfo file_info; @@ -362,7 +362,7 @@ namespace ams::fssystem { RomFileTable::FileInfo file_info; R_TRY(this->GetFileInfo(std::addressof(file_info), path)); - auto file = std::make_unique(this, this->entry_size + file_info.offset.Get(), this->entry_size + file_info.offset.Get() + file_info.size.Get()); + auto file = std::make_unique(this, m_entry_size + file_info.offset.Get(), m_entry_size + file_info.offset.Get() + file_info.size.Get()); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInRomFsFileSystemC()); *out_file = std::move(file); @@ -372,7 +372,7 @@ namespace ams::fssystem { Result RomFsFileSystem::DoOpenDirectory(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) { RomFileTable::FindPosition find; R_TRY(buffers::DoContinuouslyUntilBufferIsAllocated([&]() -> Result { - R_TRY_CATCH(this->rom_file_table.FindOpen(std::addressof(find), path)) { + R_TRY_CATCH(m_rom_file_table.FindOpen(std::addressof(find), path)) { R_CONVERT(fs::ResultDbmNotFound, fs::ResultPathNotFound()) } R_END_TRY_CATCH; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp index 71f7a7176..61b5f26fc 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp @@ -20,20 +20,20 @@ namespace ams::fssystem { SubDirectoryFileSystem::SubDirectoryFileSystem(std::shared_ptr fs, const char *bp, bool unc) : PathResolutionFileSystem(fs, unc) { - this->base_path = nullptr; + m_base_path = nullptr; R_ABORT_UNLESS(this->Initialize(bp)); } SubDirectoryFileSystem::SubDirectoryFileSystem(std::unique_ptr fs, const char *bp, bool unc) : PathResolutionFileSystem(std::move(fs), unc) { - this->base_path = nullptr; + m_base_path = nullptr; R_ABORT_UNLESS(this->Initialize(bp)); } SubDirectoryFileSystem::~SubDirectoryFileSystem() { - if (this->base_path != nullptr) { - fs::impl::Deallocate(this->base_path, this->base_path_len); + if (m_base_path != nullptr) { + fs::impl::Deallocate(m_base_path, m_base_path_len); } } @@ -56,25 +56,25 @@ namespace ams::fssystem { } /* Allocate new path. */ - this->base_path_len = normalized_path_len + 1; - this->base_path = static_cast(fs::impl::Allocate(this->base_path_len)); - R_UNLESS(this->base_path != nullptr, fs::ResultAllocationFailureInSubDirectoryFileSystem()); + m_base_path_len = normalized_path_len + 1; + m_base_path = static_cast(fs::impl::Allocate(m_base_path_len)); + R_UNLESS(m_base_path != nullptr, fs::ResultAllocationFailureInSubDirectoryFileSystem()); /* Copy path in. */ - std::memcpy(this->base_path, normalized_path, normalized_path_len); - this->base_path[normalized_path_len] = fs::StringTraits::NullTerminator; + std::memcpy(m_base_path, normalized_path, normalized_path_len); + m_base_path[normalized_path_len] = fs::StringTraits::NullTerminator; return ResultSuccess(); } Result SubDirectoryFileSystem::ResolveFullPath(char *out, size_t out_size, const char *relative_path) { /* Ensure path will fit. */ - R_UNLESS(this->base_path_len + strnlen(relative_path, fs::EntryNameLengthMax + 1) <= out_size, fs::ResultTooLongPath()); + R_UNLESS(m_base_path_len + strnlen(relative_path, fs::EntryNameLengthMax + 1) <= out_size, fs::ResultTooLongPath()); /* Copy base path. */ - std::memcpy(out, this->base_path, this->base_path_len); + std::memcpy(out, m_base_path, m_base_path_len); /* Normalize it. */ - const size_t prefix_size = this->base_path_len - 2; + const size_t prefix_size = m_base_path_len - 2; size_t normalized_len; return fs::PathNormalizer::Normalize(out + prefix_size, std::addressof(normalized_len), relative_path, out_size - prefix_size, this->IsUncPreserved(), false); } diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp index b79c5f6e0..b6794dd4e 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp @@ -18,7 +18,7 @@ namespace ams::fssystem::save { BlockCacheBufferedStorage::BlockCacheBufferedStorage() - : buffer_manager(), mutex(), entries(), data_storage(), last_result(ResultSuccess()), data_size(), verification_block_size(), verification_block_shift(), invalidate_index(), max_cache_entry_count(), flags(), buffer_level(-1) + : m_buffer_manager(), m_mutex(), m_entries(), m_data_storage(), m_last_result(ResultSuccess()), m_data_size(), m_verification_block_size(), m_verification_block_shift(), m_invalidate_index(), m_max_cache_entry_count(), m_flags(), m_buffer_level(-1) { /* ... */ } @@ -32,35 +32,35 @@ namespace ams::fssystem::save { AMS_ASSERT(data != nullptr); AMS_ASSERT(bm != nullptr); AMS_ASSERT(mtx != nullptr); - AMS_ASSERT(this->buffer_manager == nullptr); - AMS_ASSERT(this->mutex == nullptr); - AMS_ASSERT(this->data_storage == nullptr); - AMS_ASSERT(this->entries == nullptr); + AMS_ASSERT(m_buffer_manager == nullptr); + AMS_ASSERT(m_mutex == nullptr); + AMS_ASSERT(m_data_storage == nullptr); + AMS_ASSERT(m_entries == nullptr); AMS_ASSERT(max_cache_entries > 0); /* Create the entry. */ - this->entries = fs::impl::MakeUnique(static_cast(max_cache_entries)); - R_UNLESS(this->entries != nullptr, fs::ResultAllocationFailureInBlockCacheBufferedStorageA()); + m_entries = fs::impl::MakeUnique(static_cast(max_cache_entries)); + R_UNLESS(m_entries != nullptr, fs::ResultAllocationFailureInBlockCacheBufferedStorageA()); /* Set members. */ - this->buffer_manager = bm; - this->mutex = mtx; - this->data_storage = data; - this->data_size = data_size; - this->verification_block_size = verif_block_size; - this->last_result = ResultSuccess(); - this->invalidate_index = 0; - this->max_cache_entry_count = max_cache_entries; - this->flags = 0; - this->buffer_level = buffer_level; - this->storage_type = storage_type; + m_buffer_manager = bm; + m_mutex = mtx; + m_data_storage = data; + m_data_size = data_size; + m_verification_block_size = verif_block_size; + m_last_result = ResultSuccess(); + m_invalidate_index = 0; + m_max_cache_entry_count = max_cache_entries; + m_flags = 0; + m_buffer_level = buffer_level; + m_storage_type = storage_type; /* Calculate block shift. */ - this->verification_block_shift = ILog2(static_cast(verif_block_size)); - AMS_ASSERT(static_cast(1ull << this->verification_block_size) == this->verification_block_size); + m_verification_block_shift = ILog2(static_cast(verif_block_size)); + AMS_ASSERT(static_cast(1ull << m_verification_block_size) == m_verification_block_size); /* Clear the entry. */ - std::memset(this->entries.get(), 0, sizeof(CacheEntry) * this->max_cache_entry_count); + std::memset(m_entries.get(), 0, sizeof(CacheEntry) * m_max_cache_entry_count); /* Set burst mode. */ this->SetKeepBurstMode(is_keep_burst_mode); @@ -72,31 +72,31 @@ namespace ams::fssystem::save { } void BlockCacheBufferedStorage::Finalize() { - if (this->entries != nullptr) { + if (m_entries != nullptr) { /* Invalidate all cache entries. */ this->InvalidateAllCacheEntries(); /* Clear members. */ - this->buffer_manager = nullptr; - this->mutex = nullptr; - this->data_storage = nullptr; - this->data_size = 0; - this->verification_block_size = 0; - this->verification_block_shift = 0; - this->invalidate_index = 0; - this->max_cache_entry_count = 0; + m_buffer_manager = nullptr; + m_mutex = nullptr; + m_data_storage = nullptr; + m_data_size = 0; + m_verification_block_size = 0; + m_verification_block_shift = 0; + m_invalidate_index = 0; + m_max_cache_entry_count = 0; - this->entries.reset(); + m_entries.reset(); } } Result BlockCacheBufferedStorage::Read(s64 offset, void *buffer, size_t size) { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Succeed if zero-size. */ R_SUCCEED_IF(size == 0); @@ -108,18 +108,18 @@ namespace ams::fssystem::save { s64 read_offset = offset; size_t read_size = size; - R_UNLESS(read_offset < this->data_size, fs::ResultInvalidOffset()); + R_UNLESS(read_offset < m_data_size, fs::ResultInvalidOffset()); - if (static_cast(read_offset + read_size) > this->data_size) { - read_size = static_cast(this->data_size - read_offset); + if (static_cast(read_offset + read_size) > m_data_size) { + read_size = static_cast(m_data_size - read_offset); } /* Determine the aligned range to read. */ - const size_t block_alignment = this->verification_block_size; + const size_t block_alignment = m_verification_block_size; s64 aligned_offset = util::AlignDown(read_offset, block_alignment); s64 aligned_offset_end = util::AlignUp(read_offset + read_size, block_alignment); - AMS_ASSERT(0 <= aligned_offset && aligned_offset_end <= static_cast(util::AlignUp(this->data_size, block_alignment))); + AMS_ASSERT(0 <= aligned_offset && aligned_offset_end <= static_cast(util::AlignUp(m_data_size, block_alignment))); /* Try to read using cache. */ char *dst = static_cast(buffer); @@ -183,7 +183,7 @@ namespace ams::fssystem::save { R_TRY(this->UpdateLastResult(this->FlushRangeCacheEntries(read_offset, aligned_size, false))); /* Read the data. */ - R_TRY(this->UpdateLastResult(this->data_storage->Read(read_offset, dst, aligned_size))); + R_TRY(this->UpdateLastResult(m_data_storage->Read(read_offset, dst, aligned_size))); /* Advance. */ dst += aligned_size; @@ -202,7 +202,7 @@ namespace ams::fssystem::save { /* If the entry isn't cached, read the data. */ if (!entry.is_cached) { - if (Result result = this->data_storage->Read(entry.offset, src, entry.size); R_FAILED(result)) { + if (Result result = m_data_storage->Read(entry.offset, src, entry.size); R_FAILED(result)) { this->DestroyBuffer(std::addressof(entry), range); return this->UpdateLastResult(result); } @@ -243,11 +243,11 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::Write(s64 offset, const void *buffer, size_t size) { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Succeed if zero-size. */ R_SUCCEED_IF(size == 0); @@ -256,21 +256,21 @@ namespace ams::fssystem::save { R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); /* Determine the extents to read. */ - R_UNLESS(offset < this->data_size, fs::ResultInvalidOffset()); + R_UNLESS(offset < m_data_size, fs::ResultInvalidOffset()); - if (static_cast(offset + size) > this->data_size) { - size = static_cast(this->data_size - offset); + if (static_cast(offset + size) > m_data_size) { + size = static_cast(m_data_size - offset); } /* The actual extents may be zero-size, so succeed if that's the case. */ R_SUCCEED_IF(size == 0); /* Determine the aligned range to read. */ - const size_t block_alignment = this->verification_block_size; + const size_t block_alignment = m_verification_block_size; s64 aligned_offset = util::AlignDown(offset, block_alignment); const s64 aligned_offset_end = util::AlignUp(offset + size, block_alignment); - AMS_ASSERT(0 <= aligned_offset && aligned_offset_end <= static_cast(util::AlignUp(this->data_size, block_alignment))); + AMS_ASSERT(0 <= aligned_offset && aligned_offset_end <= static_cast(util::AlignUp(m_data_size, block_alignment))); /* Write the data. */ const u8 *src = static_cast(buffer); @@ -283,7 +283,7 @@ namespace ams::fssystem::save { R_TRY(this->UpdateLastResult(this->FlushRangeCacheEntries(offset, aligned_size, true))); /* Read the data. */ - R_TRY(this->UpdateLastResult(this->data_storage->Write(offset, src, aligned_size))); + R_TRY(this->UpdateLastResult(m_data_storage->Write(offset, src, aligned_size))); /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -304,7 +304,7 @@ namespace ams::fssystem::save { /* If the entry isn't cached and we're writing a partial entry, read in the entry. */ if (!entry.is_cached && ((offset != entry.offset) || (offset + size < entry.offset + entry.size))) { - if (Result result = this->data_storage->Read(entry.offset, dst, entry.size); R_FAILED(result)) { + if (Result result = m_data_storage->Read(entry.offset, dst, entry.size); R_FAILED(result)) { this->DestroyBuffer(std::addressof(entry), range); return this->UpdateLastResult(result); } @@ -349,7 +349,7 @@ namespace ams::fssystem::save { } /* Ensure that didn't end up in a failure state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); return ResultSuccess(); } @@ -357,26 +357,26 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::GetSize(s64 *out) { /* Validate pre-conditions. */ AMS_ASSERT(out != nullptr); - AMS_ASSERT(this->data_storage != nullptr); + AMS_ASSERT(m_data_storage != nullptr); /* Set the size. */ - *out = this->data_size; + *out = m_data_size; return ResultSuccess(); } Result BlockCacheBufferedStorage::Flush() { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Flush all cache entries. */ R_TRY(this->UpdateLastResult(this->FlushAllCacheEntries())); /* Flush the data storage. */ - R_TRY(this->UpdateLastResult(this->data_storage->Flush())); + R_TRY(this->UpdateLastResult(m_data_storage->Flush())); /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -388,7 +388,7 @@ namespace ams::fssystem::save { AMS_UNUSED(src, src_size); /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); + AMS_ASSERT(m_data_storage != nullptr); switch (op_id) { case fs::OperationId::FillZero: @@ -403,7 +403,7 @@ namespace ams::fssystem::save { } case fs::OperationId::Invalidate: { - R_UNLESS(this->storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInBlockCacheBufferedStorageB()); + R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInBlockCacheBufferedStorageB()); R_TRY(this->InvalidateCacheImpl(offset, size)); return ResultSuccess(); } @@ -419,11 +419,11 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::Commit() { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Flush all cache entries. */ R_TRY(this->UpdateLastResult(this->FlushAllCacheEntries())); @@ -433,38 +433,38 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::OnRollback() { /* Validate pre-conditions. */ - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Release all valid entries back to the buffer manager. */ const auto max_cache_entry_count = this->GetMaxCacheEntryCount(); for (s32 i = 0; i < max_cache_entry_count; i++) { - const auto &entry = this->entries[i]; + const auto &entry = m_entries[i]; if (entry.is_valid) { if (entry.is_write_back) { AMS_ASSERT(entry.memory_address != 0 && entry.handle == 0); - this->buffer_manager->DeallocateBuffer(entry.memory_address, entry.memory_size); + m_buffer_manager->DeallocateBuffer(entry.memory_address, entry.memory_size); } else { AMS_ASSERT(entry.memory_address == 0 && entry.handle != 0); - const auto memory_range = this->buffer_manager->AcquireCache(entry.handle); + const auto memory_range = m_buffer_manager->AcquireCache(entry.handle); if (memory_range.first != 0) { - this->buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); + m_buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); } } } } /* Clear all entries. */ - std::memset(this->entries.get(), 0, sizeof(CacheEntry) * max_cache_entry_count); + std::memset(m_entries.get(), 0, sizeof(CacheEntry) * max_cache_entry_count); return ResultSuccess(); } Result BlockCacheBufferedStorage::ClearImpl(s64 offset, s64 size) { /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Get our storage size. */ s64 storage_size = 0; @@ -474,8 +474,8 @@ namespace ams::fssystem::save { R_UNLESS(0 <= offset && offset < storage_size, fs::ResultInvalidOffset()); /* Determine the extents to data signature for. */ - auto start_offset = util::AlignDown(offset, this->verification_block_size); - auto end_offset = util::AlignUp(std::min(offset + size, storage_size), this->verification_block_size); + auto start_offset = util::AlignDown(offset, m_verification_block_size); + auto end_offset = util::AlignUp(std::min(offset + size, storage_size), m_verification_block_size); /* Flush the entries. */ R_TRY(this->UpdateLastResult(this->FlushRangeCacheEntries(offset, size, true))); @@ -483,26 +483,26 @@ namespace ams::fssystem::save { /* Handle any data before or after the aligned range. */ if (start_offset < offset || offset + size < end_offset) { /* Allocate a work buffer. */ - std::unique_ptr work = fs::impl::MakeUnique(this->verification_block_size); + std::unique_ptr work = fs::impl::MakeUnique(m_verification_block_size); R_UNLESS(work != nullptr, fs::ResultAllocationFailureInBlockCacheBufferedStorageB()); /* Handle data before the aligned range. */ if (start_offset < offset) { /* Read the block. */ - R_TRY(this->UpdateLastResult(this->data_storage->Read(start_offset, work.get(), this->verification_block_size))); + R_TRY(this->UpdateLastResult(m_data_storage->Read(start_offset, work.get(), m_verification_block_size))); /* Determine the partial extents to clear. */ const auto clear_offset = static_cast(offset - start_offset); - const auto clear_size = static_cast(std::min(static_cast(this->verification_block_size - clear_offset), size)); + const auto clear_size = static_cast(std::min(static_cast(m_verification_block_size - clear_offset), size)); /* Clear the partial block. */ std::memset(work.get() + clear_offset, 0, clear_size); /* Write the partially cleared block. */ - R_TRY(this->UpdateLastResult(this->data_storage->Write(start_offset, work.get(), this->verification_block_size))); + R_TRY(this->UpdateLastResult(m_data_storage->Write(start_offset, work.get(), m_verification_block_size))); /* Update the start offset. */ - start_offset += this->verification_block_size; + start_offset += m_verification_block_size; /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -511,18 +511,18 @@ namespace ams::fssystem::save { /* Handle data after the aligned range. */ if (start_offset < offset + size && offset + size < end_offset) { /* Read the block. */ - const auto last_offset = end_offset - this->verification_block_size; - R_TRY(this->UpdateLastResult(this->data_storage->Read(last_offset, work.get(), this->verification_block_size))); + const auto last_offset = end_offset - m_verification_block_size; + R_TRY(this->UpdateLastResult(m_data_storage->Read(last_offset, work.get(), m_verification_block_size))); /* Clear the partial block. */ const auto clear_size = static_cast((offset + size) - last_offset); std::memset(work.get(), 0, clear_size); /* Write the partially cleared block. */ - R_TRY(this->UpdateLastResult(this->data_storage->Write(last_offset, work.get(), this->verification_block_size))); + R_TRY(this->UpdateLastResult(m_data_storage->Write(last_offset, work.get(), m_verification_block_size))); /* Update the end offset. */ - end_offset -= this->verification_block_size; + end_offset -= m_verification_block_size; /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -533,7 +533,7 @@ namespace ams::fssystem::save { R_SUCCEED_IF(start_offset == end_offset); /* Clear the signature for the aligned range. */ - R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::FillZero, start_offset, end_offset - start_offset))); + R_TRY(this->UpdateLastResult(m_data_storage->OperateRange(fs::OperationId::FillZero, start_offset, end_offset - start_offset))); /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -543,7 +543,7 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::ClearSignatureImpl(s64 offset, s64 size) { /* Ensure we aren't already in a failed state. */ - R_TRY(this->last_result); + R_TRY(m_last_result); /* Get our storage size. */ s64 storage_size = 0; @@ -553,14 +553,14 @@ namespace ams::fssystem::save { R_UNLESS(0 <= offset && offset < storage_size, fs::ResultInvalidOffset()); /* Determine the extents to clear signature for. */ - const auto start_offset = util::AlignUp(offset, this->verification_block_size); - const auto end_offset = util::AlignDown(std::min(offset + size, storage_size), this->verification_block_size); + const auto start_offset = util::AlignUp(offset, m_verification_block_size); + const auto end_offset = util::AlignDown(std::min(offset + size, storage_size), m_verification_block_size); /* Flush the entries. */ R_TRY(this->UpdateLastResult(this->FlushRangeCacheEntries(offset, size, true))); /* Clear the signature for the aligned range. */ - R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(fs::OperationId::DestroySignature, start_offset, end_offset - start_offset))); + R_TRY(this->UpdateLastResult(m_data_storage->OperateRange(fs::OperationId::DestroySignature, start_offset, end_offset - start_offset))); /* Set blocking buffer manager allocations. */ buffers::EnableBlockingBufferManagerAllocation(); @@ -579,20 +579,20 @@ namespace ams::fssystem::save { /* Determine the extents we can actually query. */ const auto actual_size = std::min(size, storage_size - offset); - const auto aligned_offset = util::AlignDown(offset, this->verification_block_size); - const auto aligned_offset_end = util::AlignUp(offset + actual_size, this->verification_block_size); + const auto aligned_offset = util::AlignDown(offset, m_verification_block_size); + const auto aligned_offset_end = util::AlignUp(offset + actual_size, m_verification_block_size); const auto aligned_size = aligned_offset_end - aligned_offset; /* Invalidate the aligned range. */ { - Result result = this->data_storage->OperateRange(fs::OperationId::Invalidate, aligned_offset, aligned_size); + Result result = m_data_storage->OperateRange(fs::OperationId::Invalidate, aligned_offset, aligned_size); AMS_ASSERT(!fs::ResultBufferAllocationFailed::Includes(result)); R_TRY(result); } /* Clear our last result if we should. */ - if (fs::ResultIntegrityVerificationStorageCorrupted::Includes(this->last_result)) { - this->last_result = ResultSuccess(); + if (fs::ResultIntegrityVerificationStorageCorrupted::Includes(m_last_result)) { + m_last_result = ResultSuccess(); } return ResultSuccess(); @@ -605,12 +605,12 @@ namespace ams::fssystem::save { /* Determine the extents we can actually query. */ const auto actual_size = std::min(size, storage_size - offset); - const auto aligned_offset = util::AlignDown(offset, this->verification_block_size); - const auto aligned_offset_end = util::AlignUp(offset + actual_size, this->verification_block_size); + const auto aligned_offset = util::AlignDown(offset, m_verification_block_size); + const auto aligned_offset_end = util::AlignUp(offset + actual_size, m_verification_block_size); const auto aligned_size = aligned_offset_end - aligned_offset; /* Query the aligned range. */ - R_TRY(this->UpdateLastResult(this->data_storage->OperateRange(dst, dst_size, fs::OperationId::QueryRange, aligned_offset, aligned_size, nullptr, 0))); + R_TRY(this->UpdateLastResult(m_data_storage->OperateRange(dst, dst_size, fs::OperationId::QueryRange, aligned_offset, aligned_size, nullptr, 0))); return ResultSuccess(); } @@ -621,12 +621,12 @@ namespace ams::fssystem::save { const size_t size = entry.size; /* Lock our mutex. */ - std::scoped_lock lk(*this->mutex); + std::scoped_lock lk(*m_mutex); /* Iterate over all entries, checking if any overlap our extents. */ const auto max_cache_entry_count = this->GetMaxCacheEntryCount(); for (auto i = 0; i < max_cache_entry_count; ++i) { - const auto &entry = this->entries[i]; + const auto &entry = m_entries[i]; if (entry.is_valid && (entry.is_write_back ? entry.memory_address != 0 : entry.handle != 0)) { if (entry.offset < static_cast(offset + size) && offset < static_cast(entry.offset + entry.size)) { return true; @@ -641,13 +641,13 @@ namespace ams::fssystem::save { AMS_UNUSED(is_allocate_for_write); /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); AMS_ASSERT(out_range != nullptr); AMS_ASSERT(out_entry != nullptr); /* Lock our mutex. */ - std::scoped_lock lk(*this->mutex); + std::scoped_lock lk(*m_mutex); /* Get the maximum cache entry count. */ const CacheIndex max_cache_entry_count = static_cast(this->GetMaxCacheEntryCount()); @@ -656,7 +656,7 @@ namespace ams::fssystem::save { CacheIndex index; size_t actual_size = ideal_size; for (index = 0; index < max_cache_entry_count; ++index) { - const auto &entry = this->entries[index]; + const auto &entry = m_entries[index]; if (entry.is_valid && (entry.is_write_back ? entry.memory_address != 0 : entry.handle != 0)) { const s64 entry_offset = entry.offset; if (entry_offset <= offset && offset < static_cast(entry_offset + entry.size)) { @@ -675,13 +675,13 @@ namespace ams::fssystem::save { /* If we located an entry, use it. */ if (index != max_cache_entry_count) { - auto &entry = this->entries[index]; + auto &entry = m_entries[index]; /* Get the range of the found entry. */ if (entry.is_write_back) { *out_range = std::make_pair(entry.memory_address, entry.memory_size); } else { - *out_range = this->buffer_manager->AcquireCache(entry.handle); + *out_range = m_buffer_manager->AcquireCache(entry.handle); } /* Get the found entry. */ @@ -705,13 +705,13 @@ namespace ams::fssystem::save { /* If we don't have an out entry, allocate one. */ if (out_range->first == 0) { /* Ensure that the allocatable size is above a threshold. */ - const auto size_threshold = this->buffer_manager->GetTotalSize() / 8; - if (this->buffer_manager->GetTotalAllocatableSize() < size_threshold) { + const auto size_threshold = m_buffer_manager->GetTotalSize() / 8; + if (m_buffer_manager->GetTotalAllocatableSize() < size_threshold) { R_TRY(this->FlushAllCacheEntries()); } /* Decide in advance on a block alignment. */ - const size_t block_alignment = this->verification_block_size; + const size_t block_alignment = m_verification_block_size; /* Ensure that the size we request is valid. */ { @@ -721,7 +721,7 @@ namespace ams::fssystem::save { AMS_ASSERT(actual_size >= block_alignment); /* Allocate a buffer. */ - R_TRY(buffers::AllocateBufferUsingBufferManagerContext(out_range, this->buffer_manager, actual_size, IBufferManager::BufferAttribute(this->buffer_level), [=](const MemoryRange &buffer) { + R_TRY(buffers::AllocateBufferUsingBufferManagerContext(out_range, m_buffer_manager, actual_size, IBufferManager::BufferAttribute(m_buffer_level), [=](const MemoryRange &buffer) { return buffer.first != 0 && block_alignment <= buffer.second; }, AMS_CURRENT_FUNCTION_NAME)); @@ -748,7 +748,7 @@ namespace ams::fssystem::save { void BlockCacheBufferedStorage::DestroyBuffer(CacheEntry *entry, const MemoryRange &range) { /* Validate pre-conditions. */ - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); AMS_ASSERT(entry != nullptr); /* Set the entry as invalid and not cached. */ @@ -756,7 +756,7 @@ namespace ams::fssystem::save { entry->is_valid = false; /* Release the entry. */ - this->buffer_manager->DeallocateBuffer(range.first, range.second); + m_buffer_manager->DeallocateBuffer(range.first, range.second); } Result BlockCacheBufferedStorage::StoreAssociateBuffer(CacheIndex *out, const MemoryRange &range, const CacheEntry &entry) { @@ -764,7 +764,7 @@ namespace ams::fssystem::save { AMS_ASSERT(out != nullptr); /* Lock our mutex. */ - std::scoped_lock lk(*this->mutex); + std::scoped_lock lk(*m_mutex); /* If the entry is write-back, ensure we don't exceed certain dirtiness thresholds. */ if (entry.is_write_back) { @@ -778,7 +778,7 @@ namespace ams::fssystem::save { /* Locate the index of an unused cache entry. */ CacheIndex index; for (index = 0; index < max_cache_entry_count; ++index) { - if (!this->entries[index].is_valid) { + if (!m_entries[index].is_valid) { break; } } @@ -786,10 +786,10 @@ namespace ams::fssystem::save { /* If all entries are valid, we need to invalidate one. */ if (index == max_cache_entry_count) { /* Increment the index to invalidate. */ - this->invalidate_index = (this->invalidate_index + 1) % max_cache_entry_count; + m_invalidate_index = (m_invalidate_index + 1) % max_cache_entry_count; /* Get the entry to invalidate. */ - const CacheEntry *entry_to_invalidate = std::addressof(this->entries[this->invalidate_index]); + const CacheEntry *entry_to_invalidate = std::addressof(m_entries[m_invalidate_index]); AMS_UNUSED(entry_to_invalidate); /* Ensure that the entry can be invalidated. */ @@ -797,17 +797,17 @@ namespace ams::fssystem::save { AMS_ASSERT(!entry_to_invalidate->is_flushing); /* Invalidate the entry. */ - R_TRY(this->FlushCacheEntry(this->invalidate_index, true)); + R_TRY(this->FlushCacheEntry(m_invalidate_index, true)); /* Check that the entry was invalidated successfully. */ AMS_ASSERT(!entry_to_invalidate->is_valid); AMS_ASSERT(!entry_to_invalidate->is_flushing); - index = this->invalidate_index; + index = m_invalidate_index; } /* Store the entry. */ - CacheEntry *entry_ptr = std::addressof(this->entries[index]); + CacheEntry *entry_ptr = std::addressof(m_entries[index]); *entry_ptr = entry; /* Assert that the entry is valid to store. */ @@ -824,7 +824,7 @@ namespace ams::fssystem::save { entry_ptr->memory_address = range.first; entry_ptr->memory_size = range.second; } else { - entry_ptr->handle = this->buffer_manager->RegisterCache(range.first, range.second, IBufferManager::BufferAttribute(this->buffer_level)); + entry_ptr->handle = m_buffer_manager->RegisterCache(range.first, range.second, IBufferManager::BufferAttribute(m_buffer_level)); entry_ptr->memory_address = 0; entry_ptr->memory_size = 0; } @@ -832,10 +832,10 @@ namespace ams::fssystem::save { /* Set the out index. */ AMS_ASSERT(entry_ptr->is_valid); *out = index; - this->invalidate_index = index; + m_invalidate_index = index; } else { /* If a redundant entry exists, we don't need the newly stored entry. */ - this->buffer_manager->DeallocateBuffer(range.first, range.second); + m_buffer_manager->DeallocateBuffer(range.first, range.second); entry_ptr->is_valid = false; *out = -1; } @@ -845,10 +845,10 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::FlushCacheEntry(CacheIndex index, bool invalidate) { /* Lock our mutex. */ - std::scoped_lock lk(*this->mutex); + std::scoped_lock lk(*m_mutex); /* Get the entry. */ - CacheEntry *entry = std::addressof(this->entries[index]); + CacheEntry *entry = std::addressof(m_entries[index]); MemoryRange memory_range; /* Check that the entry's state allows for flush. */ @@ -860,9 +860,9 @@ namespace ams::fssystem::save { AMS_ASSERT(invalidate); /* Get and release the buffer. */ - memory_range = this->buffer_manager->AcquireCache(entry->handle); + memory_range = m_buffer_manager->AcquireCache(entry->handle); if (memory_range.first != 0) { - this->buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); + m_buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); } /* The entry is no longer valid. */ @@ -881,20 +881,20 @@ namespace ams::fssystem::save { /* Validate the entry's offset. */ AMS_ASSERT(entry->offset >= 0); - AMS_ASSERT(entry->offset < this->data_size); - AMS_ASSERT(util::IsAligned(entry->offset, this->verification_block_size)); + AMS_ASSERT(entry->offset < m_data_size); + AMS_ASSERT(util::IsAligned(entry->offset, m_verification_block_size)); /* Write back the data. */ Result result = ResultSuccess(); size_t write_size = entry->size; - if (R_SUCCEEDED(this->last_result)) { + if (R_SUCCEEDED(m_last_result)) { /* Set blocking buffer manager allocations. */ - result = this->data_storage->Write(entry->offset, reinterpret_cast(memory_range.first), write_size); + result = m_data_storage->Write(entry->offset, reinterpret_cast(memory_range.first), write_size); /* Check the result. */ AMS_ASSERT(!fs::ResultBufferAllocationFailed::Includes(result)); } else { - result = this->last_result; + result = m_last_result; } /* Set that we're not write-back. */ @@ -902,13 +902,13 @@ namespace ams::fssystem::save { /* If we're invalidating, release the buffer. Otherwise, register the flushed data. */ if (invalidate) { - this->buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); + m_buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); entry->is_valid = false; entry->is_flushing = false; } else { AMS_ASSERT(entry->is_valid); - entry->handle = this->buffer_manager->RegisterCache(memory_range.first, memory_range.second, IBufferManager::BufferAttribute(this->buffer_level)); + entry->handle = m_buffer_manager->RegisterCache(memory_range.first, memory_range.second, IBufferManager::BufferAttribute(m_buffer_level)); entry->memory_address = 0; entry->memory_size = 0; @@ -924,14 +924,14 @@ namespace ams::fssystem::save { Result BlockCacheBufferedStorage::FlushRangeCacheEntries(s64 offset, s64 size, bool invalidate) { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Iterate over all entries that fall within the range. */ Result result = ResultSuccess(); const auto max_cache_entry_count = this->GetMaxCacheEntryCount(); for (auto i = 0; i < max_cache_entry_count; ++i) { - auto &entry = this->entries[i]; + auto &entry = m_entries[i]; if (entry.is_valid && (entry.is_write_back || invalidate) && (entry.offset < (offset + size)) && (offset < static_cast(entry.offset + entry.size))) { const auto cur_result = this->FlushCacheEntry(i, invalidate); if (R_FAILED(cur_result) && R_SUCCEEDED(result)) { @@ -949,22 +949,22 @@ namespace ams::fssystem::save { void BlockCacheBufferedStorage::InvalidateRangeCacheEntries(s64 offset, s64 size) { /* Validate pre-conditions. */ - AMS_ASSERT(this->data_storage != nullptr); - AMS_ASSERT(this->buffer_manager != nullptr); + AMS_ASSERT(m_data_storage != nullptr); + AMS_ASSERT(m_buffer_manager != nullptr); /* Iterate over all entries that fall within the range. */ const auto max_cache_entry_count = this->GetMaxCacheEntryCount(); for (auto i = 0; i < max_cache_entry_count; ++i) { - auto &entry = this->entries[i]; + auto &entry = m_entries[i]; if (entry.is_valid && (entry.offset < (offset + size)) && (offset < static_cast(entry.offset + entry.size))) { if (entry.is_write_back) { AMS_ASSERT(entry.memory_address != 0 && entry.handle == 0); - this->buffer_manager->DeallocateBuffer(entry.memory_address, entry.memory_size); + m_buffer_manager->DeallocateBuffer(entry.memory_address, entry.memory_size); } else { AMS_ASSERT(entry.memory_address == 0 && entry.handle != 0); - const auto memory_range = this->buffer_manager->AcquireCache(entry.handle); + const auto memory_range = m_buffer_manager->AcquireCache(entry.handle); if (memory_range.first != 0) { - this->buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); + m_buffer_manager->DeallocateBuffer(memory_range.first, memory_range.second); } } @@ -992,8 +992,8 @@ namespace ams::fssystem::save { AMS_ASSERT(max_cache_entry_count > 0); /* Get size metrics from the buffer manager. */ - const auto total_size = this->buffer_manager->GetTotalSize(); - const auto allocatable_size = this->buffer_manager->GetTotalAllocatableSize(); + const auto total_size = m_buffer_manager->GetTotalSize(); + const auto allocatable_size = m_buffer_manager->GetTotalAllocatableSize(); /* If we have enough allocatable space, we don't need to do anything. */ R_SUCCEED_IF(allocatable_size >= total_size / 4); @@ -1001,12 +1001,12 @@ namespace ams::fssystem::save { /* Setup for flushing dirty entries. */ auto threshold = 2; auto dirty_count = 0; - auto flushed_index = this->invalidate_index; + auto flushed_index = m_invalidate_index; /* Iterate over all entries (starting with the invalidate index), and flush dirty entries once threshold is met. */ for (auto i = 0; i < max_cache_entry_count; ++i) { - auto index = (this->invalidate_index + 1 + i) % max_cache_entry_count; - if (this->entries[index].is_valid && this->entries[index].is_write_back) { + auto index = (m_invalidate_index + 1 + i) % max_cache_entry_count; + if (m_entries[index].is_valid && m_entries[index].is_write_back) { ++dirty_count; if (threshold <= dirty_count) { R_TRY(this->FlushCacheEntry(index, false)); @@ -1016,15 +1016,15 @@ namespace ams::fssystem::save { } /* Update the invalidate index. */ - this->invalidate_index = flushed_index; + m_invalidate_index = flushed_index; return ResultSuccess(); } Result BlockCacheBufferedStorage::UpdateLastResult(Result result) { /* Update the last result. */ - if (R_FAILED(result) && !fs::ResultBufferAllocationFailed::Includes(result) && R_SUCCEEDED(this->last_result)) { - this->last_result = result; + if (R_FAILED(result) && !fs::ResultBufferAllocationFailed::Includes(result) && R_SUCCEEDED(m_last_result)) { + m_last_result = result; } /* Try to succeed with the result. */ @@ -1054,7 +1054,7 @@ namespace ams::fssystem::save { while (*aligned_offset < aligned_offset_end) { /* Get the associated buffer for the offset. */ - R_TRY(this->UpdateLastResult(this->GetAssociateBuffer(std::addressof(memory_range), std::addressof(entry), *aligned_offset, this->verification_block_size, true))); + R_TRY(this->UpdateLastResult(this->GetAssociateBuffer(std::addressof(memory_range), std::addressof(entry), *aligned_offset, m_verification_block_size, true))); /* If the entry isn't cached, we're done. */ if (!entry.is_cached) { @@ -1106,7 +1106,7 @@ namespace ams::fssystem::save { while (aligned_offset < *aligned_offset_end) { /* Get the associated buffer for the offset. */ - R_TRY(this->UpdateLastResult(this->GetAssociateBuffer(std::addressof(memory_range), std::addressof(entry), *aligned_offset_end - this->verification_block_size, this->verification_block_size, true))); + R_TRY(this->UpdateLastResult(this->GetAssociateBuffer(std::addressof(memory_range), std::addressof(entry), *aligned_offset_end - m_verification_block_size, m_verification_block_size, true))); /* If the entry isn't cached, we're done. */ if (!entry.is_cached) { @@ -1149,8 +1149,8 @@ namespace ams::fssystem::save { /* Determine bulk read offsets. */ const s64 read_offset = offset; const size_t read_size = size; - const s64 aligned_offset = util::AlignDown(read_offset, this->verification_block_size); - const s64 aligned_offset_end = util::AlignUp(read_offset + read_size, this->verification_block_size); + const s64 aligned_offset = util::AlignDown(read_offset, m_verification_block_size); + const s64 aligned_offset_end = util::AlignUp(read_offset + read_size, m_verification_block_size); char *dst = static_cast(buffer); /* Prepare to do our reads. */ @@ -1177,7 +1177,7 @@ namespace ams::fssystem::save { } /* Read the data. */ - R_TRY(this->data_storage->Read(aligned_offset, read_buffer, buffer_size)); + R_TRY(m_data_storage->Read(aligned_offset, read_buffer, buffer_size)); /* Copy the data out. */ if (dst != read_buffer) { diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp index 3c66f7ef9..abea74829 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp @@ -33,18 +33,18 @@ namespace ams::fssystem::save { }; static_assert(util::is_pod::value); private: - BufferedStorage *buffered_storage; - std::pair memory_range; - IBufferManager::CacheHandle cache_handle; - s64 offset; - std::atomic is_valid; - std::atomic is_dirty; - u8 reserved[2]; - s32 reference_count; - Cache *next; - Cache *prev; + BufferedStorage *m_buffered_storage; + std::pair m_memory_range; + IBufferManager::CacheHandle m_cache_handle; + s64 m_offset; + std::atomic m_is_valid; + std::atomic m_is_dirty; + u8 m_reserved[2]; + s32 m_reference_count; + Cache *m_next; + Cache *m_prev; public: - Cache() : buffered_storage(nullptr), memory_range(InvalidAddress, 0), cache_handle(), offset(InvalidOffset), is_valid(false), is_dirty(false), reference_count(1), next(nullptr), prev(nullptr) { + Cache() : m_buffered_storage(nullptr), m_memory_range(InvalidAddress, 0), m_cache_handle(), m_offset(InvalidOffset), m_is_valid(false), m_is_dirty(false), m_reference_count(1), m_next(nullptr), m_prev(nullptr) { /* ... */ } @@ -54,142 +54,142 @@ namespace ams::fssystem::save { void Initialize(BufferedStorage *bs) { AMS_ASSERT(bs != nullptr); - AMS_ASSERT(this->buffered_storage == nullptr); + AMS_ASSERT(m_buffered_storage == nullptr); - this->buffered_storage = bs; + m_buffered_storage = bs; this->Link(); } void Finalize() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->reference_count == 0); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_reference_count == 0); /* If we're valid, acquire our cache handle and free our buffer. */ if (this->IsValid()) { - const auto buffer_manager = this->buffered_storage->buffer_manager; - if (!this->is_dirty) { - AMS_ASSERT(this->memory_range.first == InvalidAddress); - this->memory_range = buffer_manager->AcquireCache(this->cache_handle); + const auto buffer_manager = m_buffered_storage->m_buffer_manager; + if (!m_is_dirty) { + AMS_ASSERT(m_memory_range.first == InvalidAddress); + m_memory_range = buffer_manager->AcquireCache(m_cache_handle); } - if (this->memory_range.first != InvalidAddress) { - buffer_manager->DeallocateBuffer(this->memory_range.first, this->memory_range.second); - this->memory_range.first = InvalidAddress; - this->memory_range.second = 0; + if (m_memory_range.first != InvalidAddress) { + buffer_manager->DeallocateBuffer(m_memory_range.first, m_memory_range.second); + m_memory_range.first = InvalidAddress; + m_memory_range.second = 0; } } /* Clear all our members. */ - this->buffered_storage = nullptr; - this->offset = InvalidOffset; - this->is_valid = false; - this->is_dirty = false; - this->next = nullptr; - this->prev = nullptr; + m_buffered_storage = nullptr; + m_offset = InvalidOffset; + m_is_valid = false; + m_is_dirty = false; + m_next = nullptr; + m_prev = nullptr; } void Link() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->reference_count > 0); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_reference_count > 0); - if ((--this->reference_count) == 0) { - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + if ((--m_reference_count) == 0) { + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); - if (this->buffered_storage->next_fetch_cache == nullptr) { - this->buffered_storage->next_fetch_cache = this; - this->next = this; - this->prev = this; + if (m_buffered_storage->m_next_fetch_cache == nullptr) { + m_buffered_storage->m_next_fetch_cache = this; + m_next = this; + m_prev = this; } else { /* Check against a cache being registered twice. */ { - auto cache = this->buffered_storage->next_fetch_cache; + auto cache = m_buffered_storage->m_next_fetch_cache; do { - if (cache->IsValid() && this->Hits(cache->offset, this->buffered_storage->block_size)) { - this->is_valid = false; + if (cache->IsValid() && this->Hits(cache->m_offset, m_buffered_storage->m_block_size)) { + m_is_valid = false; break; } - cache = cache->next; - } while (cache != this->buffered_storage->next_fetch_cache); + cache = cache->m_next; + } while (cache != m_buffered_storage->m_next_fetch_cache); } /* Link into the fetch list. */ { - AMS_ASSERT(this->buffered_storage->next_fetch_cache->prev != nullptr); - AMS_ASSERT(this->buffered_storage->next_fetch_cache->prev->next == this->buffered_storage->next_fetch_cache); - this->next = this->buffered_storage->next_fetch_cache; - this->prev = this->buffered_storage->next_fetch_cache->prev; - this->next->prev = this; - this->prev->next = this; + AMS_ASSERT(m_buffered_storage->m_next_fetch_cache->m_prev != nullptr); + AMS_ASSERT(m_buffered_storage->m_next_fetch_cache->m_prev->m_next == m_buffered_storage->m_next_fetch_cache); + m_next = m_buffered_storage->m_next_fetch_cache; + m_prev = m_buffered_storage->m_next_fetch_cache->m_prev; + m_next->m_prev = this; + m_prev->m_next = this; } /* Insert invalid caches at the start of the list. */ if (!this->IsValid()) { - this->buffered_storage->next_fetch_cache = this; + m_buffered_storage->m_next_fetch_cache = this; } } /* If we're not valid, clear our offset. */ if (!this->IsValid()) { - this->offset = InvalidOffset; - this->is_dirty = false; + m_offset = InvalidOffset; + m_is_dirty = false; } /* Ensure our buffer state is coherent. */ - if (this->memory_range.first != InvalidAddress && !this->is_dirty) { + if (m_memory_range.first != InvalidAddress && !m_is_dirty) { if (this->IsValid()) { - this->cache_handle = this->buffered_storage->buffer_manager->RegisterCache(this->memory_range.first, this->memory_range.second, IBufferManager::BufferAttribute()); + m_cache_handle = m_buffered_storage->m_buffer_manager->RegisterCache(m_memory_range.first, m_memory_range.second, IBufferManager::BufferAttribute()); } else { - this->buffered_storage->buffer_manager->DeallocateBuffer(this->memory_range.first, this->memory_range.second); + m_buffered_storage->m_buffer_manager->DeallocateBuffer(m_memory_range.first, m_memory_range.second); } - this->memory_range.first = InvalidAddress; - this->memory_range.second = 0; + m_memory_range.first = InvalidAddress; + m_memory_range.second = 0; } } } void Unlink() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->reference_count >= 0); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_reference_count >= 0); - if ((++this->reference_count) == 1) { - AMS_ASSERT(this->next != nullptr); - AMS_ASSERT(this->prev != nullptr); - AMS_ASSERT(this->next->prev == this); - AMS_ASSERT(this->prev->next == this); + if ((++m_reference_count) == 1) { + AMS_ASSERT(m_next != nullptr); + AMS_ASSERT(m_prev != nullptr); + AMS_ASSERT(m_next->m_prev == this); + AMS_ASSERT(m_prev->m_next == this); - if (this->buffered_storage->next_fetch_cache == this) { - if (this->next != this) { - this->buffered_storage->next_fetch_cache = this->next; + if (m_buffered_storage->m_next_fetch_cache == this) { + if (m_next != this) { + m_buffered_storage->m_next_fetch_cache = m_next; } else { - this->buffered_storage->next_fetch_cache = nullptr; + m_buffered_storage->m_next_fetch_cache = nullptr; } } - this->buffered_storage->next_acquire_cache = this; + m_buffered_storage->m_next_acquire_cache = this; - this->next->prev = this->prev; - this->prev->next = this->next; - this->next = nullptr; - this->prev = nullptr; + m_next->m_prev = m_prev; + m_prev->m_next = m_next; + m_next = nullptr; + m_prev = nullptr; } else { - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); } } void Read(s64 offset, void *buffer, size_t size) const { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(this->IsValid()); AMS_ASSERT(this->Hits(offset, 1)); - AMS_ASSERT(this->memory_range.first != InvalidAddress); + AMS_ASSERT(m_memory_range.first != InvalidAddress); - const auto read_offset = offset - this->offset; - const auto readable_offset_max = this->buffered_storage->block_size - size; - const auto cache_buffer = reinterpret_cast(this->memory_range.first) + read_offset; + const auto read_offset = offset - m_offset; + const auto readable_offset_max = m_buffered_storage->m_block_size - size; + const auto cache_buffer = reinterpret_cast(m_memory_range.first) + read_offset; AMS_ASSERT(read_offset >= 0); AMS_ASSERT(static_cast(read_offset) <= readable_offset_max); AMS_UNUSED(readable_offset_max); @@ -198,42 +198,42 @@ namespace ams::fssystem::save { } void Write(s64 offset, const void *buffer, size_t size) { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(this->IsValid()); AMS_ASSERT(this->Hits(offset, 1)); - AMS_ASSERT(this->memory_range.first != InvalidAddress); + AMS_ASSERT(m_memory_range.first != InvalidAddress); - const auto write_offset = offset - this->offset; - const auto writable_offset_max = this->buffered_storage->block_size - size; - const auto cache_buffer = reinterpret_cast(this->memory_range.first) + write_offset; + const auto write_offset = offset - m_offset; + const auto writable_offset_max = m_buffered_storage->m_block_size - size; + const auto cache_buffer = reinterpret_cast(m_memory_range.first) + write_offset; AMS_ASSERT(write_offset >= 0); AMS_ASSERT(static_cast(write_offset) <= writable_offset_max); AMS_UNUSED(writable_offset_max); std::memcpy(cache_buffer, buffer, size); - this->is_dirty = true; + m_is_dirty = true; } Result Flush() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(this->IsValid()); - if (this->is_dirty) { - AMS_ASSERT(this->memory_range.first != InvalidAddress); + if (m_is_dirty) { + AMS_ASSERT(m_memory_range.first != InvalidAddress); - const auto base_size = this->buffered_storage->base_storage_size; - const auto block_size = static_cast(this->buffered_storage->block_size); - const auto flush_size = static_cast(std::min(block_size, base_size - this->offset)); + const auto base_size = m_buffered_storage->m_base_storage_size; + const auto block_size = static_cast(m_buffered_storage->m_block_size); + const auto flush_size = static_cast(std::min(block_size, base_size - m_offset)); - auto &base_storage = this->buffered_storage->base_storage; - const auto cache_buffer = reinterpret_cast(this->memory_range.first); + auto &base_storage = m_buffered_storage->m_base_storage; + const auto cache_buffer = reinterpret_cast(m_memory_range.first); - R_TRY(base_storage.Write(this->offset, cache_buffer, flush_size)); - this->is_dirty = false; + R_TRY(base_storage.Write(m_offset, cache_buffer, flush_size)); + m_is_dirty = false; buffers::EnableBlockingBufferManagerAllocation(); } @@ -242,19 +242,19 @@ namespace ams::fssystem::save { } const std::pair PrepareFetch() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(this->IsValid()); - AMS_ASSERT(this->buffered_storage->mutex.IsLockedByCurrentThread()); + AMS_ASSERT(m_buffered_storage->m_mutex.IsLockedByCurrentThread()); std::pair result(ResultSuccess(), false); - if (this->reference_count == 1) { + if (m_reference_count == 1) { result.first = this->Flush(); if (R_SUCCEEDED(result.first)) { - this->is_valid = false; - this->reference_count = 0; + m_is_valid = false; + m_reference_count = 0; result.second = true; } } @@ -263,51 +263,51 @@ namespace ams::fssystem::save { } void UnprepareFetch() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(!this->IsValid()); - AMS_ASSERT(!this->is_dirty); - AMS_ASSERT(this->buffered_storage->mutex.IsLockedByCurrentThread()); + AMS_ASSERT(!m_is_dirty); + AMS_ASSERT(m_buffered_storage->m_mutex.IsLockedByCurrentThread()); - this->is_valid = true; - this->reference_count = 1; + m_is_valid = true; + m_reference_count = 1; } Result Fetch(s64 offset) { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(!this->IsValid()); - AMS_ASSERT(!this->is_dirty); + AMS_ASSERT(!m_is_dirty); - if (this->memory_range.first == InvalidAddress) { + if (m_memory_range.first == InvalidAddress) { R_TRY(this->AllocateFetchBuffer()); } FetchParameter fetch_param = {}; this->CalcFetchParameter(std::addressof(fetch_param), offset); - auto &base_storage = this->buffered_storage->base_storage; + auto &base_storage = m_buffered_storage->m_base_storage; R_TRY(base_storage.Read(fetch_param.offset, fetch_param.buffer, fetch_param.size)); - this->offset = fetch_param.offset; + m_offset = fetch_param.offset; AMS_ASSERT(this->Hits(offset, 1)); return ResultSuccess(); } Result FetchFromBuffer(s64 offset, const void *buffer, size_t buffer_size) { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); - AMS_ASSERT(this->next == nullptr); - AMS_ASSERT(this->prev == nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); + AMS_ASSERT(m_next == nullptr); + AMS_ASSERT(m_prev == nullptr); AMS_ASSERT(!this->IsValid()); - AMS_ASSERT(!this->is_dirty); - AMS_ASSERT(util::IsAligned(offset, this->buffered_storage->block_size)); + AMS_ASSERT(!m_is_dirty); + AMS_ASSERT(util::IsAligned(offset, m_buffered_storage->m_block_size)); - if (this->memory_range.first == InvalidAddress) { + if (m_memory_range.first == InvalidAddress) { R_TRY(this->AllocateFetchBuffer()); } @@ -318,53 +318,53 @@ namespace ams::fssystem::save { AMS_UNUSED(buffer_size); std::memcpy(fetch_param.buffer, buffer, fetch_param.size); - this->offset = fetch_param.offset; + m_offset = fetch_param.offset; AMS_ASSERT(this->Hits(offset, 1)); return ResultSuccess(); } bool TryAcquireCache() { - AMS_ASSERT(this->buffered_storage != nullptr); - AMS_ASSERT(this->buffered_storage->buffer_manager != nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage->m_buffer_manager != nullptr); AMS_ASSERT(this->IsValid()); - if (this->memory_range.first != InvalidAddress) { + if (m_memory_range.first != InvalidAddress) { return true; } else { - this->memory_range = this->buffered_storage->buffer_manager->AcquireCache(this->cache_handle); - this->is_valid = this->memory_range.first != InvalidAddress; - return this->is_valid; + m_memory_range = m_buffered_storage->m_buffer_manager->AcquireCache(m_cache_handle); + m_is_valid = m_memory_range.first != InvalidAddress; + return m_is_valid; } } void Invalidate() { - AMS_ASSERT(this->buffered_storage != nullptr); - this->is_valid = false; + AMS_ASSERT(m_buffered_storage != nullptr); + m_is_valid = false; } bool IsValid() const { - AMS_ASSERT(this->buffered_storage != nullptr); - return this->is_valid || this->reference_count > 0; + AMS_ASSERT(m_buffered_storage != nullptr); + return m_is_valid || m_reference_count > 0; } bool IsDirty() const { - AMS_ASSERT(this->buffered_storage != nullptr); - return this->is_dirty; + AMS_ASSERT(m_buffered_storage != nullptr); + return m_is_dirty; } bool Hits(s64 offset, s64 size) const { - AMS_ASSERT(this->buffered_storage != nullptr); - const auto block_size = static_cast(this->buffered_storage->block_size); - return (offset < this->offset + block_size) && (this->offset < offset + size); + AMS_ASSERT(m_buffered_storage != nullptr); + const auto block_size = static_cast(m_buffered_storage->m_block_size); + return (offset < m_offset + block_size) && (m_offset < offset + size); } private: Result AllocateFetchBuffer() { - IBufferManager *buffer_manager = this->buffered_storage->buffer_manager; - AMS_ASSERT(buffer_manager->AcquireCache(this->cache_handle).first == InvalidAddress); + IBufferManager *buffer_manager = m_buffered_storage->m_buffer_manager; + AMS_ASSERT(buffer_manager->AcquireCache(m_cache_handle).first == InvalidAddress); - auto range_guard = SCOPE_GUARD { this->memory_range.first = InvalidAddress; }; - R_TRY(buffers::AllocateBufferUsingBufferManagerContext(std::addressof(this->memory_range), buffer_manager, this->buffered_storage->block_size, IBufferManager::BufferAttribute(), [](const std::pair &buffer) { + auto range_guard = SCOPE_GUARD { m_memory_range.first = InvalidAddress; }; + R_TRY(buffers::AllocateBufferUsingBufferManagerContext(std::addressof(m_memory_range), buffer_manager, m_buffered_storage->m_block_size, IBufferManager::BufferAttribute(), [](const std::pair &buffer) { return buffer.first != 0; }, AMS_CURRENT_FUNCTION_NAME)); @@ -375,11 +375,11 @@ namespace ams::fssystem::save { void CalcFetchParameter(FetchParameter *out, s64 offset) const { AMS_ASSERT(out != nullptr); - const auto block_size = static_cast(this->buffered_storage->block_size); - const auto cache_offset = util::AlignDown(offset, this->buffered_storage->block_size); - const auto base_size = this->buffered_storage->base_storage_size; + const auto block_size = static_cast(m_buffered_storage->m_block_size); + const auto cache_offset = util::AlignDown(offset, m_buffered_storage->m_block_size); + const auto base_size = m_buffered_storage->m_base_storage_size; const auto cache_size = static_cast(std::min(block_size, base_size - cache_offset)); - const auto cache_buffer = reinterpret_cast(this->memory_range.first); + const auto cache_buffer = reinterpret_cast(m_memory_range.first); AMS_ASSERT(offset >= 0); AMS_ASSERT(offset < base_size); @@ -394,149 +394,149 @@ namespace ams::fssystem::save { NON_MOVEABLE(SharedCache); friend class UniqueCache; private: - Cache *cache; - Cache *start_cache; - BufferedStorage *buffered_storage; + Cache *m_cache; + Cache *m_start_cache; + BufferedStorage *m_buffered_storage; public: - explicit SharedCache(BufferedStorage *bs) : cache(nullptr), start_cache(bs->next_acquire_cache), buffered_storage(bs) { - AMS_ASSERT(this->buffered_storage != nullptr); + explicit SharedCache(BufferedStorage *bs) : m_cache(nullptr), m_start_cache(bs->m_next_acquire_cache), m_buffered_storage(bs) { + AMS_ASSERT(m_buffered_storage != nullptr); } ~SharedCache() { - std::scoped_lock lk(buffered_storage->mutex); + std::scoped_lock lk(m_buffered_storage->m_mutex); this->Release(); } bool AcquireNextOverlappedCache(s64 offset, s64 size) { - AMS_ASSERT(this->buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); - auto is_first = this->cache == nullptr; - const auto start = is_first ? this->start_cache : this->cache + 1; + auto is_first = m_cache == nullptr; + const auto start = is_first ? m_start_cache : m_cache + 1; - AMS_ASSERT(start >= this->buffered_storage->caches.get()); - AMS_ASSERT(start <= this->buffered_storage->caches.get() + this->buffered_storage->cache_count); + AMS_ASSERT(start >= m_buffered_storage->m_caches.get()); + AMS_ASSERT(start <= m_buffered_storage->m_caches.get() + m_buffered_storage->m_cache_count); - std::scoped_lock lk(this->buffered_storage->mutex); + std::scoped_lock lk(m_buffered_storage->m_mutex); this->Release(); - AMS_ASSERT(this->cache == nullptr); + AMS_ASSERT(m_cache == nullptr); for (auto cache = start; true; ++cache) { - if (this->buffered_storage->caches.get() + this->buffered_storage->cache_count <= cache) { - cache = this->buffered_storage->caches.get(); + if (m_buffered_storage->m_caches.get() + m_buffered_storage->m_cache_count <= cache) { + cache = m_buffered_storage->m_caches.get(); } - if (!is_first && cache == this->start_cache) { + if (!is_first && cache == m_start_cache) { break; } if (cache->IsValid() && cache->Hits(offset, size) && cache->TryAcquireCache()) { cache->Unlink(); - this->cache = cache; + m_cache = cache; return true; } is_first = false; } - this->cache = nullptr; + m_cache = nullptr; return false; } bool AcquireNextDirtyCache() { - AMS_ASSERT(this->buffered_storage != nullptr); - const auto start = this->cache != nullptr ? this->cache + 1 : this->buffered_storage->caches.get(); - const auto end = this->buffered_storage->caches.get() + this->buffered_storage->cache_count; + AMS_ASSERT(m_buffered_storage != nullptr); + const auto start = m_cache != nullptr ? m_cache + 1 : m_buffered_storage->m_caches.get(); + const auto end = m_buffered_storage->m_caches.get() + m_buffered_storage->m_cache_count; - AMS_ASSERT(start >= this->buffered_storage->caches.get()); + AMS_ASSERT(start >= m_buffered_storage->m_caches.get()); AMS_ASSERT(start <= end); this->Release(); - AMS_ASSERT(this->cache == nullptr); + AMS_ASSERT(m_cache == nullptr); for (auto cache = start; cache < end; ++cache) { if (cache->IsValid() && cache->IsDirty() && cache->TryAcquireCache()) { cache->Unlink(); - this->cache = cache; + m_cache = cache; return true; } } - this->cache = nullptr; + m_cache = nullptr; return false; } bool AcquireNextValidCache() { - AMS_ASSERT(this->buffered_storage != nullptr); - const auto start = this->cache != nullptr ? this->cache + 1 : this->buffered_storage->caches.get(); - const auto end = this->buffered_storage->caches.get() + this->buffered_storage->cache_count; + AMS_ASSERT(m_buffered_storage != nullptr); + const auto start = m_cache != nullptr ? m_cache + 1 : m_buffered_storage->m_caches.get(); + const auto end = m_buffered_storage->m_caches.get() + m_buffered_storage->m_cache_count; - AMS_ASSERT(start >= this->buffered_storage->caches.get()); + AMS_ASSERT(start >= m_buffered_storage->m_caches.get()); AMS_ASSERT(start <= end); this->Release(); - AMS_ASSERT(this->cache == nullptr); + AMS_ASSERT(m_cache == nullptr); for (auto cache = start; cache < end; ++cache) { if (cache->IsValid() && cache->TryAcquireCache()) { cache->Unlink(); - this->cache = cache; + m_cache = cache; return true; } } - this->cache = nullptr; + m_cache = nullptr; return false; } bool AcquireFetchableCache() { - AMS_ASSERT(this->buffered_storage != nullptr); + AMS_ASSERT(m_buffered_storage != nullptr); - std::scoped_lock lk(this->buffered_storage->mutex); + std::scoped_lock lk(m_buffered_storage->m_mutex); this->Release(); - AMS_ASSERT(this->cache == nullptr); + AMS_ASSERT(m_cache == nullptr); - this->cache = this->buffered_storage->next_fetch_cache; - if (this->cache != nullptr) { - if (this->cache->IsValid()) { - this->cache->TryAcquireCache(); + m_cache = m_buffered_storage->m_next_fetch_cache; + if (m_cache != nullptr) { + if (m_cache->IsValid()) { + m_cache->TryAcquireCache(); } - this->cache->Unlink(); + m_cache->Unlink(); } - return this->cache != nullptr; + return m_cache != nullptr; } void Read(s64 offset, void *buffer, size_t size) { - AMS_ASSERT(this->cache != nullptr); - this->cache->Read(offset, buffer, size); + AMS_ASSERT(m_cache != nullptr); + m_cache->Read(offset, buffer, size); } void Write(s64 offset, const void *buffer, size_t size) { - AMS_ASSERT(this->cache != nullptr); - this->cache->Write(offset, buffer, size); + AMS_ASSERT(m_cache != nullptr); + m_cache->Write(offset, buffer, size); } Result Flush() { - AMS_ASSERT(this->cache != nullptr); - return this->cache->Flush(); + AMS_ASSERT(m_cache != nullptr); + return m_cache->Flush(); } void Invalidate() { - AMS_ASSERT(this->cache != nullptr); - return this->cache->Invalidate(); + AMS_ASSERT(m_cache != nullptr); + return m_cache->Invalidate(); } bool Hits(s64 offset, s64 size) const { - AMS_ASSERT(this->cache != nullptr); - return this->cache->Hits(offset, size); + AMS_ASSERT(m_cache != nullptr); + return m_cache->Hits(offset, size); } private: void Release() { - if (this->cache != nullptr) { - AMS_ASSERT(this->buffered_storage->caches.get() <= this->cache); - AMS_ASSERT(this->cache <= this->buffered_storage->caches.get() + this->buffered_storage->cache_count); + if (m_cache != nullptr) { + AMS_ASSERT(m_buffered_storage->m_caches.get() <= m_cache); + AMS_ASSERT(m_cache <= m_buffered_storage->m_caches.get() + m_buffered_storage->m_cache_count); - this->cache->Link(); - this->cache = nullptr; + m_cache->Link(); + m_cache = nullptr; } } }; @@ -545,45 +545,45 @@ namespace ams::fssystem::save { NON_COPYABLE(UniqueCache); NON_MOVEABLE(UniqueCache); private: - Cache *cache; - BufferedStorage *buffered_storage; + Cache *m_cache; + BufferedStorage *m_buffered_storage; public: - explicit UniqueCache(BufferedStorage *bs) : cache(nullptr), buffered_storage(bs) { - AMS_ASSERT(this->buffered_storage != nullptr); + explicit UniqueCache(BufferedStorage *bs) : m_cache(nullptr), m_buffered_storage(bs) { + AMS_ASSERT(m_buffered_storage != nullptr); } ~UniqueCache() { - if (this->cache != nullptr) { - std::scoped_lock lk(this->buffered_storage->mutex); - this->cache->UnprepareFetch(); + if (m_cache != nullptr) { + std::scoped_lock lk(m_buffered_storage->m_mutex); + m_cache->UnprepareFetch(); } } const std::pair Upgrade(const SharedCache &shared_cache) { - AMS_ASSERT(this->buffered_storage == shared_cache.buffered_storage); - AMS_ASSERT(shared_cache.cache != nullptr); + AMS_ASSERT(m_buffered_storage == shared_cache.m_buffered_storage); + AMS_ASSERT(shared_cache.m_cache != nullptr); - std::scoped_lock lk(this->buffered_storage->mutex); - const auto result = shared_cache.cache->PrepareFetch(); + std::scoped_lock lk(m_buffered_storage->m_mutex); + const auto result = shared_cache.m_cache->PrepareFetch(); if (R_SUCCEEDED(result.first) && result.second) { - this->cache = shared_cache.cache; + m_cache = shared_cache.m_cache; } return result; } Result Fetch(s64 offset) { - AMS_ASSERT(this->cache != nullptr); - return this->cache->Fetch(offset); + AMS_ASSERT(m_cache != nullptr); + return m_cache->Fetch(offset); } Result FetchFromBuffer(s64 offset, const void *buffer, size_t buffer_size) { - AMS_ASSERT(this->cache != nullptr); - R_TRY(this->cache->FetchFromBuffer(offset, buffer, buffer_size)); + AMS_ASSERT(m_cache != nullptr); + R_TRY(m_cache->FetchFromBuffer(offset, buffer, buffer_size)); return ResultSuccess(); } }; - BufferedStorage::BufferedStorage() : base_storage(), buffer_manager(), block_size(), base_storage_size(), caches(), cache_count(), next_acquire_cache(), next_fetch_cache(), mutex(), bulk_read_enabled() { + BufferedStorage::BufferedStorage() : m_base_storage(), m_buffer_manager(), m_block_size(), m_base_storage_size(), m_caches(), m_cache_count(), m_next_acquire_cache(), m_next_fetch_cache(), m_mutex(), m_bulk_read_enabled() { /* ... */ } @@ -598,33 +598,33 @@ namespace ams::fssystem::save { AMS_ASSERT(buffer_count > 0); /* Get the base storage size. */ - R_TRY(base_storage.GetSize(std::addressof(this->base_storage_size))); + R_TRY(base_storage.GetSize(std::addressof(m_base_storage_size))); /* Set members. */ - this->base_storage = base_storage; - this->buffer_manager = buffer_manager; - this->block_size = block_size; - this->cache_count = buffer_count; + m_base_storage = base_storage; + m_buffer_manager = buffer_manager; + m_block_size = block_size; + m_cache_count = buffer_count; /* Allocate the caches. */ - this->caches.reset(new Cache[buffer_count]); - R_UNLESS(this->caches != nullptr, fs::ResultAllocationFailureInBufferedStorageA()); + m_caches.reset(new Cache[buffer_count]); + R_UNLESS(m_caches != nullptr, fs::ResultAllocationFailureInBufferedStorageA()); /* Initialize the caches. */ for (auto i = 0; i < buffer_count; i++) { - this->caches[i].Initialize(this); + m_caches[i].Initialize(this); } - this->next_acquire_cache = std::addressof(this->caches[0]); + m_next_acquire_cache = std::addressof(m_caches[0]); return ResultSuccess(); } void BufferedStorage::Finalize() { - this->base_storage = fs::SubStorage(); - this->base_storage_size = 0; - this->caches.reset(); - this->cache_count = 0; - this->next_fetch_cache = nullptr; + m_base_storage = fs::SubStorage(); + m_base_storage_size = 0; + m_caches.reset(); + m_cache_count = 0; + m_next_fetch_cache = nullptr; } Result BufferedStorage::Read(s64 offset, void *buffer, size_t size) { @@ -659,16 +659,16 @@ namespace ams::fssystem::save { AMS_ASSERT(out != nullptr); AMS_ASSERT(this->IsInitialized()); - *out = this->base_storage_size; + *out = m_base_storage_size; return ResultSuccess(); } Result BufferedStorage::SetSize(s64 size) { AMS_ASSERT(this->IsInitialized()); - const s64 prev_size = this->base_storage_size; + const s64 prev_size = m_base_storage_size; if (prev_size < size) { /* Prepare to expand. */ - if (!util::IsAligned(prev_size, this->block_size)) { + if (!util::IsAligned(prev_size, m_block_size)) { SharedCache cache(this); const auto invalidate_offset = prev_size; const auto invalidate_size = size - prev_size; @@ -683,7 +683,7 @@ namespace ams::fssystem::save { SharedCache cache(this); const auto invalidate_offset = prev_size; const auto invalidate_size = size - prev_size; - const auto is_fragment = util::IsAligned(size, this->block_size); + const auto is_fragment = util::IsAligned(size, m_block_size); while (cache.AcquireNextOverlappedCache(invalidate_offset, invalidate_size)) { if (is_fragment && cache.Hits(invalidate_offset, 1)) { R_TRY(cache.Flush()); @@ -693,13 +693,13 @@ namespace ams::fssystem::save { } /* Set the size. */ - R_TRY(this->base_storage.SetSize(size)); + R_TRY(m_base_storage.SetSize(size)); /* Get our new size. */ s64 new_size = 0; - R_TRY(this->base_storage.GetSize(std::addressof(new_size))); + R_TRY(m_base_storage.GetSize(std::addressof(new_size))); - this->base_storage_size = new_size; + m_base_storage_size = new_size; return ResultSuccess(); } @@ -713,7 +713,7 @@ namespace ams::fssystem::save { } /* Flush the base storage. */ - R_TRY(this->base_storage.Flush()); + R_TRY(m_base_storage.Flush()); return ResultSuccess(); } @@ -728,7 +728,7 @@ namespace ams::fssystem::save { } } - return this->base_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size); + return m_base_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size); } void BufferedStorage::InvalidateCaches() { @@ -741,16 +741,16 @@ namespace ams::fssystem::save { } Result BufferedStorage::PrepareAllocation() { - const auto flush_threshold = this->buffer_manager->GetTotalSize() / 8; - if (this->buffer_manager->GetTotalAllocatableSize() < flush_threshold) { + const auto flush_threshold = m_buffer_manager->GetTotalSize() / 8; + if (m_buffer_manager->GetTotalAllocatableSize() < flush_threshold) { R_TRY(this->Flush()); } return ResultSuccess(); } Result BufferedStorage::ControlDirtiness() { - const auto flush_threshold = this->buffer_manager->GetTotalSize() / 4; - if (this->buffer_manager->GetTotalAllocatableSize() < flush_threshold) { + const auto flush_threshold = m_buffer_manager->GetTotalSize() / 4; + if (m_buffer_manager->GetTotalAllocatableSize() < flush_threshold) { s32 dirty_count = 0; SharedCache cache(this); while (cache.AcquireNextDirtyCache()) { @@ -764,11 +764,11 @@ namespace ams::fssystem::save { } Result BufferedStorage::ReadCore(s64 offset, void *buffer, size_t size) { - AMS_ASSERT(this->caches != nullptr); + AMS_ASSERT(m_caches != nullptr); AMS_ASSERT(buffer != nullptr); /* Validate the offset. */ - const auto base_storage_size = this->base_storage_size; + const auto base_storage_size = m_base_storage_size; R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); R_UNLESS(offset <= base_storage_size, fs::ResultInvalidOffset()); @@ -778,7 +778,7 @@ namespace ams::fssystem::save { s64 buf_offset = 0; /* Determine what caches are needed, if we have bulk read set. */ - if (this->bulk_read_enabled) { + if (m_bulk_read_enabled) { /* Check head cache. */ const auto head_cache_needed = this->ReadHeadCache(std::addressof(cur_offset), buffer, std::addressof(remaining_size), std::addressof(buf_offset)); R_SUCCEED_IF(remaining_size == 0); @@ -811,16 +811,16 @@ namespace ams::fssystem::save { auto *cur_dst = static_cast(buffer) + buf_offset; size_t cur_size = 0; - if (!util::IsAligned(cur_offset, this->block_size)) { - const size_t aligned_size = this->block_size - (cur_offset & (this->block_size - 1)); + if (!util::IsAligned(cur_offset, m_block_size)) { + const size_t aligned_size = m_block_size - (cur_offset & (m_block_size - 1)); cur_size = std::min(aligned_size, remaining_size); - } else if (remaining_size < this->block_size) { + } else if (remaining_size < m_block_size) { cur_size = remaining_size; } else { - cur_size = util::AlignDown(remaining_size, this->block_size); + cur_size = util::AlignDown(remaining_size, m_block_size); } - if (cur_size <= this->block_size) { + if (cur_size <= m_block_size) { SharedCache cache(this); if (!cache.AcquireNextOverlappedCache(cur_offset, cur_size)) { R_TRY(this->PrepareAllocation()); @@ -846,7 +846,7 @@ namespace ams::fssystem::save { cache.Invalidate(); } } - R_TRY(this->base_storage.Read(cur_offset, cur_dst, cur_size)); + R_TRY(m_base_storage.Read(cur_offset, cur_dst, cur_size)); } remaining_size -= cur_size; @@ -863,18 +863,18 @@ namespace ams::fssystem::save { AMS_ASSERT(size != nullptr); AMS_ASSERT(buffer_offset != nullptr); - bool is_cache_needed = !util::IsAligned(*offset, this->block_size); + bool is_cache_needed = !util::IsAligned(*offset, m_block_size); while (*size > 0) { size_t cur_size = 0; - if (!util::IsAligned(*offset, this->block_size)) { - const s64 aligned_size = util::AlignUp(*offset, this->block_size) - *offset; + if (!util::IsAligned(*offset, m_block_size)) { + const s64 aligned_size = util::AlignUp(*offset, m_block_size) - *offset; cur_size = std::min(aligned_size, static_cast(*size)); - } else if (*size < this->block_size) { + } else if (*size < m_block_size) { cur_size = *size; } else { - cur_size = this->block_size; + cur_size = m_block_size; } SharedCache cache(this); @@ -896,19 +896,19 @@ namespace ams::fssystem::save { AMS_ASSERT(buffer != nullptr); AMS_ASSERT(size != nullptr); - bool is_cache_needed = !util::IsAligned(offset + *size, this->block_size); + bool is_cache_needed = !util::IsAligned(offset + *size, m_block_size); while (*size > 0) { const s64 cur_offset_end = offset + *size; size_t cur_size = 0; - if (!util::IsAligned(cur_offset_end, this->block_size)) { - const s64 aligned_size = cur_offset_end - util::AlignDown(cur_offset_end, this->block_size); + if (!util::IsAligned(cur_offset_end, m_block_size)) { + const s64 aligned_size = cur_offset_end - util::AlignDown(cur_offset_end, m_block_size); cur_size = std::min(aligned_size, static_cast(*size)); - } else if (*size < this->block_size) { + } else if (*size < m_block_size) { cur_size = *size; } else { - cur_size = this->block_size; + cur_size = m_block_size; } const s64 cur_offset = cur_offset_end - static_cast(cur_size); @@ -929,8 +929,8 @@ namespace ams::fssystem::save { Result BufferedStorage::BulkRead(s64 offset, void *buffer, size_t size, bool head_cache_needed, bool tail_cache_needed) { /* Determine aligned extents. */ - const s64 aligned_offset = util::AlignDown(offset, this->block_size); - const s64 aligned_offset_end = std::min(util::AlignUp(offset + static_cast(size), this->block_size), this->base_storage_size); + const s64 aligned_offset = util::AlignDown(offset, m_block_size); + const s64 aligned_offset_end = std::min(util::AlignUp(offset + static_cast(size), m_block_size), m_base_storage_size); const s64 aligned_size = aligned_offset_end - aligned_offset; /* Allocate a work buffer. */ @@ -954,7 +954,7 @@ namespace ams::fssystem::save { } /* Read from the base storage. */ - R_TRY(this->base_storage.Read(aligned_offset, work_buffer, static_cast(aligned_size))); + R_TRY(m_base_storage.Read(aligned_offset, work_buffer, static_cast(aligned_size))); if (work_buffer != static_cast(buffer)) { std::memcpy(buffer, work_buffer + offset - aligned_offset, size); } @@ -982,7 +982,7 @@ namespace ams::fssystem::save { } /* Handle tail cache if needed. */ - if (tail_cache_needed && (!head_cache_needed || aligned_size > static_cast(this->block_size))) { + if (tail_cache_needed && (!head_cache_needed || aligned_size > static_cast(m_block_size))) { if (!cached) { R_TRY(this->PrepareAllocation()); } @@ -995,7 +995,7 @@ namespace ams::fssystem::save { const auto upgrade_result = fetch_cache.Upgrade(cache); R_TRY(upgrade_result.first); if (upgrade_result.second) { - const s64 tail_cache_offset = util::AlignDown(offset + static_cast(size), this->block_size); + const s64 tail_cache_offset = util::AlignDown(offset + static_cast(size), m_block_size); const size_t tail_cache_size = static_cast(aligned_size - tail_cache_offset + aligned_offset); R_TRY(fetch_cache.FetchFromBuffer(tail_cache_offset, work_buffer + tail_cache_offset - aligned_offset, tail_cache_size)); break; @@ -1011,11 +1011,11 @@ namespace ams::fssystem::save { } Result BufferedStorage::WriteCore(s64 offset, const void *buffer, size_t size) { - AMS_ASSERT(this->caches != nullptr); + AMS_ASSERT(m_caches != nullptr); AMS_ASSERT(buffer != nullptr); /* Validate the offset. */ - const auto base_storage_size = this->base_storage_size; + const auto base_storage_size = m_base_storage_size; R_UNLESS(offset >= 0, fs::ResultInvalidOffset()); R_UNLESS(offset <= base_storage_size, fs::ResultInvalidOffset()); @@ -1030,16 +1030,16 @@ namespace ams::fssystem::save { const auto *cur_src = static_cast(buffer) + buf_offset; size_t cur_size = 0; - if (!util::IsAligned(cur_offset, this->block_size)) { - const size_t aligned_size = this->block_size - (cur_offset & (this->block_size - 1)); + if (!util::IsAligned(cur_offset, m_block_size)) { + const size_t aligned_size = m_block_size - (cur_offset & (m_block_size - 1)); cur_size = std::min(aligned_size, remaining_size); - } else if (remaining_size < this->block_size) { + } else if (remaining_size < m_block_size) { cur_size = remaining_size; } else { - cur_size = util::AlignDown(remaining_size, this->block_size); + cur_size = util::AlignDown(remaining_size, m_block_size); } - if (cur_size <= this->block_size) { + if (cur_size <= m_block_size) { SharedCache cache(this); if (!cache.AcquireNextOverlappedCache(cur_offset, cur_size)) { R_TRY(this->PrepareAllocation()); @@ -1069,7 +1069,7 @@ namespace ams::fssystem::save { } } - R_TRY(this->base_storage.Write(cur_offset, cur_src, cur_size)); + R_TRY(m_base_storage.Write(cur_offset, cur_src, cur_size)); buffers::EnableBlockingBufferManagerAllocation(); } diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp index 888c8af54..a16a99a54 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp @@ -56,7 +56,7 @@ namespace ams::fssystem::save { } /* Instantiate the global random generation function. */ - HierarchicalIntegrityVerificationStorage::GenerateRandomFunction HierarchicalIntegrityVerificationStorage::s_generate_random = nullptr; + constinit HierarchicalIntegrityVerificationStorage::GenerateRandomFunction HierarchicalIntegrityVerificationStorage::s_generate_random = nullptr; Result HierarchicalIntegrityVerificationStorageControlArea::QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size) { /* Validate preconditions. */ @@ -130,24 +130,24 @@ namespace ams::fssystem::save { { s64 meta_size = 0; R_TRY(meta_storage.GetSize(std::addressof(meta_size))); - R_UNLESS(meta_size >= static_cast(sizeof(this->meta)), fs::ResultInvalidSize()); + R_UNLESS(meta_size >= static_cast(sizeof(m_meta)), fs::ResultInvalidSize()); } /* Set the storage and read the meta. */ - this->storage = meta_storage; - R_TRY(this->storage.Read(0, std::addressof(this->meta), sizeof(this->meta))); + m_storage = meta_storage; + R_TRY(m_storage.Read(0, std::addressof(m_meta), sizeof(m_meta))); /* Validate the meta magic. */ - R_UNLESS(this->meta.magic == IntegrityVerificationStorageMagic, fs::ResultIncorrectIntegrityVerificationMagic()); + R_UNLESS(m_meta.magic == IntegrityVerificationStorageMagic, fs::ResultIncorrectIntegrityVerificationMagic()); /* Validate the meta version. */ - R_UNLESS((this->meta.version & IntegrityVerificationStorageVersionMask) == (IntegrityVerificationStorageVersion & IntegrityVerificationStorageVersionMask), fs::ResultUnsupportedVersion()); + R_UNLESS((m_meta.version & IntegrityVerificationStorageVersionMask) == (IntegrityVerificationStorageVersion & IntegrityVerificationStorageVersionMask), fs::ResultUnsupportedVersion()); return ResultSuccess(); } void HierarchicalIntegrityVerificationStorageControlArea::Finalize() { - this->storage = fs::SubStorage(); + m_storage = fs::SubStorage(); } Result HierarchicalIntegrityVerificationStorage::Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type) { @@ -156,9 +156,9 @@ namespace ams::fssystem::save { AMS_ASSERT(IntegrityMinLayerCount <= info.max_layers && info.max_layers <= IntegrityMaxLayerCount); /* Set member variables. */ - this->max_layers = info.max_layers; - this->buffers = bufs; - this->mutex = mtx; + m_max_layers = info.max_layers; + m_buffers = bufs; + m_mutex = mtx; /* Determine our cache counts. */ const auto max_data_cache_entry_count = (storage_type == fs::StorageType_SaveData) ? MaxSaveDataFsDataCacheEntryCount : MaxRomFsDataCacheEntryCount; @@ -168,64 +168,64 @@ namespace ams::fssystem::save { { fs::HashSalt mac; crypto::GenerateHmacSha256Mac(mac.value, sizeof(mac), info.seed.value, sizeof(info.seed), KeyArray[0].key, KeyArray[0].size); - this->verify_storages[0].Initialize(storage[HierarchicalStorageInformation::MasterStorage], storage[HierarchicalStorageInformation::Layer1Storage], static_cast(1) << info.info[0].block_order, HashSize, this->buffers->buffers[this->max_layers - 2], mac, false, storage_type); + m_verify_storages[0].Initialize(storage[HierarchicalStorageInformation::MasterStorage], storage[HierarchicalStorageInformation::Layer1Storage], static_cast(1) << info.info[0].block_order, HashSize, m_buffers->buffers[m_max_layers - 2], mac, false, storage_type); } /* Ensure we don't leak state if further initialization goes wrong. */ auto top_verif_guard = SCOPE_GUARD { - this->verify_storages[0].Finalize(); + m_verify_storages[0].Finalize(); - this->data_size = -1; - this->buffers = nullptr; - this->mutex = nullptr; + m_data_size = -1; + m_buffers = nullptr; + m_mutex = nullptr; }; /* Initialize the top level buffer storage. */ - R_TRY(this->buffer_storages[0].Initialize(this->buffers->buffers[0], this->mutex, std::addressof(this->verify_storages[0]), info.info[0].size, static_cast(1) << info.info[0].block_order, max_hash_cache_entry_count, false, 0x10, false, storage_type)); - auto top_buffer_guard = SCOPE_GUARD { this->buffer_storages[0].Finalize(); }; + R_TRY(m_buffer_storages[0].Initialize(m_buffers->buffers[0], m_mutex, std::addressof(m_verify_storages[0]), info.info[0].size, static_cast(1) << info.info[0].block_order, max_hash_cache_entry_count, false, 0x10, false, storage_type)); + auto top_buffer_guard = SCOPE_GUARD { m_buffer_storages[0].Finalize(); }; /* Prepare to initialize the level storages. */ s32 level = 0; /* Ensure we don't leak state if further initialization goes wrong. */ auto level_guard = SCOPE_GUARD { - this->verify_storages[level + 1].Finalize(); + m_verify_storages[level + 1].Finalize(); for (/* ... */; level > 0; --level) { - this->buffer_storages[level].Finalize(); - this->verify_storages[level].Finalize(); + m_buffer_storages[level].Finalize(); + m_verify_storages[level].Finalize(); } }; /* Initialize the level storages. */ - for (/* ... */; level < this->max_layers - 3; ++level) { + for (/* ... */; level < m_max_layers - 3; ++level) { /* Initialize the verification storage. */ { - fs::SubStorage buffer_storage(std::addressof(this->buffer_storages[level]), 0, info.info[level].size); + fs::SubStorage buffer_storage(std::addressof(m_buffer_storages[level]), 0, info.info[level].size); fs::HashSalt mac; crypto::GenerateHmacSha256Mac(mac.value, sizeof(mac), info.seed.value, sizeof(info.seed), KeyArray[level + 1].key, KeyArray[level + 1].size); - this->verify_storages[level + 1].Initialize(buffer_storage, storage[level + 2], static_cast(1) << info.info[level + 1].block_order, static_cast(1) << info.info[level].block_order, this->buffers->buffers[this->max_layers - 2], mac, false, storage_type); + m_verify_storages[level + 1].Initialize(buffer_storage, storage[level + 2], static_cast(1) << info.info[level + 1].block_order, static_cast(1) << info.info[level].block_order, m_buffers->buffers[m_max_layers - 2], mac, false, storage_type); } /* Initialize the buffer storage. */ - R_TRY(this->buffer_storages[level + 1].Initialize(this->buffers->buffers[level + 1], this->mutex, std::addressof(this->verify_storages[level + 1]), info.info[level + 1].size, static_cast(1) << info.info[level + 1].block_order, max_hash_cache_entry_count, false, 0x11 + static_cast(level), false, storage_type)); + R_TRY(m_buffer_storages[level + 1].Initialize(m_buffers->buffers[level + 1], m_mutex, std::addressof(m_verify_storages[level + 1]), info.info[level + 1].size, static_cast(1) << info.info[level + 1].block_order, max_hash_cache_entry_count, false, 0x11 + static_cast(level), false, storage_type)); } /* Initialize the final level storage. */ { /* Initialize the verification storage. */ { - fs::SubStorage buffer_storage(std::addressof(this->buffer_storages[level]), 0, info.info[level].size); + fs::SubStorage buffer_storage(std::addressof(m_buffer_storages[level]), 0, info.info[level].size); fs::HashSalt mac; crypto::GenerateHmacSha256Mac(mac.value, sizeof(mac), info.seed.value, sizeof(info.seed), KeyArray[level + 1].key, KeyArray[level + 1].size); - this->verify_storages[level + 1].Initialize(buffer_storage, storage[level + 2], static_cast(1) << info.info[level + 1].block_order, static_cast(1) << info.info[level].block_order, this->buffers->buffers[this->max_layers - 2], mac, true, storage_type); + m_verify_storages[level + 1].Initialize(buffer_storage, storage[level + 2], static_cast(1) << info.info[level + 1].block_order, static_cast(1) << info.info[level].block_order, m_buffers->buffers[m_max_layers - 2], mac, true, storage_type); } /* Initialize the buffer storage. */ - R_TRY(this->buffer_storages[level + 1].Initialize(this->buffers->buffers[level + 1], this->mutex, std::addressof(this->verify_storages[level + 1]), info.info[level + 1].size, static_cast(1) << info.info[level + 1].block_order, max_data_cache_entry_count, true, 0x11 + static_cast(level), true, storage_type)); + R_TRY(m_buffer_storages[level + 1].Initialize(m_buffers->buffers[level + 1], m_mutex, std::addressof(m_verify_storages[level + 1]), info.info[level + 1].size, static_cast(1) << info.info[level + 1].block_order, max_data_cache_entry_count, true, 0x11 + static_cast(level), true, storage_type)); } /* Set the data size. */ - this->data_size = info.info[level + 1].size; + m_data_size = info.info[level + 1].size; /* We succeeded. */ level_guard.Cancel(); @@ -235,24 +235,24 @@ namespace ams::fssystem::save { } void HierarchicalIntegrityVerificationStorage::Finalize() { - if (this->data_size >= 0) { - this->data_size = 0; + if (m_data_size >= 0) { + m_data_size = 0; - this->buffers = nullptr; - this->mutex = nullptr; + m_buffers = nullptr; + m_mutex = nullptr; - for (s32 level = this->max_layers - 2; level >= 0; --level) { - this->buffer_storages[level].Finalize(); - this->verify_storages[level].Finalize(); + for (s32 level = m_max_layers - 2; level >= 0; --level) { + m_buffer_storages[level].Finalize(); + m_verify_storages[level].Finalize(); } - this->data_size = -1; + m_data_size = -1; } } Result HierarchicalIntegrityVerificationStorage::Read(s64 offset, void *buffer, size_t size) { /* Validate preconditions. */ - AMS_ASSERT(this->data_size >= 0); + AMS_ASSERT(m_data_size >= 0); /* Succeed if zero-size. */ R_SUCCEED_IF(size == 0); @@ -262,8 +262,8 @@ namespace ams::fssystem::save { /* Acquire access to the read semaphore. */ if (!g_read_semaphore.TimedAcquire(AccessTimeout)) { - for (auto level = this->max_layers - 2; level >= 0; --level) { - R_TRY(this->buffer_storages[level].Flush()); + for (auto level = m_max_layers - 2; level >= 0; --level) { + R_TRY(m_buffer_storages[level].Flush()); } g_read_semaphore.Acquire(); } @@ -272,13 +272,13 @@ namespace ams::fssystem::save { ON_SCOPE_EXIT { g_read_semaphore.Release(); }; /* Read the data. */ - R_TRY(this->buffer_storages[this->max_layers - 2].Read(offset, buffer, size)); + R_TRY(m_buffer_storages[m_max_layers - 2].Read(offset, buffer, size)); return ResultSuccess(); } Result HierarchicalIntegrityVerificationStorage::Write(s64 offset, const void *buffer, size_t size) { /* Validate preconditions. */ - AMS_ASSERT(this->data_size >= 0); + AMS_ASSERT(m_data_size >= 0); /* Succeed if zero-size. */ R_SUCCEED_IF(size == 0); @@ -288,8 +288,8 @@ namespace ams::fssystem::save { /* Acquire access to the write semaphore. */ if (!g_write_semaphore.TimedAcquire(AccessTimeout)) { - for (auto level = this->max_layers - 2; level >= 0; --level) { - R_TRY(this->buffer_storages[level].Flush()); + for (auto level = m_max_layers - 2; level >= 0; --level) { + R_TRY(m_buffer_storages[level].Flush()); } g_write_semaphore.Acquire(); } @@ -298,15 +298,15 @@ namespace ams::fssystem::save { ON_SCOPE_EXIT { g_write_semaphore.Release(); }; /* Write the data. */ - R_TRY(this->buffer_storages[this->max_layers - 2].Write(offset, buffer, size)); - this->is_written_for_rollback = true; + R_TRY(m_buffer_storages[m_max_layers - 2].Write(offset, buffer, size)); + m_is_written_for_rollback = true; return ResultSuccess(); } Result HierarchicalIntegrityVerificationStorage::GetSize(s64 *out) { AMS_ASSERT(out != nullptr); - AMS_ASSERT(this->data_size >= 0); - *out = this->data_size; + AMS_ASSERT(m_data_size >= 0); + *out = m_data_size; return ResultSuccess(); } @@ -319,14 +319,14 @@ namespace ams::fssystem::save { case fs::OperationId::FillZero: case fs::OperationId::DestroySignature: { - R_TRY(this->buffer_storages[this->max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); - this->is_written_for_rollback = true; + R_TRY(m_buffer_storages[m_max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + m_is_written_for_rollback = true; return ResultSuccess(); } case fs::OperationId::Invalidate: case fs::OperationId::QueryRange: { - R_TRY(this->buffer_storages[this->max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); + R_TRY(m_buffer_storages[m_max_layers - 2].OperateRange(dst, dst_size, op_id, offset, size, src, src_size)); return ResultSuccess(); } default: @@ -335,17 +335,17 @@ namespace ams::fssystem::save { } Result HierarchicalIntegrityVerificationStorage::Commit() { - for (s32 level = this->max_layers - 2; level >= 0; --level) { - R_TRY(this->buffer_storages[level].Commit()); + for (s32 level = m_max_layers - 2; level >= 0; --level) { + R_TRY(m_buffer_storages[level].Commit()); } return ResultSuccess(); } Result HierarchicalIntegrityVerificationStorage::OnRollback() { - for (s32 level = this->max_layers - 2; level >= 0; --level) { - R_TRY(this->buffer_storages[level].OnRollback()); + for (s32 level = m_max_layers - 2; level >= 0; --level) { + R_TRY(m_buffer_storages[level].OnRollback()); } - this->is_written_for_rollback = false; + m_is_written_for_rollback = false; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp index c72cc02db..a261369d5 100644 --- a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp @@ -23,47 +23,47 @@ namespace ams::fssystem::save { AMS_ASSERT(bm != nullptr); /* Set storages. */ - this->hash_storage = hs; - this->data_storage = ds; + m_hash_storage = hs; + m_data_storage = ds; /* Set verification block sizes. */ - this->verification_block_size = verif_block_size; - this->verification_block_order = ILog2(static_cast(verif_block_size)); - AMS_ASSERT(this->verification_block_size == (1l << this->verification_block_order)); + m_verification_block_size = verif_block_size; + m_verification_block_order = ILog2(static_cast(verif_block_size)); + AMS_ASSERT(m_verification_block_size == (1l << m_verification_block_order)); /* Set buffer manager. */ - this->buffer_manager = bm; + m_buffer_manager = bm; /* Set upper layer block sizes. */ upper_layer_verif_block_size = std::max(upper_layer_verif_block_size, HashSize); - this->upper_layer_verification_block_size = upper_layer_verif_block_size; - this->upper_layer_verification_block_order = ILog2(static_cast(upper_layer_verif_block_size)); - AMS_ASSERT(this->upper_layer_verification_block_size == (1l << this->upper_layer_verification_block_order)); + m_upper_layer_verification_block_size = upper_layer_verif_block_size; + m_upper_layer_verification_block_order = ILog2(static_cast(upper_layer_verif_block_size)); + AMS_ASSERT(m_upper_layer_verification_block_size == (1l << m_upper_layer_verification_block_order)); /* Validate sizes. */ { s64 hash_size = 0; s64 data_size = 0; - R_ASSERT(hash_storage.GetSize(std::addressof(hash_size))); - R_ASSERT(data_storage.GetSize(std::addressof(hash_size))); - AMS_ASSERT(((hash_size / HashSize) * this->verification_block_size) >= data_size); + AMS_ASSERT(R_SUCCEEDED(m_hash_storage.GetSize(std::addressof(hash_size)))); + AMS_ASSERT(R_SUCCEEDED(m_data_storage.GetSize(std::addressof(hash_size)))); + AMS_ASSERT(((hash_size / HashSize) * m_verification_block_size) >= data_size); AMS_UNUSED(hash_size, data_size); } /* Set salt. */ - std::memcpy(this->salt.value, salt.value, fs::HashSalt::Size); + std::memcpy(m_salt.value, salt.value, fs::HashSalt::Size); /* Set data and storage type. */ - this->is_real_data = is_real_data; - this->storage_type = storage_type; + m_is_real_data = is_real_data; + m_storage_type = storage_type; return ResultSuccess(); } void IntegrityVerificationStorage::Finalize() { - if (this->buffer_manager != nullptr) { - this->hash_storage = fs::SubStorage(); - this->data_storage = fs::SubStorage(); - this->buffer_manager = nullptr; + if (m_buffer_manager != nullptr) { + m_hash_storage = fs::SubStorage(); + m_data_storage = fs::SubStorage(); + m_buffer_manager = nullptr; } } @@ -72,8 +72,8 @@ namespace ams::fssystem::save { AMS_ASSERT(size != 0); /* Validate other preconditions. */ - AMS_ASSERT(util::IsAligned(offset, static_cast(this->verification_block_size))); - AMS_ASSERT(util::IsAligned(size, static_cast(this->verification_block_size))); + AMS_ASSERT(util::IsAligned(offset, static_cast(m_verification_block_size))); + AMS_ASSERT(util::IsAligned(size, static_cast(m_verification_block_size))); /* Succeed if zero size. */ R_SUCCEED_IF(size == 0); @@ -83,19 +83,19 @@ namespace ams::fssystem::save { /* Validate the offset. */ s64 data_size; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(offset <= data_size, fs::ResultInvalidOffset()); /* Validate the access range. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, util::AlignUp(data_size, static_cast(this->verification_block_size))), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, util::AlignUp(data_size, static_cast(m_verification_block_size))), fs::ResultOutOfRange()); /* Determine the read extents. */ size_t read_size = size; if (static_cast(offset + read_size) > data_size) { /* Determine the padding sizes. */ s64 padding_offset = data_size - offset; - size_t padding_size = static_cast(this->verification_block_size - (padding_offset & (this->verification_block_size - 1))); - AMS_ASSERT(static_cast(padding_size) < this->verification_block_size); + size_t padding_size = static_cast(m_verification_block_size - (padding_offset & (m_verification_block_size - 1))); + AMS_ASSERT(static_cast(padding_size) < m_verification_block_size); /* Clear the padding. */ std::memset(static_cast(buffer) + padding_offset, 0, padding_size); @@ -107,12 +107,12 @@ namespace ams::fssystem::save { /* Perform the read. */ { auto clear_guard = SCOPE_GUARD { std::memset(buffer, 0, size); }; - R_TRY(this->data_storage.Read(offset, buffer, read_size)); + R_TRY(m_data_storage.Read(offset, buffer, read_size)); clear_guard.Cancel(); } /* Prepare to validate the signatures. */ - const auto signature_count = size >> this->verification_block_order; + const auto signature_count = size >> m_verification_block_order; PooledBuffer signature_buffer(signature_count * sizeof(BlockHash), sizeof(BlockHash)); const auto buffer_count = std::min(signature_count, signature_buffer.GetSize() / sizeof(BlockHash)); @@ -123,23 +123,23 @@ namespace ams::fssystem::save { while (verified_count < signature_count) { /* Read the current signatures. */ const auto cur_count = std::min(buffer_count, signature_count - verified_count); - auto cur_result = this->ReadBlockSignature(signature_buffer.GetBuffer(), signature_buffer.GetSize(), offset + (verified_count << this->verification_block_order), cur_count << this->verification_block_order); + auto cur_result = this->ReadBlockSignature(signature_buffer.GetBuffer(), signature_buffer.GetSize(), offset + (verified_count << m_verification_block_order), cur_count << m_verification_block_order); /* Temporarily increase our priority. */ ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); /* Loop over each signature we read. */ for (size_t i = 0; i < cur_count && R_SUCCEEDED(cur_result); ++i) { - const auto verified_size = (verified_count + i) << this->verification_block_order; + const auto verified_size = (verified_count + i) << m_verification_block_order; u8 *cur_buf = static_cast(buffer) + verified_size; cur_result = this->VerifyHash(cur_buf, reinterpret_cast(signature_buffer.GetBuffer()) + i); /* If the data is corrupted, clear the corrupted parts. */ if (fs::ResultIntegrityVerificationStorageCorrupted::Includes(cur_result)) { - std::memset(cur_buf, 0, this->verification_block_size); + std::memset(cur_buf, 0, m_verification_block_size); /* Set the result if we should. */ - if (!fs::ResultClearedRealDataVerificationFailed::Includes(cur_result) && this->storage_type != fs::StorageType_Authoring) { + if (!fs::ResultClearedRealDataVerificationFailed::Includes(cur_result) && m_storage_type != fs::StorageType_Authoring) { verify_hash_result = cur_result; } @@ -170,17 +170,17 @@ namespace ams::fssystem::save { /* Validate the offset. */ s64 data_size; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(offset < data_size, fs::ResultInvalidOffset()); /* Validate the access range. */ - R_UNLESS(IStorage::CheckAccessRange(offset, size, util::AlignUp(data_size, static_cast(this->verification_block_size))), fs::ResultOutOfRange()); + R_UNLESS(IStorage::CheckAccessRange(offset, size, util::AlignUp(data_size, static_cast(m_verification_block_size))), fs::ResultOutOfRange()); /* Validate preconditions. */ - AMS_ASSERT(util::IsAligned(offset, this->verification_block_size)); - AMS_ASSERT(util::IsAligned(size, this->verification_block_size)); + AMS_ASSERT(util::IsAligned(offset, m_verification_block_size)); + AMS_ASSERT(util::IsAligned(size, m_verification_block_size)); AMS_ASSERT(offset <= data_size); - AMS_ASSERT(static_cast(offset + size) < data_size + this->verification_block_size); + AMS_ASSERT(static_cast(offset + size) < data_size + m_verification_block_size); /* Validate that if writing past the end, all extra data is zero padding. */ if (static_cast(offset + size) > data_size) { @@ -201,13 +201,13 @@ namespace ams::fssystem::save { } /* Determine the size we're writing in blocks. */ - const auto aligned_write_size = util::AlignUp(write_size, this->verification_block_size); + const auto aligned_write_size = util::AlignUp(write_size, m_verification_block_size); /* Write the updated block signatures. */ Result update_result = ResultSuccess(); size_t updated_count = 0; { - const auto signature_count = aligned_write_size >> this->verification_block_order; + const auto signature_count = aligned_write_size >> m_verification_block_order; PooledBuffer signature_buffer(signature_count * sizeof(BlockHash), sizeof(BlockHash)); const auto buffer_count = std::min(signature_count, signature_buffer.GetSize() / sizeof(BlockHash)); @@ -219,13 +219,13 @@ namespace ams::fssystem::save { ScopedThreadPriorityChanger cp(+1, ScopedThreadPriorityChanger::Mode::Relative); for (size_t i = 0; i < cur_count; ++i) { - const auto updated_size = (updated_count + i) << this->verification_block_order; + const auto updated_size = (updated_count + i) << m_verification_block_order; this->CalcBlockHash(reinterpret_cast(signature_buffer.GetBuffer()) + i, reinterpret_cast(buffer) + updated_size); } } /* Write the new block signatures. */ - if (R_FAILED((update_result = this->WriteBlockSignature(signature_buffer.GetBuffer(), signature_buffer.GetSize(), offset + (updated_count << this->verification_block_order), cur_count << this->verification_block_order)))) { + if (R_FAILED((update_result = this->WriteBlockSignature(signature_buffer.GetBuffer(), signature_buffer.GetSize(), offset + (updated_count << m_verification_block_order), cur_count << m_verification_block_order)))) { break; } @@ -235,44 +235,44 @@ namespace ams::fssystem::save { } /* Write the data. */ - R_TRY(this->data_storage.Write(offset, buffer, std::min(write_size, updated_count << this->verification_block_order))); + R_TRY(m_data_storage.Write(offset, buffer, std::min(write_size, updated_count << m_verification_block_order))); return update_result; } Result IntegrityVerificationStorage::GetSize(s64 *out) { - return this->data_storage.GetSize(out); + return m_data_storage.GetSize(out); } Result IntegrityVerificationStorage::Flush() { /* Flush both storages. */ - R_TRY(this->hash_storage.Flush()); - R_TRY(this->data_storage.Flush()); + R_TRY(m_hash_storage.Flush()); + R_TRY(m_data_storage.Flush()); return ResultSuccess(); } Result IntegrityVerificationStorage::OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { /* Validate preconditions. */ - AMS_ASSERT(util::IsAligned(offset, static_cast(this->verification_block_size))); - AMS_ASSERT(util::IsAligned(size, static_cast(this->verification_block_size))); + AMS_ASSERT(util::IsAligned(offset, static_cast(m_verification_block_size))); + AMS_ASSERT(util::IsAligned(size, static_cast(m_verification_block_size))); switch (op_id) { case fs::OperationId::FillZero: { /* Clear should only be called for save data. */ - AMS_ASSERT(this->storage_type == fs::StorageType_SaveData); + AMS_ASSERT(m_storage_type == fs::StorageType_SaveData); /* Validate the range. */ s64 data_size = 0; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(0 <= offset && offset <= data_size, fs::ResultInvalidOffset()); /* Determine the extents to clear. */ - const auto sign_offset = (offset >> this->verification_block_order) * HashSize; - const auto sign_size = (std::min(size, data_size - offset) >> this->verification_block_order) * HashSize; + const auto sign_offset = (offset >> m_verification_block_order) * HashSize; + const auto sign_size = (std::min(size, data_size - offset) >> m_verification_block_order) * HashSize; /* Allocate a work buffer. */ - const auto buf_size = static_cast(std::min(sign_size, static_cast(1) << (this->upper_layer_verification_block_order + 2))); + const auto buf_size = static_cast(std::min(sign_size, static_cast(1) << (m_upper_layer_verification_block_order + 2))); std::unique_ptr buf = fs::impl::MakeUnique(buf_size); R_UNLESS(buf != nullptr, fs::ResultAllocationFailureInIntegrityVerificationStorageA()); @@ -284,7 +284,7 @@ namespace ams::fssystem::save { while (remaining_size > 0) { const auto cur_size = static_cast(std::min(remaining_size, static_cast(buf_size))); - R_TRY(this->hash_storage.Write(sign_offset + sign_size - remaining_size, buf.get(), cur_size)); + R_TRY(m_hash_storage.Write(sign_offset + sign_size - remaining_size, buf.get(), cur_size)); remaining_size -= cur_size; } @@ -293,23 +293,23 @@ namespace ams::fssystem::save { case fs::OperationId::DestroySignature: { /* Clear Signature should only be called for save data. */ - AMS_ASSERT(this->storage_type == fs::StorageType_SaveData); + AMS_ASSERT(m_storage_type == fs::StorageType_SaveData); /* Validate the range. */ s64 data_size = 0; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(0 <= offset && offset <= data_size, fs::ResultInvalidOffset()); /* Determine the extents to clear the signature for. */ - const auto sign_offset = (offset >> this->verification_block_order) * HashSize; - const auto sign_size = (std::min(size, data_size - offset) >> this->verification_block_order) * HashSize; + const auto sign_offset = (offset >> m_verification_block_order) * HashSize; + const auto sign_size = (std::min(size, data_size - offset) >> m_verification_block_order) * HashSize; /* Allocate a work buffer. */ std::unique_ptr buf = fs::impl::MakeUnique(sign_size); R_UNLESS(buf != nullptr, fs::ResultAllocationFailureInIntegrityVerificationStorageB()); /* Read the existing signature. */ - R_TRY(this->hash_storage.Read(sign_offset, buf.get(), sign_size)); + R_TRY(m_hash_storage.Read(sign_offset, buf.get(), sign_size)); /* Clear the signature. */ /* This sets all bytes to FF, with the verification bit cleared. */ @@ -318,25 +318,25 @@ namespace ams::fssystem::save { } /* Write the cleared signature. */ - return this->hash_storage.Write(sign_offset, buf.get(), sign_size); + return m_hash_storage.Write(sign_offset, buf.get(), sign_size); } case fs::OperationId::Invalidate: { /* Only allow cache invalidation for RomFs. */ - R_UNLESS(this->storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInIntegrityVerificationStorageB()); + R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInIntegrityVerificationStorageB()); /* Validate the range. */ s64 data_size = 0; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(0 <= offset && offset <= data_size, fs::ResultInvalidOffset()); /* Determine the extents to invalidate. */ - const auto sign_offset = (offset >> this->verification_block_order) * HashSize; - const auto sign_size = (std::min(size, data_size - offset) >> this->verification_block_order) * HashSize; + const auto sign_offset = (offset >> m_verification_block_order) * HashSize; + const auto sign_size = (std::min(size, data_size - offset) >> m_verification_block_order) * HashSize; /* Operate on our storages. */ - R_TRY(this->hash_storage.OperateRange(dst, dst_size, op_id, sign_offset, sign_size, src, src_size)); - R_TRY(this->data_storage.OperateRange(dst, dst_size, op_id, sign_offset, sign_size, src, src_size)); + R_TRY(m_hash_storage.OperateRange(dst, dst_size, op_id, sign_offset, sign_size, src, src_size)); + R_TRY(m_data_storage.OperateRange(dst, dst_size, op_id, sign_offset, sign_size, src, src_size)); return ResultSuccess(); } @@ -344,14 +344,14 @@ namespace ams::fssystem::save { { /* Validate the range. */ s64 data_size = 0; - R_TRY(this->data_storage.GetSize(std::addressof(data_size))); + R_TRY(m_data_storage.GetSize(std::addressof(data_size))); R_UNLESS(0 <= offset && offset <= data_size, fs::ResultInvalidOffset()); /* Determine the real size to query. */ const auto actual_size = std::min(size, data_size - offset); /* Query the data storage. */ - R_TRY(this->data_storage.OperateRange(dst, dst_size, op_id, offset, actual_size, src, src_size)); + R_TRY(m_data_storage.OperateRange(dst, dst_size, op_id, offset, actual_size, src, src_size)); return ResultSuccess(); } @@ -366,8 +366,8 @@ namespace ams::fssystem::save { sha.Initialize(); /* If calculating for save data, hash the salt. */ - if (this->storage_type == fs::StorageType_SaveData) { - sha.Update(this->salt.value, sizeof(this->salt)); + if (m_storage_type == fs::StorageType_SaveData) { + sha.Update(m_salt.value, sizeof(m_salt)); } /* Update with the buffer and get the hash. */ @@ -375,7 +375,7 @@ namespace ams::fssystem::save { sha.GetHash(out, sizeof(*out)); /* Set the validation bit, if the hash is for save data. */ - if (this->storage_type == fs::StorageType_SaveData) { + if (m_storage_type == fs::StorageType_SaveData) { SetValidationBit(out); } } @@ -383,12 +383,12 @@ namespace ams::fssystem::save { Result IntegrityVerificationStorage::ReadBlockSignature(void *dst, size_t dst_size, s64 offset, size_t size) { /* Validate preconditions. */ AMS_ASSERT(dst != nullptr); - AMS_ASSERT(util::IsAligned(offset, static_cast(this->verification_block_size))); - AMS_ASSERT(util::IsAligned(size, static_cast(this->verification_block_size))); + AMS_ASSERT(util::IsAligned(offset, static_cast(m_verification_block_size))); + AMS_ASSERT(util::IsAligned(size, static_cast(m_verification_block_size))); /* Determine where to read the signature. */ - const s64 sign_offset = (offset >> this->verification_block_order) * HashSize; - const auto sign_size = static_cast((size >> this->verification_block_order) * HashSize); + const s64 sign_offset = (offset >> m_verification_block_order) * HashSize; + const auto sign_size = static_cast((size >> m_verification_block_order) * HashSize); AMS_ASSERT(dst_size >= sign_size); AMS_UNUSED(dst_size); @@ -397,13 +397,13 @@ namespace ams::fssystem::save { /* Validate that we can read the signature. */ s64 hash_size; - R_TRY(this->hash_storage.GetSize(std::addressof(hash_size))); + R_TRY(m_hash_storage.GetSize(std::addressof(hash_size))); const bool range_valid = static_cast(sign_offset + sign_size) <= hash_size; AMS_ASSERT(range_valid); R_UNLESS(range_valid, fs::ResultOutOfRange()); /* Read the signature. */ - R_TRY(this->hash_storage.Read(sign_offset, dst, sign_size)); + R_TRY(m_hash_storage.Read(sign_offset, dst, sign_size)); /* We succeeded. */ clear_guard.Cancel(); @@ -413,16 +413,16 @@ namespace ams::fssystem::save { Result IntegrityVerificationStorage::WriteBlockSignature(const void *src, size_t src_size, s64 offset, size_t size) { /* Validate preconditions. */ AMS_ASSERT(src != nullptr); - AMS_ASSERT(util::IsAligned(offset, static_cast(this->verification_block_size))); + AMS_ASSERT(util::IsAligned(offset, static_cast(m_verification_block_size))); /* Determine where to write the signature. */ - const s64 sign_offset = (offset >> this->verification_block_order) * HashSize; - const auto sign_size = static_cast((size >> this->verification_block_order) * HashSize); + const s64 sign_offset = (offset >> m_verification_block_order) * HashSize; + const auto sign_size = static_cast((size >> m_verification_block_order) * HashSize); AMS_ASSERT(src_size >= sign_size); AMS_UNUSED(src_size); /* Write the signature. */ - R_TRY(this->hash_storage.Write(sign_offset, src, sign_size)); + R_TRY(m_hash_storage.Write(sign_offset, src, sign_size)); /* We succeeded. */ return ResultSuccess(); @@ -437,7 +437,7 @@ namespace ams::fssystem::save { auto &cmp_hash = *hash; /* If save data, check if the data is uninitialized. */ - if (this->storage_type == fs::StorageType_SaveData) { + if (m_storage_type == fs::StorageType_SaveData) { bool is_cleared = false; R_TRY(this->IsCleared(std::addressof(is_cleared), cmp_hash)); R_UNLESS(!is_cleared, fs::ResultClearedRealDataVerificationFailed()); @@ -453,7 +453,7 @@ namespace ams::fssystem::save { std::memset(std::addressof(cmp_hash), 0, sizeof(cmp_hash)); /* Return the appropriate result. */ - if (this->is_real_data) { + if (m_is_real_data) { return fs::ResultUnclearedRealDataVerificationFailed(); } else { return fs::ResultNonRealDataVerificationFailed(); @@ -466,7 +466,7 @@ namespace ams::fssystem::save { Result IntegrityVerificationStorage::IsCleared(bool *is_cleared, const BlockHash &hash) { /* Validate preconditions. */ AMS_ASSERT(is_cleared != nullptr); - AMS_ASSERT(this->storage_type == fs::StorageType_SaveData); + AMS_ASSERT(m_storage_type == fs::StorageType_SaveData); /* Default to uncleared. */ *is_cleared = false; diff --git a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.cpp b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.cpp index 3017400a0..a452ce875 100644 --- a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.cpp +++ b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.cpp @@ -21,30 +21,30 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { void InterruptEventHandler::Initialize(DriverImpl *drv, os::InterruptName intr, int ctlr) { /* Set fields. */ - this->driver = drv; - this->interrupt_name = intr; - this->controller_number = ctlr; + m_driver = drv; + m_interrupt_name = intr; + m_controller_number = ctlr; /* Initialize interrupt event. */ - os::InitializeInterruptEvent(std::addressof(this->interrupt_event), intr, os::EventClearMode_ManualClear); + os::InitializeInterruptEvent(std::addressof(m_interrupt_event), intr, os::EventClearMode_ManualClear); /* Initialize base. */ - IEventHandler::Initialize(std::addressof(this->interrupt_event)); + IEventHandler::Initialize(std::addressof(m_interrupt_event)); } void InterruptEventHandler::HandleEvent() { /* Lock the driver's interrupt mutex. */ - std::scoped_lock lk(this->driver->interrupt_control_mutex); + std::scoped_lock lk(m_driver->m_interrupt_control_mutex); /* Check each pad. */ bool found = false; - for (auto it = this->driver->interrupt_pad_list.begin(); !found && it != this->driver->interrupt_pad_list.end(); ++it) { + for (auto it = m_driver->m_interrupt_pad_list.begin(); !found && it != m_driver->m_interrupt_pad_list.end(); ++it) { found = this->CheckAndHandleInterrupt(*it); } /* If we didn't find a pad, clear the interrupt event. */ if (!found) { - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); } } @@ -53,13 +53,13 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = static_cast(pad.GetPadNumber()); /* Check if the pad matches our controller number. */ - if (this->controller_number != ConvertInternalGpioPadNumberToController(pad_number)) { + if (m_controller_number != ConvertInternalGpioPadNumberToController(pad_number)) { return false; } /* Get the addresses of INT_STA, INT_ENB. */ - const uintptr_t sta_address = GetGpioRegisterAddress(this->driver->gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number); - const uintptr_t enb_address = GetGpioRegisterAddress(this->driver->gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number); + const uintptr_t sta_address = GetGpioRegisterAddress(m_driver->m_gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number); + const uintptr_t enb_address = GetGpioRegisterAddress(m_driver->m_gpio_virtual_address, GpioRegisterType_GPIO_INT_STA, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); /* Check if both STA and ENB are set. */ @@ -73,10 +73,10 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { /* Disable the interrupt on the pad. */ pad.SetInterruptEnabled(false); - this->driver->RemoveInterruptPad(std::addressof(pad)); + m_driver->RemoveInterruptPad(std::addressof(pad)); /* Clear the interrupt event. */ - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); /* Signal the pad's bound event. */ pad.SignalInterruptBoundEvent(); @@ -84,15 +84,15 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { return true; } - DriverImpl::DriverImpl(dd::PhysicalAddress reg_paddr, size_t size) : gpio_physical_address(reg_paddr), gpio_virtual_address(), suspend_handler(this), interrupt_pad_list(), interrupt_control_mutex() { + DriverImpl::DriverImpl(dd::PhysicalAddress reg_paddr, size_t size) : m_gpio_physical_address(reg_paddr), m_gpio_virtual_address(), m_suspend_handler(this), m_interrupt_pad_list(), m_interrupt_control_mutex() { /* Get the corresponding virtual address for our physical address. */ - this->gpio_virtual_address = dd::QueryIoMapping(reg_paddr, size); - AMS_ABORT_UNLESS(this->gpio_virtual_address != 0); + m_gpio_virtual_address = dd::QueryIoMapping(reg_paddr, size); + AMS_ABORT_UNLESS(m_gpio_virtual_address != 0); } void DriverImpl::InitializeDriver() { /* Initialize our suspend handler. */ - this->suspend_handler.Initialize(this->gpio_virtual_address); + m_suspend_handler.Initialize(m_gpio_virtual_address); } void DriverImpl::FinalizeDriver() { @@ -107,7 +107,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Configure the pad as GPIO by modifying the appropriate bit in CNF. */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_CNF, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_CNF, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); SetMaskedBit(pad_address, pad_index, 1); @@ -134,7 +134,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Get the pad direction by reading the appropriate bit in OE */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); if (reg::Read(pad_address, 1u << pad_index) != 0) { @@ -155,7 +155,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Configure the pad direction by modifying the appropriate bit in OE */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); SetMaskedBit(pad_address, pad_index, direction); @@ -174,7 +174,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Get the pad value by reading the appropriate bit in IN */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); if (reg::Read(pad_address, 1u << pad_index) != 0) { @@ -194,7 +194,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Configure the pad value by modifying the appropriate bit in IN */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); SetMaskedBit(pad_address, pad_index, value); @@ -213,7 +213,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Get the pad mode by reading the appropriate bits in INT_LVL */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); switch ((reg::Read(pad_address) >> pad_index) & InternalInterruptMode_Mask) { @@ -236,7 +236,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { const InternalGpioPadNumber pad_number = pad->GetPadNumber(); /* Configure the pad mode by modifying the appropriate bits in INT_LVL */ - const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number); + const uintptr_t pad_address = GetGpioRegisterAddress(m_gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number); const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number); switch (mode) { diff --git a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.hpp b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.hpp index 72a92fef0..e67016b1e 100644 --- a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.hpp +++ b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_driver_impl.hpp @@ -26,14 +26,14 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { class InterruptEventHandler : public ddsf::IEventHandler { private: - DriverImpl *driver; - os::InterruptName interrupt_name; - os::InterruptEventType interrupt_event; - int controller_number; + DriverImpl *m_driver; + os::InterruptName m_interrupt_name; + os::InterruptEventType m_interrupt_event; + int m_controller_number; private: bool CheckAndHandleInterrupt(TegraPad &pad); public: - InterruptEventHandler() : IEventHandler(), driver(nullptr), interrupt_name(), interrupt_event(), controller_number() { /* ... */ } + InterruptEventHandler() : IEventHandler(), m_driver(nullptr), m_interrupt_name(), m_interrupt_event(), m_controller_number() { /* ... */ } void Initialize(DriverImpl *drv, os::InterruptName intr, int ctlr); @@ -46,11 +46,11 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo::nx::impl::DriverImpl, ::ams::gpio::driver::IGpioDriver); friend class InterruptEventHandler; private: - dd::PhysicalAddress gpio_physical_address; - uintptr_t gpio_virtual_address; - SuspendHandler suspend_handler; - TegraPad::InterruptList interrupt_pad_list; - mutable os::SdkMutex interrupt_control_mutex; + dd::PhysicalAddress m_gpio_physical_address; + uintptr_t m_gpio_virtual_address; + SuspendHandler m_suspend_handler; + TegraPad::InterruptList m_interrupt_pad_list; + mutable os::SdkMutex m_interrupt_control_mutex; public: DriverImpl(dd::PhysicalAddress reg_paddr, size_t size); @@ -76,7 +76,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const override { AMS_UNUSED(pad); - return this->interrupt_control_mutex; + return m_interrupt_control_mutex; } virtual Result GetDebounceEnabled(bool *out, Pad *pad) const override; @@ -114,14 +114,14 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { void AddInterruptPad(TegraPad *pad) { AMS_ASSERT(pad != nullptr); if (!pad->IsLinkedToInterruptBoundPadList()) { - this->interrupt_pad_list.push_back(*pad); + m_interrupt_pad_list.push_back(*pad); } } void RemoveInterruptPad(TegraPad *pad) { AMS_ASSERT(pad != nullptr); if (pad->IsLinkedToInterruptBoundPadList()) { - this->interrupt_pad_list.erase(this->interrupt_pad_list.iterator_to(*pad)); + m_interrupt_pad_list.erase(m_interrupt_pad_list.iterator_to(*pad)); } } }; diff --git a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.cpp b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.cpp index b8ca333d7..d6fc297e6 100644 --- a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.cpp +++ b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.cpp @@ -20,7 +20,7 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { void SuspendHandler::Initialize(uintptr_t gpio_vaddr) { /* Set our gpio virtual address. */ - this->gpio_virtual_address = gpio_vaddr; + m_gpio_virtual_address = gpio_vaddr; /* Ensure that we can use the wec library. */ ams::wec::Initialize(); diff --git a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.hpp b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.hpp index eb8f00115..09faf34ec 100644 --- a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.hpp +++ b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_suspend_handler.hpp @@ -54,21 +54,21 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { } }; private: - ddsf::IDriver &driver; - uintptr_t gpio_virtual_address; - RegisterValues register_values[GpioPadPort_Count]; - ValuesForSleepState values_for_sleep_state[GpioPadPort_Count]; + ddsf::IDriver &m_driver; + uintptr_t m_gpio_virtual_address; + RegisterValues m_register_values[GpioPadPort_Count]; + ValuesForSleepState m_values_for_sleep_state[GpioPadPort_Count]; private: uintptr_t GetGpioVirtualAddress() const { - AMS_ASSERT(this->gpio_virtual_address != 0); - return this->gpio_virtual_address; + AMS_ASSERT(m_gpio_virtual_address != 0); + return m_gpio_virtual_address; } public: - explicit SuspendHandler(ddsf::IDriver *drv) : driver(*drv), gpio_virtual_address(0) { - for (auto &rv : this->register_values) { + explicit SuspendHandler(ddsf::IDriver *drv) : m_driver(*drv), m_gpio_virtual_address(0) { + for (auto &rv : m_register_values) { rv.Reset(); } - for (auto &v : this->values_for_sleep_state) { + for (auto &v : m_values_for_sleep_state) { v.Reset(); } } diff --git a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_tegra_pad.hpp b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_tegra_pad.hpp index 735c9f0fe..51d1a72a3 100644 --- a/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_tegra_pad.hpp +++ b/libraries/libstratosphere/source/gpio/driver/board/nintendo/nx/impl/gpio_tegra_pad.hpp @@ -351,26 +351,26 @@ namespace ams::gpio::driver::board::nintendo::nx::impl { private: using Base = ::ams::gpio::driver::Pad; private: - util::IntrusiveListNode interrupt_list_node; - PadInfo info; - PadStatus status; + util::IntrusiveListNode m_interrupt_list_node; + PadInfo m_info; + PadStatus m_status; public: - using InterruptListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::interrupt_list_node>; + using InterruptListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::m_interrupt_list_node>; using InterruptList = typename InterruptListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; public: - TegraPad() : Pad(), interrupt_list_node(), info(), status() { /* ... */ } + TegraPad() : Pad(), m_interrupt_list_node(), m_info(), m_status() { /* ... */ } - const PadInfo &GetInfo() const { return this->info; } - PadStatus &GetStatus() { return this->status; } + const PadInfo &GetInfo() const { return m_info; } + PadStatus &GetStatus() { return m_status; } void SetParameters(int pad, const PadInfo &i) { Base::SetPadNumber(pad); - this->info = i; + m_info = i; } bool IsLinkedToInterruptBoundPadList() const { - return this->interrupt_list_node.IsLinked(); + return m_interrupt_list_node.IsLinked(); } }; diff --git a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp index 51ebadb84..47b686f9b 100644 --- a/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp +++ b/libraries/libstratosphere/source/gpio/driver/impl/gpio_pad_session_impl.cpp @@ -73,8 +73,8 @@ namespace ams::gpio::driver::impl { auto ev_guard = SCOPE_GUARD { os::DestroySystemEvent(event); }; /* Attach the event to our holder. */ - this->event_holder.AttachEvent(event); - auto hl_guard = SCOPE_GUARD { this->event_holder.DetachEvent(); }; + m_event_holder.AttachEvent(event); + auto hl_guard = SCOPE_GUARD { m_event_holder.DetachEvent(); }; /* Update interrupt needed. */ R_TRY(this->UpdateDriverInterruptEnabled()); @@ -97,7 +97,7 @@ namespace ams::gpio::driver::impl { } /* Detach and destroy the event */ - os::DestroySystemEvent(this->event_holder.DetachEvent()); + os::DestroySystemEvent(m_event_holder.DetachEvent()); /* Update interrupt needed. */ R_ABORT_UNLESS(this->UpdateDriverInterruptEnabled()); @@ -143,7 +143,7 @@ namespace ams::gpio::driver::impl { AMS_ASSERT(driver.GetInterruptControlMutex(pad).IsLockedByCurrentThread()); AMS_UNUSED(pad, driver); - if (auto *event = this->event_holder.GetSystemEvent(); event != nullptr) { + if (auto *event = m_event_holder.GetSystemEvent(); event != nullptr) { os::SignalSystemEvent(event); } } diff --git a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp index 069f5a8e7..ce7d4815b 100644 --- a/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp +++ b/libraries/libstratosphere/source/gpio/gpio_remote_pad_session_impl.hpp @@ -20,82 +20,82 @@ namespace ams::gpio { class RemotePadSessionImpl { private: - ::GpioPadSession srv; + ::GpioPadSession m_srv; public: - RemotePadSessionImpl(::GpioPadSession &p) : srv(p) { /* ... */ } + RemotePadSessionImpl(::GpioPadSession &p) : m_srv(p) { /* ... */ } - ~RemotePadSessionImpl() { ::gpioPadClose(std::addressof(this->srv)); } + ~RemotePadSessionImpl() { ::gpioPadClose(std::addressof(m_srv)); } public: /* Actual commands. */ Result SetDirection(gpio::Direction direction) { - return ::gpioPadSetDirection(std::addressof(this->srv), static_cast<::GpioDirection>(static_cast(direction))); + return ::gpioPadSetDirection(std::addressof(m_srv), static_cast<::GpioDirection>(static_cast(direction))); } Result GetDirection(ams::sf::Out out) { static_assert(sizeof(gpio::Direction) == sizeof(::GpioDirection)); - return ::gpioPadGetDirection(std::addressof(this->srv), reinterpret_cast<::GpioDirection *>(out.GetPointer())); + return ::gpioPadGetDirection(std::addressof(m_srv), reinterpret_cast<::GpioDirection *>(out.GetPointer())); } Result SetInterruptMode(gpio::InterruptMode mode) { - return ::gpioPadSetInterruptMode(std::addressof(this->srv), static_cast<::GpioInterruptMode>(static_cast(mode))); + return ::gpioPadSetInterruptMode(std::addressof(m_srv), static_cast<::GpioInterruptMode>(static_cast(mode))); } Result GetInterruptMode(ams::sf::Out out) { static_assert(sizeof(gpio::InterruptMode) == sizeof(::GpioInterruptMode)); - return ::gpioPadGetInterruptMode(std::addressof(this->srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer())); + return ::gpioPadGetInterruptMode(std::addressof(m_srv), reinterpret_cast<::GpioInterruptMode *>(out.GetPointer())); } Result SetInterruptEnable(bool enable) { - return ::gpioPadSetInterruptEnable(std::addressof(this->srv), enable); + return ::gpioPadSetInterruptEnable(std::addressof(m_srv), enable); } Result GetInterruptEnable(ams::sf::Out out) { - return ::gpioPadGetInterruptEnable(std::addressof(this->srv), out.GetPointer()); + return ::gpioPadGetInterruptEnable(std::addressof(m_srv), out.GetPointer()); } Result GetInterruptStatus(ams::sf::Out out) { static_assert(sizeof(gpio::InterruptStatus) == sizeof(::GpioInterruptStatus)); - return ::gpioPadGetInterruptStatus(std::addressof(this->srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer())); + return ::gpioPadGetInterruptStatus(std::addressof(m_srv), reinterpret_cast<::GpioInterruptStatus *>(out.GetPointer())); } Result ClearInterruptStatus() { - return ::gpioPadClearInterruptStatus(std::addressof(this->srv)); + return ::gpioPadClearInterruptStatus(std::addressof(m_srv)); } Result SetValue(gpio::GpioValue value) { - return ::gpioPadSetValue(std::addressof(this->srv), static_cast<::GpioValue>(static_cast(value))); + return ::gpioPadSetValue(std::addressof(m_srv), static_cast<::GpioValue>(static_cast(value))); } Result GetValue(ams::sf::Out out) { static_assert(sizeof(gpio::GpioValue) == sizeof(::GpioValue)); - return ::gpioPadGetValue(std::addressof(this->srv), reinterpret_cast<::GpioValue *>(out.GetPointer())); + return ::gpioPadGetValue(std::addressof(m_srv), reinterpret_cast<::GpioValue *>(out.GetPointer())); } Result BindInterrupt(ams::sf::OutCopyHandle out) { ::Event ev; - R_TRY(::gpioPadBindInterrupt(std::addressof(this->srv), std::addressof(ev))); + R_TRY(::gpioPadBindInterrupt(std::addressof(m_srv), std::addressof(ev))); out.SetValue(ev.revent, true); return ResultSuccess(); } Result UnbindInterrupt() { - return ::gpioPadUnbindInterrupt(std::addressof(this->srv)); + return ::gpioPadUnbindInterrupt(std::addressof(m_srv)); } Result SetDebounceEnabled(bool enable) { - return ::gpioPadSetDebounceEnabled(std::addressof(this->srv), enable); + return ::gpioPadSetDebounceEnabled(std::addressof(m_srv), enable); } Result GetDebounceEnabled(ams::sf::Out out) { - return ::gpioPadGetDebounceEnabled(std::addressof(this->srv), out.GetPointer()); + return ::gpioPadGetDebounceEnabled(std::addressof(m_srv), out.GetPointer()); } Result SetDebounceTime(s32 ms) { - return ::gpioPadSetDebounceTime(std::addressof(this->srv), ms); + return ::gpioPadSetDebounceTime(std::addressof(m_srv), ms); } Result GetDebounceTime(ams::sf::Out out) { - return ::gpioPadGetDebounceTime(std::addressof(this->srv), out.GetPointer()); + return ::gpioPadGetDebounceTime(std::addressof(m_srv), out.GetPointer()); } Result SetValueForSleepState(gpio::GpioValue value) { diff --git a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp index f41aff5da..0622a4d86 100644 --- a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.cpp @@ -19,12 +19,12 @@ namespace ams::gpio::server { ManagerImpl::ManagerImpl() { - this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None); - this->pad_allocator.Attach(this->heap_handle); + m_heap_handle = lmem::CreateExpHeap(m_heap_buffer, sizeof(m_heap_buffer), lmem::CreateOption_None); + m_pad_allocator.Attach(m_heap_handle); } ManagerImpl::~ManagerImpl() { - lmem::DestroyExpHeap(this->heap_handle); + lmem::DestroyExpHeap(m_heap_handle); } Result ManagerImpl::OpenSessionForDev(ams::sf::Out> out, s32 pad_descriptor) { @@ -69,7 +69,7 @@ namespace ams::gpio::server { Result ManagerImpl::OpenSession2(ams::sf::Out> out, DeviceCode device_code, ddsf::AccessMode access_mode) { /* Allocate a session. */ - auto session = Factory::CreateSharedEmplaced(std::addressof(this->pad_allocator), this); + auto session = Factory::CreateSharedEmplaced(std::addressof(m_pad_allocator), this); /* Open the session. */ R_TRY(session.GetImpl().OpenSession(device_code, access_mode)); diff --git a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.hpp b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.hpp index 5ca9cf5d4..be5d862ab 100644 --- a/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.hpp +++ b/libraries/libstratosphere/source/gpio/server/gpio_server_manager_impl.hpp @@ -24,9 +24,9 @@ namespace ams::gpio::server { using Allocator = ams::sf::ExpHeapAllocator; using Factory = ams::sf::ObjectFactory; private: - lmem::HeapHandle heap_handle; - Allocator pad_allocator; - u8 heap_buffer[12_KB]; + lmem::HeapHandle m_heap_handle; + Allocator m_pad_allocator; + u8 m_heap_buffer[12_KB]; public: ManagerImpl(); diff --git a/libraries/libstratosphere/source/gpio/server/gpio_server_pad_session_impl.hpp b/libraries/libstratosphere/source/gpio/server/gpio_server_pad_session_impl.hpp index fe0989d48..fee914e1c 100644 --- a/libraries/libstratosphere/source/gpio/server/gpio_server_pad_session_impl.hpp +++ b/libraries/libstratosphere/source/gpio/server/gpio_server_pad_session_impl.hpp @@ -22,54 +22,54 @@ namespace ams::gpio::server { class PadSessionImpl { private: - ManagerImpl *parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ - gpio::driver::GpioPadSession internal_pad_session; - bool has_session; - os::SystemEvent system_event; + ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ + gpio::driver::GpioPadSession m_internal_pad_session; + bool m_has_session; + os::SystemEvent m_system_event; public: - explicit PadSessionImpl(ManagerImpl *p) : parent(p), has_session(false) { /* ... */ } + explicit PadSessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ } ~PadSessionImpl() { - if (this->has_session) { - gpio::driver::CloseSession(std::addressof(this->internal_pad_session)); + if (m_has_session) { + gpio::driver::CloseSession(std::addressof(m_internal_pad_session)); } } Result OpenSession(DeviceCode device_code, ddsf::AccessMode access_mode) { - AMS_ABORT_UNLESS(!this->has_session); + AMS_ABORT_UNLESS(!m_has_session); - R_TRY(gpio::driver::OpenSession(std::addressof(this->internal_pad_session), device_code, access_mode)); - this->has_session = true; + R_TRY(gpio::driver::OpenSession(std::addressof(m_internal_pad_session), device_code, access_mode)); + m_has_session = true; return ResultSuccess(); } public: /* Actual commands. */ Result SetDirection(gpio::Direction direction) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* Validate the direction. */ R_UNLESS((direction == Direction_Input || direction == Direction_Output), gpio::ResultInvalidArgument()); /* Invoke the driver library. */ - R_TRY(gpio::driver::SetDirection(std::addressof(this->internal_pad_session), direction)); + R_TRY(gpio::driver::SetDirection(std::addressof(m_internal_pad_session), direction)); return ResultSuccess(); } Result GetDirection(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* Invoke the driver library. */ - R_TRY(gpio::driver::GetDirection(out.GetPointer(), std::addressof(this->internal_pad_session))); + R_TRY(gpio::driver::GetDirection(out.GetPointer(), std::addressof(m_internal_pad_session))); return ResultSuccess(); } Result SetInterruptMode(gpio::InterruptMode mode) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(mode); @@ -78,7 +78,7 @@ namespace ams::gpio::server { Result GetInterruptMode(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -87,7 +87,7 @@ namespace ams::gpio::server { Result SetInterruptEnable(bool enable) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(enable); @@ -96,7 +96,7 @@ namespace ams::gpio::server { Result GetInterruptEnable(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -105,7 +105,7 @@ namespace ams::gpio::server { Result GetInterruptStatus(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -114,7 +114,7 @@ namespace ams::gpio::server { Result ClearInterruptStatus() { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_ABORT(); @@ -122,30 +122,30 @@ namespace ams::gpio::server { Result SetValue(gpio::GpioValue value) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* Validate the value. */ R_UNLESS((value == GpioValue_Low || value == GpioValue_High), gpio::ResultInvalidArgument()); /* Invoke the driver library. */ - R_TRY(gpio::driver::SetValue(std::addressof(this->internal_pad_session), value)); + R_TRY(gpio::driver::SetValue(std::addressof(m_internal_pad_session), value)); return ResultSuccess(); } Result GetValue(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* Invoke the driver library. */ - R_TRY(gpio::driver::GetValue(out.GetPointer(), std::addressof(this->internal_pad_session))); + R_TRY(gpio::driver::GetValue(out.GetPointer(), std::addressof(m_internal_pad_session))); return ResultSuccess(); } Result BindInterrupt(ams::sf::OutCopyHandle out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -154,7 +154,7 @@ namespace ams::gpio::server { Result UnbindInterrupt() { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_ABORT(); @@ -162,7 +162,7 @@ namespace ams::gpio::server { Result SetDebounceEnabled(bool enable) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(enable); @@ -171,7 +171,7 @@ namespace ams::gpio::server { Result GetDebounceEnabled(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -180,7 +180,7 @@ namespace ams::gpio::server { Result SetDebounceTime(s32 ms) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(ms); @@ -189,7 +189,7 @@ namespace ams::gpio::server { Result GetDebounceTime(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); @@ -198,7 +198,7 @@ namespace ams::gpio::server { Result SetValueForSleepState(gpio::GpioValue value) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(value); @@ -207,7 +207,7 @@ namespace ams::gpio::server { Result GetValueForSleepState(ams::sf::Out out) { /* Validate our state. */ - AMS_ASSERT(this->has_session); + AMS_ASSERT(m_has_session); /* TODO */ AMS_UNUSED(out); diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp index fa2defd00..ebf9bb1db 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp @@ -1301,7 +1301,7 @@ namespace ams::htcfs { Header request, response; /* Create header for the request. */ - m_header_factory.MakeWriteFileHeader(std::addressof(request), buffer_size, handle, option.value, offset); + m_header_factory.MakeWriteFileHeader(std::addressof(request), buffer_size, handle, option._value, offset); /* Send the request to the host. */ R_TRY(this->SendRequest(request, buffer, buffer_size)); @@ -1335,7 +1335,7 @@ namespace ams::htcfs { Header request, response; /* Create header for the request. */ - m_header_factory.MakeWriteFileLargeHeader(std::addressof(request), handle, option.value, offset, buffer_size, DataChannelId); + m_header_factory.MakeWriteFileLargeHeader(std::addressof(request), handle, option._value, offset, buffer_size, DataChannelId); /* Send the request to the host. */ R_TRY(this->SendRequest(request)); diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp index 4b2a5346b..39de2fd41 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.cpp @@ -55,56 +55,56 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } void I2cBusAccessor::Initialize(dd::PhysicalAddress reg_paddr, size_t reg_size, os::InterruptName intr, bool pb, SpeedMode sm) { - AMS_ASSERT(this->state == State::NotInitialized); + AMS_ASSERT(m_state == State::NotInitialized); - this->is_power_bus = pb; - this->speed_mode = sm; - this->interrupt_name = intr; - this->registers_phys_addr = reg_paddr; - this->registers_size = reg_size; - this->state = State::Initializing; + m_is_power_bus = pb; + m_speed_mode = sm; + m_interrupt_name = intr; + m_registers_phys_addr = reg_paddr; + m_registers_size = reg_size; + m_state = State::Initializing; } void I2cBusAccessor::RegisterDeviceCode(DeviceCode dc) { - AMS_ASSERT(this->state == State::Initializing); + AMS_ASSERT(m_state == State::Initializing); - this->device_code = dc; + m_device_code = dc; } void I2cBusAccessor::InitializeDriver() { - AMS_ASSERT(this->state == State::Initializing); + AMS_ASSERT(m_state == State::Initializing); - this->registers = reinterpret_cast(dd::QueryIoMapping(this->registers_phys_addr, this->registers_size)); - AMS_ABORT_UNLESS(this->registers != nullptr); + m_registers = reinterpret_cast(dd::QueryIoMapping(m_registers_phys_addr, m_registers_size)); + AMS_ABORT_UNLESS(m_registers != nullptr); - this->state = State::Initialized; + m_state = State::Initialized; } void I2cBusAccessor::FinalizeDriver() { - AMS_ASSERT(this->state == State::Initialized); - this->state = State::Initializing; + AMS_ASSERT(m_state == State::Initialized); + m_state = State::Initializing; } Result I2cBusAccessor::InitializeDevice(I2cDeviceProperty *device) { /* Check that the device is valid. */ AMS_ASSERT(device != nullptr); - AMS_ASSERT(this->state == State::Initialized); + AMS_ASSERT(m_state == State::Initialized); AMS_UNUSED(device); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* Increment our user count -- if we're already open, we're done. */ - AMS_ASSERT(this->user_count >= 0); - ++this->user_count; - R_SUCCEED_IF(this->user_count > 1); + AMS_ASSERT(m_user_count >= 0); + ++m_user_count; + R_SUCCEED_IF(m_user_count > 1); /* Initialize our interrupt event. */ - os::InitializeInterruptEvent(std::addressof(this->interrupt_event), this->interrupt_name, os::EventClearMode_ManualClear); - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::InitializeInterruptEvent(std::addressof(m_interrupt_event), m_interrupt_name, os::EventClearMode_ManualClear); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); /* If we're not power bus, perform power management init. */ - if (!this->is_power_bus) { + if (!m_is_power_bus) { /* Initialize regulator library. */ regulator::Initialize(); @@ -112,9 +112,9 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { R_TRY(this->TryOpenRegulatorSession()); /* If we have a regulator session, set voltage to 2.9V. */ - if (this->has_regulator_session) { + if (m_has_regulator_session) { /* NOTE: Nintendo does not check the result, here. */ - regulator::SetVoltageValue(std::addressof(this->regulator_session), 2'900'000u); + regulator::SetVoltageValue(std::addressof(m_regulator_session), 2'900'000u); } /* Initialize clock/reset library. */ @@ -125,12 +125,12 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->ExecuteInitialConfig(); /* If we have a regulator session, enable voltage. */ - if (!this->is_power_bus && this->has_regulator_session) { + if (!m_is_power_bus && m_has_regulator_session) { /* Check whether voltage was already enabled. */ - const bool was_enabled = regulator::GetVoltageEnabled(std::addressof(this->regulator_session)); + const bool was_enabled = regulator::GetVoltageEnabled(std::addressof(m_regulator_session)); /* NOTE: Nintendo does not check the result of this call. */ - regulator::SetVoltageEnabled(std::addressof(this->regulator_session), true); + regulator::SetVoltageEnabled(std::addressof(m_regulator_session), true); /* If we enabled voltage, delay to give our enable time to take. */ if (!was_enabled) { @@ -144,35 +144,35 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void I2cBusAccessor::FinalizeDevice(I2cDeviceProperty *device) { /* Check that the device is valid. */ AMS_ASSERT(device != nullptr); - AMS_ASSERT(this->state == State::Initialized); + AMS_ASSERT(m_state == State::Initialized); AMS_UNUSED(device); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* Increment our user count -- if we're not the last user, we're done. */ - AMS_ASSERT(this->user_count > 0); - --this->user_count; - if (this->user_count > 0) { + AMS_ASSERT(m_user_count > 0); + --m_user_count; + if (m_user_count > 0) { return; } /* Finalize our interrupt event. */ - os::FinalizeInterruptEvent(std::addressof(this->interrupt_event)); + os::FinalizeInterruptEvent(std::addressof(m_interrupt_event)); /* If we have a regulator session, disable voltage. */ - if (this->has_regulator_session) { + if (m_has_regulator_session) { /* NOTE: Nintendo does not check the result of this call. */ - regulator::SetVoltageEnabled(std::addressof(this->regulator_session), false); + regulator::SetVoltageEnabled(std::addressof(m_regulator_session), false); } /* Finalize the clock/reset library. */ clkrst::Finalize(); /* If we have a regulator session, close it. */ - if (this->has_regulator_session) { - regulator::CloseSession(std::addressof(this->regulator_session)); - this->has_regulator_session = false; + if (m_has_regulator_session) { + regulator::CloseSession(std::addressof(m_regulator_session)); + m_has_regulator_session = false; } /* Finalize the regulator library. */ @@ -185,10 +185,10 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { AMS_ASSERT(src != nullptr); AMS_ASSERT(src_size > 0); - if (this->is_power_bus) { - AMS_ASSERT(this->state == State::Initialized || this->state == State::Suspended); + if (m_is_power_bus) { + AMS_ASSERT(m_state == State::Initialized || m_state == State::Suspended); } else { - AMS_ASSERT(this->state == State::Initialized); + AMS_ASSERT(m_state == State::Initialized); } /* Send the data. */ @@ -201,10 +201,10 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { AMS_ASSERT(dst != nullptr); AMS_ASSERT(dst_size > 0); - if (this->is_power_bus) { - AMS_ASSERT(this->state == State::Initialized || this->state == State::Suspended); + if (m_is_power_bus) { + AMS_ASSERT(m_state == State::Initialized || m_state == State::Suspended); } else { - AMS_ASSERT(this->state == State::Initialized); + AMS_ASSERT(m_state == State::Initialized); } /* Send the data. */ @@ -213,18 +213,18 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void I2cBusAccessor::SuspendBus() { /* Check that state is valid. */ - AMS_ASSERT(this->state == State::Initialized); + AMS_ASSERT(m_state == State::Initialized); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* If we need to, disable clock/voltage appropriately. */ - if (!this->is_power_bus && this->user_count > 0) { + if (!m_is_power_bus && m_user_count > 0) { /* Disable clock. */ { /* Open a clkrst session. */ clkrst::ClkRstSession clkrst_session; - R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), this->device_code)); + R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), m_device_code)); ON_SCOPE_EXIT { clkrst::CloseSession(std::addressof(clkrst_session)); }; /* Set clock disabled for the session. */ @@ -232,47 +232,47 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Disable voltage. */ - if (this->has_regulator_session) { - regulator::SetVoltageEnabled(std::addressof(this->regulator_session), false); + if (m_has_regulator_session) { + regulator::SetVoltageEnabled(std::addressof(m_regulator_session), false); } } /* Update state. */ - this->state = State::Suspended; + m_state = State::Suspended; } void I2cBusAccessor::SuspendPowerBus() { /* Check that state is valid. */ - AMS_ASSERT(this->state == State::Suspended); + AMS_ASSERT(m_state == State::Suspended); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* If we need to, disable clock/voltage appropriately. */ - if (this->is_power_bus && this->user_count > 0) { + if (m_is_power_bus && m_user_count > 0) { /* Nothing should actually be done here. */ } /* Update state. */ - this->state = State::PowerBusSuspended; + m_state = State::PowerBusSuspended; } void I2cBusAccessor::ResumeBus() { /* Check that state is valid. */ - AMS_ASSERT(this->state == State::Suspended); + AMS_ASSERT(m_state == State::Suspended); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* If we need to, enable clock/voltage appropriately. */ - if (!this->is_power_bus && this->user_count > 0) { + if (!m_is_power_bus && m_user_count > 0) { /* Enable voltage. */ - if (this->has_regulator_session) { + if (m_has_regulator_session) { /* Check whether voltage was already enabled. */ - const bool was_enabled = regulator::GetVoltageEnabled(std::addressof(this->regulator_session)); + const bool was_enabled = regulator::GetVoltageEnabled(std::addressof(m_regulator_session)); /* NOTE: Nintendo does not check the result of this call. */ - regulator::SetVoltageEnabled(std::addressof(this->regulator_session), true); + regulator::SetVoltageEnabled(std::addressof(m_regulator_session), true); /* If we enabled voltage, delay to give our enable time to take. */ if (!was_enabled) { @@ -285,36 +285,36 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Update state. */ - this->state = State::Initialized; + m_state = State::Initialized; } void I2cBusAccessor::ResumePowerBus() { /* Check that state is valid. */ - AMS_ASSERT(this->state == State::PowerBusSuspended); + AMS_ASSERT(m_state == State::PowerBusSuspended); /* Acquire exclusive access. */ - std::scoped_lock lk(this->user_count_mutex); + std::scoped_lock lk(m_user_count_mutex); /* If we need to, enable clock/voltage appropriately. */ - if (this->is_power_bus && this->user_count > 0) { + if (m_is_power_bus && m_user_count > 0) { /* Execute initial config, which will enable clock as relevant. */ this->ExecuteInitialConfig(); } /* Update state. */ - this->state = State::Suspended; + m_state = State::Suspended; } Result I2cBusAccessor::TryOpenRegulatorSession() { /* Ensure we track the session. */ - this->has_regulator_session = true; - auto s_guard = SCOPE_GUARD { this->has_regulator_session = false; }; + m_has_regulator_session = true; + auto s_guard = SCOPE_GUARD { m_has_regulator_session = false; }; /* Try to open the session. */ - R_TRY_CATCH(regulator::OpenSession(std::addressof(this->regulator_session), this->device_code)) { + R_TRY_CATCH(regulator::OpenSession(std::addressof(m_regulator_session), m_device_code)) { R_CATCH(ddsf::ResultDeviceCodeNotFound) { /* It's okay if the device isn't found, but we don't have a session if so. */ - this->has_regulator_session = false; + m_has_regulator_session = false; } } R_END_TRY_CATCH; @@ -325,13 +325,13 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void I2cBusAccessor::ExecuteInitialConfig() { /* Lock exclusive access to registers. */ - std::scoped_lock lk(this->register_mutex); + std::scoped_lock lk(m_register_mutex); /* Reset the controller. */ this->ResetController(); /* Set clock registers. */ - this->SetClockRegisters(this->speed_mode); + this->SetClockRegisters(m_speed_mode); /* Set packet mode registers. */ this->SetPacketModeRegisters(); @@ -342,20 +342,20 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { Result I2cBusAccessor::Send(const u8 *src, size_t src_size, TransactionOption option, u16 slave_address, AddressingMode addressing_mode) { /* Acquire exclusive access to the registers. */ - std::scoped_lock lk(this->register_mutex); + std::scoped_lock lk(m_register_mutex); /* Configure interrupt mask, clear interrupt status. */ - reg::Write(this->registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_TFIFO_DATA_REQ_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); + reg::Write(m_registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_TFIFO_DATA_REQ_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); - reg::Write(this->registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ARB_LOST, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_NOACK, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_RFIFO_UNF, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_TFIFO_OVF, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ALL_PACKETS_XFER_COMPLETE, SET)); + reg::Write(m_registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ARB_LOST, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_NOACK, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_RFIFO_UNF, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_TFIFO_OVF, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ALL_PACKETS_XFER_COMPLETE, SET)); /* Write the header. */ this->WriteHeader(Xfer_Write, src_size, option, slave_address, addressing_mode); @@ -366,7 +366,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { while (true) { /* Get the number of empty bytes in the fifo status. */ - const u32 empty = reg::GetValue(this->registers->fifo_status, I2C_REG_BITS_MASK(FIFO_STATUS_TX_FIFO_EMPTY_CNT)); + const u32 empty = reg::GetValue(m_registers->fifo_status, I2C_REG_BITS_MASK(FIFO_STATUS_TX_FIFO_EMPTY_CNT)); /* Write up to (empty) bytes to the fifo. */ for (u32 i = 0; remaining > 0 && i < empty; ++i) { @@ -379,7 +379,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Write the data word. */ - reg::Write(this->registers->tx_packet_fifo, word); + reg::Write(m_registers->tx_packet_fifo, word); /* Advance. */ cur += cur_bytes; @@ -392,13 +392,13 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Wait for our current data to send. */ - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); - if (!os::TimedWaitInterruptEvent(std::addressof(this->interrupt_event), Timeout)) { + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); + if (!os::TimedWaitInterruptEvent(std::addressof(m_interrupt_event), Timeout)) { /* We timed out. */ this->HandleTransactionError(i2c::ResultBusBusy()); this->DisableInterruptMask(); - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); return i2c::ResultTimeout(); } @@ -407,9 +407,9 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Configure interrupt mask to not care about tfifo data req. */ - reg::Write(this->registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); + reg::Write(m_registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); /* Wait for the packet transfer to complete. */ while (true) { @@ -417,18 +417,18 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { R_TRY(this->CheckAndHandleError()); /* Check if packet transfer is done. */ - if (reg::HasValue(this->registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET))) { + if (reg::HasValue(m_registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET))) { break; } /* Wait for our the packet to transfer. */ - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); - if (!os::TimedWaitInterruptEvent(std::addressof(this->interrupt_event), Timeout)) { + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); + if (!os::TimedWaitInterruptEvent(std::addressof(m_interrupt_event), Timeout)) { /* We timed out. */ this->HandleTransactionError(i2c::ResultBusBusy()); this->DisableInterruptMask(); - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); return i2c::ResultTimeout(); } } @@ -443,20 +443,20 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { Result I2cBusAccessor::Receive(u8 *dst, size_t dst_size, TransactionOption option, u16 slave_address, AddressingMode addressing_mode) { /* Acquire exclusive access to the registers. */ - std::scoped_lock lk(this->register_mutex); + std::scoped_lock lk(m_register_mutex); /* Configure interrupt mask, clear interrupt status. */ - reg::Write(this->registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_RFIFO_DATA_REQ_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), - I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); + reg::Write(m_registers->interrupt_mask_register, I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_RFIFO_DATA_REQ_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_ARB_LOST_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_NOACK_INT_EN, ENABLE), + I2C_REG_BITS_ENUM(INTERRUPT_MASK_REGISTER_PACKET_XFER_COMPLETE_INT_EN, ENABLE)); - reg::Write(this->registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ARB_LOST, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_NOACK, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_RFIFO_UNF, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_TFIFO_OVF, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET), - I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ALL_PACKETS_XFER_COMPLETE, SET)); + reg::Write(m_registers->interrupt_status_register, I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ARB_LOST, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_NOACK, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_RFIFO_UNF, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_TFIFO_OVF, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_PACKET_XFER_COMPLETE, SET), + I2C_REG_BITS_ENUM(INTERRUPT_STATUS_REGISTER_ALL_PACKETS_XFER_COMPLETE, SET)); /* Write the header. */ this->WriteHeader(Xfer_Read, dst_size, option, slave_address, addressing_mode); @@ -467,13 +467,13 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { while (remaining > 0) { /* Wait for data to come in. */ - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); - if (!os::TimedWaitInterruptEvent(std::addressof(this->interrupt_event), Timeout)) { + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); + if (!os::TimedWaitInterruptEvent(std::addressof(m_interrupt_event), Timeout)) { /* We timed out. */ this->HandleTransactionError(i2c::ResultBusBusy()); this->DisableInterruptMask(); - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); return i2c::ResultTimeout(); } @@ -481,7 +481,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { R_TRY(this->CheckAndHandleError()); /* Get the number of full bytes in the fifo status. */ - const u32 full = reg::GetValue(this->registers->fifo_status, I2C_REG_BITS_MASK(FIFO_STATUS_RX_FIFO_FULL_CNT)); + const u32 full = reg::GetValue(m_registers->fifo_status, I2C_REG_BITS_MASK(FIFO_STATUS_RX_FIFO_FULL_CNT)); /* Determine how many words we can read. */ const size_t cur_words = std::min(util::DivideUp(remaining, sizeof(u32)), static_cast(full)); @@ -489,7 +489,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { /* Read the correct number of words from the fifo. */ for (size_t i = 0; i < cur_words; ++i) { /* Read the word from the fifo. */ - const u32 word = reg::Read(this->registers->rx_fifo); + const u32 word = reg::Read(m_registers->rx_fifo); /* Copy bytes from the word. */ const size_t cur_bytes = std::min(remaining, sizeof(u32)); @@ -512,41 +512,41 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { const bool is_read = xfer == Xfer_Read; const bool is_7_bit = addressing_mode == AddressingMode_SevenBit; const bool is_stop = (option & TransactionOption_StopCondition) != 0; - const bool is_hs = this->speed_mode == SpeedMode_HighSpeed; + const bool is_hs = m_speed_mode == SpeedMode_HighSpeed; const u32 slave_addr = ((static_cast(slave_address) & 0x7F) << 1) | (is_read ? 1 : 0); /* Flush fifos. */ this->FlushFifos(); /* Enqueue the first header word. */ - reg::Write(this->registers->tx_packet_fifo, IO_PACKET_BITS_ENUM (HEADER_WORD0_PROT_HDR_SZ, 1_WORD), - IO_PACKET_BITS_VALUE(HEADER_WORD0_PKT_ID, 0), - IO_PACKET_BITS_VALUE(HEADER_WORD0_CONTROLLER_ID, 0), - IO_PACKET_BITS_ENUM (HEADER_WORD0_PROTOCOL, I2C), - IO_PACKET_BITS_ENUM (HEADER_WORD0_PKT_TYPE, REQUEST)); + reg::Write(m_registers->tx_packet_fifo, IO_PACKET_BITS_ENUM (HEADER_WORD0_PROT_HDR_SZ, 1_WORD), + IO_PACKET_BITS_VALUE(HEADER_WORD0_PKT_ID, 0), + IO_PACKET_BITS_VALUE(HEADER_WORD0_CONTROLLER_ID, 0), + IO_PACKET_BITS_ENUM (HEADER_WORD0_PROTOCOL, I2C), + IO_PACKET_BITS_ENUM (HEADER_WORD0_PKT_TYPE, REQUEST)); /* Enqueue the second header word. */ - reg::Write(this->registers->tx_packet_fifo, IO_PACKET_BITS_VALUE(HEADER_WORD1_PAYLOAD_SIZE, static_cast(size - 1))); + reg::Write(m_registers->tx_packet_fifo, IO_PACKET_BITS_VALUE(HEADER_WORD1_PAYLOAD_SIZE, static_cast(size - 1))); /* Enqueue the protocol header word. */ - reg::Write(this->registers->tx_packet_fifo, IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_HS_MODE, is_hs, ENABLE, DISABLE), - IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_CONTINUE_ON_NACK, DISABLE), - IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_SEND_START_BYTE, DISABLE), - IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_READ_WRITE, is_read, READ, WRITE), - IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_ADDRESS_MODE, is_7_bit, SEVEN_BIT, TEN_BIT), - IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_IE, ENABLE), - IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_REPEAT_START_STOP, is_stop, STOP_CONDITION, REPEAT_START_CONDITION), - IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_CONTINUE_XFER, USE_REPEAT_START_TOP), - IO_PACKET_BITS_VALUE (PROTOCOL_HEADER_HS_MASTER_ADDR, 0), - IO_PACKET_BITS_VALUE (PROTOCOL_HEADER_SLAVE_ADDR, slave_addr)); + reg::Write(m_registers->tx_packet_fifo, IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_HS_MODE, is_hs, ENABLE, DISABLE), + IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_CONTINUE_ON_NACK, DISABLE), + IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_SEND_START_BYTE, DISABLE), + IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_READ_WRITE, is_read, READ, WRITE), + IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_ADDRESS_MODE, is_7_bit, SEVEN_BIT, TEN_BIT), + IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_IE, ENABLE), + IO_PACKET_BITS_ENUM_SEL(PROTOCOL_HEADER_REPEAT_START_STOP, is_stop, STOP_CONDITION, REPEAT_START_CONDITION), + IO_PACKET_BITS_ENUM (PROTOCOL_HEADER_CONTINUE_XFER, USE_REPEAT_START_TOP), + IO_PACKET_BITS_VALUE (PROTOCOL_HEADER_HS_MASTER_ADDR, 0), + IO_PACKET_BITS_VALUE (PROTOCOL_HEADER_SLAVE_ADDR, slave_addr)); } void I2cBusAccessor::ResetController() const { /* Reset the controller. */ - if (!this->is_power_bus) { + if (!m_is_power_bus) { /* Open a clkrst session. */ clkrst::ClkRstSession clkrst_session; - R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), this->device_code)); + R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), m_device_code)); ON_SCOPE_EXIT { clkrst::CloseSession(std::addressof(clkrst_session)); }; /* Reset the controller, setting clock rate to 408 MHz / 5 (to account for clock divisor). */ @@ -573,17 +573,17 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->ResetController(); /* Configure the sclk threshold for bus clear config. */ - reg::Write(this->registers->bus_clear_config, I2C_REG_BITS_VALUE(BUS_CLEAR_CONFIG_BC_SCLK_THRESHOLD, 9)); + reg::Write(m_registers->bus_clear_config, I2C_REG_BITS_VALUE(BUS_CLEAR_CONFIG_BC_SCLK_THRESHOLD, 9)); /* Set stop cond and terminate in bus clear config. */ - reg::ReadWrite(this->registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_STOP_COND, STOP)); - reg::ReadWrite(this->registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_TERMINATE, IMMEDIATE)); + reg::ReadWrite(m_registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_STOP_COND, STOP)); + reg::ReadWrite(m_registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_TERMINATE, IMMEDIATE)); /* Set master config load, busy loop up to 1ms for it to take. */ - reg::ReadWrite(this->registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE)); + reg::ReadWrite(m_registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE)); const os::Tick start_tick_a = os::GetSystemTick(); - while (reg::HasValue(this->registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE))) { + while (reg::HasValue(m_registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE))) { if ((os::GetSystemTick() - start_tick_a).ToTimeSpan().GetMicroSeconds() > BusyLoopMicroSeconds) { need_retry = true; break; @@ -595,10 +595,10 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { } /* Set bus clear enable, wait up to 1ms for it to take. */ - reg::ReadWrite(this->registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_ENABLE, ENABLE)); + reg::ReadWrite(m_registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_ENABLE, ENABLE)); const os::Tick start_tick_b = os::GetSystemTick(); - while (reg::HasValue(this->registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_ENABLE, ENABLE))) { + while (reg::HasValue(m_registers->bus_clear_config, I2C_REG_BITS_ENUM(BUS_CLEAR_CONFIG_BC_ENABLE, ENABLE))) { if ((os::GetSystemTick() - start_tick_b).ToTimeSpan().GetMicroSeconds() > BusyLoopMicroSeconds) { need_retry = true; break; @@ -611,7 +611,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { /* Wait up to 1ms for the bus clear to complete. */ const os::Tick start_tick_c = os::GetSystemTick(); - while (reg::HasValue(this->registers->bus_clear_status, I2C_REG_BITS_ENUM(BUS_CLEAR_STATUS_BC_STATUS, NOT_CLEARED))) { + while (reg::HasValue(m_registers->bus_clear_status, I2C_REG_BITS_ENUM(BUS_CLEAR_STATUS_BC_STATUS, NOT_CLEARED))) { if ((os::GetSystemTick() - start_tick_c).ToTimeSpan().GetMicroSeconds() > BusyLoopMicroSeconds) { need_retry = true; break; @@ -629,7 +629,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { u32 t_high, t_low, clk_div, debounce, src_div; bool high_speed = false; - if (this->is_power_bus) { + if (m_is_power_bus) { t_high = 0x02; t_low = 0x04; clk_div = 0x05; @@ -672,26 +672,26 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { /* Write the clock divisors. */ if (high_speed) { - reg::Write(this->registers->hs_interface_timing_0, I2C_REG_BITS_VALUE(HS_INTERFACE_TIMING_0_HS_THIGH, t_high), - I2C_REG_BITS_VALUE(HS_INTERFACE_TIMING_0_HS_TLOW, t_low)); + reg::Write(m_registers->hs_interface_timing_0, I2C_REG_BITS_VALUE(HS_INTERFACE_TIMING_0_HS_THIGH, t_high), + I2C_REG_BITS_VALUE(HS_INTERFACE_TIMING_0_HS_TLOW, t_low)); - reg::Write(this->registers->clk_divisor_register, I2C_REG_BITS_VALUE(CLK_DIVISOR_REGISTER_HSMODE, clk_div)); + reg::Write(m_registers->clk_divisor_register, I2C_REG_BITS_VALUE(CLK_DIVISOR_REGISTER_HSMODE, clk_div)); } else { - reg::Write(this->registers->interface_timing_0, I2C_REG_BITS_VALUE(INTERFACE_TIMING_0_THIGH, t_high), - I2C_REG_BITS_VALUE(INTERFACE_TIMING_0_TLOW, t_low)); + reg::Write(m_registers->interface_timing_0, I2C_REG_BITS_VALUE(INTERFACE_TIMING_0_THIGH, t_high), + I2C_REG_BITS_VALUE(INTERFACE_TIMING_0_TLOW, t_low)); - reg::Write(this->registers->clk_divisor_register, I2C_REG_BITS_VALUE(CLK_DIVISOR_REGISTER_STD_FAST_MODE, clk_div)); + reg::Write(m_registers->clk_divisor_register, I2C_REG_BITS_VALUE(CLK_DIVISOR_REGISTER_STD_FAST_MODE, clk_div)); } /* Configure debounce. */ - reg::Write(this->registers->cnfg, I2C_REG_BITS_VALUE(I2C_CNFG_DEBOUNCE_CNT, debounce)); - reg::Read(this->registers->cnfg); + reg::Write(m_registers->cnfg, I2C_REG_BITS_VALUE(I2C_CNFG_DEBOUNCE_CNT, debounce)); + reg::Read(m_registers->cnfg); /* Set the clock rate, if we should. */ - if (!this->is_power_bus) { + if (!m_is_power_bus) { /* Open a clkrst session. */ clkrst::ClkRstSession clkrst_session; - R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), this->device_code)); + R_ABORT_UNLESS(clkrst::OpenSession(std::addressof(clkrst_session), m_device_code)); ON_SCOPE_EXIT { clkrst::CloseSession(std::addressof(clkrst_session)); }; /* Reset the controller, setting clock rate to 408 MHz / (src_div + 1). */ @@ -704,26 +704,26 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void I2cBusAccessor::SetPacketModeRegisters() { /* Set packet mode enable. */ - reg::ReadWrite(this->registers->cnfg, I2C_REG_BITS_ENUM(I2C_CNFG_PACKET_MODE_EN, GO)); + reg::ReadWrite(m_registers->cnfg, I2C_REG_BITS_ENUM(I2C_CNFG_PACKET_MODE_EN, GO)); /* Set master config load. */ - reg::ReadWrite(this->registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE)); + reg::ReadWrite(m_registers->config_load, I2C_REG_BITS_ENUM(CONFIG_LOAD_MSTR_CONFIG_LOAD, ENABLE)); /* Set tx/fifo triggers to default (maximum values). */ - reg::Write(this->registers->fifo_control, I2C_REG_BITS_VALUE(FIFO_CONTROL_RX_FIFO_TRIG, 7), - I2C_REG_BITS_VALUE(FIFO_CONTROL_TX_FIFO_TRIG, 7)); + reg::Write(m_registers->fifo_control, I2C_REG_BITS_VALUE(FIFO_CONTROL_RX_FIFO_TRIG, 7), + I2C_REG_BITS_VALUE(FIFO_CONTROL_TX_FIFO_TRIG, 7)); } Result I2cBusAccessor::FlushFifos() { /* Flush the fifo. */ - reg::Write(this->registers->fifo_control, I2C_REG_BITS_VALUE(FIFO_CONTROL_RX_FIFO_TRIG, 7), - I2C_REG_BITS_VALUE(FIFO_CONTROL_TX_FIFO_TRIG, 7), - I2C_REG_BITS_ENUM (FIFO_CONTROL_RX_FIFO_FLUSH, SET), - I2C_REG_BITS_ENUM (FIFO_CONTROL_TX_FIFO_FLUSH, SET)); + reg::Write(m_registers->fifo_control, I2C_REG_BITS_VALUE(FIFO_CONTROL_RX_FIFO_TRIG, 7), + I2C_REG_BITS_VALUE(FIFO_CONTROL_TX_FIFO_TRIG, 7), + I2C_REG_BITS_ENUM (FIFO_CONTROL_RX_FIFO_FLUSH, SET), + I2C_REG_BITS_ENUM (FIFO_CONTROL_TX_FIFO_FLUSH, SET)); /* Wait up to 5 ms for the flush to complete. */ int count = 0; - while (!reg::HasValue(this->registers->fifo_control, I2C_REG_BITS_ENUM(FIFO_CONTROL_FIFO_FLUSH, RX_UNSET_TX_UNSET))) { + while (!reg::HasValue(m_registers->fifo_control, I2C_REG_BITS_ENUM(FIFO_CONTROL_FIFO_FLUSH, RX_UNSET_TX_UNSET))) { R_UNLESS((++count < 5), i2c::ResultBusBusy()); os::SleepThread(TimeSpan::FromMilliSeconds(1)); } @@ -733,8 +733,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { Result I2cBusAccessor::GetTransactionResult() const { /* Get packet status/interrupt status. */ - volatile u32 packet_status = reg::Read(this->registers->packet_transfer_status); - volatile u32 interrupt_status = reg::Read(this->registers->interrupt_status_register); + volatile u32 packet_status = reg::Read(m_registers->packet_transfer_status); + volatile u32 interrupt_status = reg::Read(m_registers->interrupt_status_register); /* Check for ack. */ R_UNLESS(reg::HasValue(packet_status, I2C_REG_BITS_ENUM(PACKET_TRANSFER_STATUS_NOACK_FOR_DATA, UNSET)), i2c::ResultNoAck()); @@ -759,7 +759,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->ResetController(); /* Set clock registers. */ - this->SetClockRegisters(this->speed_mode); + this->SetClockRegisters(m_speed_mode); /* Set packet mode registers. */ this->SetPacketModeRegisters(); diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp index 272781549..d40e69bab 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_bus_accessor.hpp @@ -37,31 +37,31 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { Xfer_Read = 1, }; private: - volatile I2cRegisters *registers; - SpeedMode speed_mode; - os::InterruptEventType interrupt_event; - int user_count; - os::SdkMutex user_count_mutex; - os::SdkMutex register_mutex; - regulator::RegulatorSession regulator_session; - bool has_regulator_session; - State state; - os::SdkMutex transaction_order_mutex; - bool is_power_bus; - dd::PhysicalAddress registers_phys_addr; - size_t registers_size; - os::InterruptName interrupt_name; - DeviceCode device_code; - util::IntrusiveListNode bus_accessor_list_node; + volatile I2cRegisters *m_registers; + SpeedMode m_speed_mode; + os::InterruptEventType m_interrupt_event; + int m_user_count; + os::SdkMutex m_user_count_mutex; + os::SdkMutex m_register_mutex; + regulator::RegulatorSession m_regulator_session; + bool m_has_regulator_session; + State m_state; + os::SdkMutex m_transaction_order_mutex; + bool m_is_power_bus; + dd::PhysicalAddress m_registers_phys_addr; + size_t m_registers_size; + os::InterruptName m_interrupt_name; + DeviceCode m_device_code; + util::IntrusiveListNode m_bus_accessor_list_node; public: - using BusAccessorListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cBusAccessor::bus_accessor_list_node>; + using BusAccessorListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cBusAccessor::m_bus_accessor_list_node>; using BusAccessorList = typename BusAccessorListTraits::ListType; - friend class util::IntrusiveList>; + friend class util::IntrusiveList>; public: I2cBusAccessor() - : registers(nullptr), speed_mode(SpeedMode_Fast), user_count(0), user_count_mutex(), - register_mutex(), has_regulator_session(false), state(State::NotInitialized), transaction_order_mutex(), - is_power_bus(false), registers_phys_addr(0), registers_size(0), interrupt_name(), device_code(-1), bus_accessor_list_node() + : m_registers(nullptr), m_speed_mode(SpeedMode_Fast), m_user_count(0), m_user_count_mutex(), + m_register_mutex(), m_has_regulator_session(false), m_state(State::NotInitialized), m_transaction_order_mutex(), + m_is_power_bus(false), m_registers_phys_addr(0), m_registers_size(0), m_interrupt_name(), m_device_code(-1), m_bus_accessor_list_node() { /* ... */ } @@ -69,10 +69,10 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void Initialize(dd::PhysicalAddress reg_paddr, size_t reg_size, os::InterruptName intr, bool pb, SpeedMode sm); void RegisterDeviceCode(DeviceCode device_code); - SpeedMode GetSpeedMode() const { return this->speed_mode; } - dd::PhysicalAddress GetRegistersPhysicalAddress() const { return this->registers_phys_addr; } - size_t GetRegistersSize() const { return this->registers_size; } - os::InterruptName GetInterruptName() const { return this->interrupt_name; } + SpeedMode GetSpeedMode() const { return m_speed_mode; } + dd::PhysicalAddress GetRegistersPhysicalAddress() const { return m_registers_phys_addr; } + size_t GetRegistersSize() const { return m_registers_size; } + os::InterruptName GetInterruptName() const { return m_interrupt_name; } private: Result TryOpenRegulatorSession(); @@ -94,8 +94,8 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { void HandleTransactionError(Result result); void DisableInterruptMask() { - reg::Write(this->registers->interrupt_mask_register, 0); - reg::Read(this->registers->interrupt_mask_register); + reg::Write(m_registers->interrupt_mask_register, 0); + reg::Read(m_registers->interrupt_mask_register); } Result CheckAndHandleError() { @@ -103,7 +103,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { this->HandleTransactionError(result); if (R_FAILED(result)) { this->DisableInterruptMask(); - os::ClearInterruptEvent(std::addressof(this->interrupt_event)); + os::ClearInterruptEvent(std::addressof(m_interrupt_event)); return result; } @@ -120,7 +120,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { virtual Result Receive(void *dst, size_t dst_size, I2cDeviceProperty *device, TransactionOption option) override; virtual os::SdkMutex &GetTransactionOrderMutex() override { - return this->transaction_order_mutex; + return m_transaction_order_mutex; } virtual void SuspendBus() override; @@ -130,7 +130,7 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { virtual void ResumePowerBus() override; virtual const DeviceCode &GetDeviceCode() const override { - return this->device_code; + return m_device_code; } }; diff --git a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp index fef2779e7..d1284c4fb 100644 --- a/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp +++ b/libraries/libstratosphere/source/i2c/driver/board/nintendo/nx/impl/i2c_i_allocator.hpp @@ -25,48 +25,48 @@ namespace ams::i2c::driver::board::nintendo::nx::impl { private: using T = typename ListType::value_type; private: - ams::MemoryResource *memory_resource; - ListType list; - mutable os::SdkMutex list_lock; + ams::MemoryResource *m_memory_resource; + ListType m_list; + mutable os::SdkMutex m_list_lock; public: - IAllocator(ams::MemoryResource *mr) : memory_resource(mr), list(), list_lock() { /* ... */ } + IAllocator(ams::MemoryResource *mr) : m_memory_resource(mr), m_list(), m_list_lock() { /* ... */ } ~IAllocator() { - std::scoped_lock lk(this->list_lock); + std::scoped_lock lk(m_list_lock); /* Remove all entries. */ - auto it = this->list.begin(); - while (it != this->list.end()) { + auto it = m_list.begin(); + while (it != m_list.end()) { T *obj = std::addressof(*it); - it = this->list.erase(it); + it = m_list.erase(it); std::destroy_at(obj); - this->memory_resource->Deallocate(obj, sizeof(T)); + m_memory_resource->Deallocate(obj, sizeof(T)); } } template T *Allocate(Args &&...args) { - std::scoped_lock lk(this->list_lock); + std::scoped_lock lk(m_list_lock); /* Allocate space for the object. */ - void *storage = this->memory_resource->Allocate(sizeof(T), alignof(T)); + void *storage = m_memory_resource->Allocate(sizeof(T), alignof(T)); AMS_ABORT_UNLESS(storage != nullptr); /* Construct the object. */ T *t = std::construct_at(static_cast(storage), std::forward(args)...); /* Link the object into our list. */ - this->list.push_back(*t); + m_list.push_back(*t); return t; } template T *Find(F f) { - std::scoped_lock lk(this->list_lock); + std::scoped_lock lk(m_list_lock); - for (T &it : this->list) { + for (T &it : m_list) { if (f(static_cast(it))) { return std::addressof(it); } diff --git a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp index 745217313..2bf06ce7a 100644 --- a/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp +++ b/libraries/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp @@ -144,8 +144,8 @@ namespace ams::i2c::driver::impl { /* If we timed out, retry up to our max retry count. */ R_TRY_CATCH(result) { R_CATCH(i2c::ResultTimeout) { - if ((++retry_count) <= this->max_retry_count) { - os::SleepThread(this->retry_interval); + if ((++retry_count) <= m_max_retry_count) { + os::SleepThread(m_retry_interval); continue; } return i2c::ResultBusBusy(); @@ -197,8 +197,8 @@ namespace ams::i2c::driver::impl { } Result I2cSessionImpl::SetRetryPolicy(int mr, int interval_us) { - this->max_retry_count = mr; - this->retry_interval = TimeSpan::FromMicroSeconds(interval_us); + m_max_retry_count = mr; + m_retry_interval = TimeSpan::FromMicroSeconds(interval_us); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp b/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp index e07ecaa00..2b2189d9d 100644 --- a/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp +++ b/libraries/libstratosphere/source/i2c/i2c_command_list_formatter.cpp @@ -19,7 +19,7 @@ namespace ams::i2c { Result CommandListFormatter::IsEnqueueAble(size_t sz) const { - R_UNLESS(this->command_list_length - this->current_index >= sz, i2c::ResultCommandListFull()); + R_UNLESS(m_command_list_length - m_current_index >= sz, i2c::ResultCommandListFull()); return ResultSuccess(); } @@ -29,11 +29,11 @@ namespace ams::i2c { R_TRY(this->IsEnqueueAble(CommandLength)); /* Get the command list. */ - util::BitPack8 *cmd_list = static_cast(this->command_list); + util::BitPack8 *cmd_list = static_cast(m_command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; - auto &header1 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[m_current_index++]; + auto &header1 = cmd_list[m_current_index++]; /* Set the header. */ header0 = {}; @@ -53,11 +53,11 @@ namespace ams::i2c { R_TRY(this->IsEnqueueAble(CommandLength + size)); /* Get the command list. */ - util::BitPack8 *cmd_list = static_cast(this->command_list); + util::BitPack8 *cmd_list = static_cast(m_command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; - auto &header1 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[m_current_index++]; + auto &header1 = cmd_list[m_current_index++]; /* Set the header. */ header0 = {}; @@ -69,8 +69,8 @@ namespace ams::i2c { header1.Set(size); /* Copy the data we're sending. */ - std::memcpy(cmd_list + this->current_index, src, size); - this->current_index += size; + std::memcpy(cmd_list + m_current_index, src, size); + m_current_index += size; return ResultSuccess(); } @@ -81,11 +81,11 @@ namespace ams::i2c { R_TRY(this->IsEnqueueAble(CommandLength)); /* Get the command list. */ - util::BitPack8 *cmd_list = static_cast(this->command_list); + util::BitPack8 *cmd_list = static_cast(m_command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; - auto &header1 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[m_current_index++]; + auto &header1 = cmd_list[m_current_index++]; /* Set the header. */ header0 = {}; diff --git a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp index b0c1e6509..98815ae0e 100644 --- a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.cpp @@ -19,12 +19,12 @@ namespace ams::i2c::server { ManagerImpl::ManagerImpl() { - this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None); - this->allocator.Attach(this->heap_handle); + m_heap_handle = lmem::CreateExpHeap(m_heap_buffer, sizeof(m_heap_buffer), lmem::CreateOption_None); + m_allocator.Attach(m_heap_handle); } ManagerImpl::~ManagerImpl() { - lmem::DestroyExpHeap(this->heap_handle); + lmem::DestroyExpHeap(m_heap_handle); } Result ManagerImpl::OpenSessionForDev(ams::sf::Out> out, s32 bus_idx, u16 slave_address, i2c::AddressingMode addressing_mode, i2c::SpeedMode speed_mode) { @@ -51,7 +51,7 @@ namespace ams::i2c::server { Result ManagerImpl::OpenSession2(ams::sf::Out> out, DeviceCode device_code) { /* Allocate a session. */ - auto session = Factory::CreateSharedEmplaced(std::addressof(this->allocator), this); + auto session = Factory::CreateSharedEmplaced(std::addressof(m_allocator), this); /* Open the session. */ R_TRY(session.GetImpl().OpenSession(device_code)); diff --git a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.hpp b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.hpp index e584d29be..ca05071b2 100644 --- a/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.hpp +++ b/libraries/libstratosphere/source/i2c/server/i2c_server_manager_impl.hpp @@ -24,9 +24,9 @@ namespace ams::i2c::server { using Allocator = ams::sf::ExpHeapAllocator; using Factory = ams::sf::ObjectFactory; private: - lmem::HeapHandle heap_handle; - Allocator allocator; - u8 heap_buffer[4_KB]; + lmem::HeapHandle m_heap_handle; + Allocator m_allocator; + u8 m_heap_buffer[4_KB]; public: ManagerImpl(); diff --git a/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp b/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp index 6dceaaa7b..848ba6c9d 100644 --- a/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp +++ b/libraries/libstratosphere/source/i2c/server/i2c_server_session_impl.hpp @@ -22,53 +22,53 @@ namespace ams::i2c::server { class SessionImpl { private: - ManagerImpl *parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ - i2c::driver::I2cSession internal_session; - bool has_session; + ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ + i2c::driver::I2cSession m_internal_session; + bool m_has_session; public: - explicit SessionImpl(ManagerImpl *p) : parent(p), has_session(false) { /* ... */ } + explicit SessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ } ~SessionImpl() { - if (this->has_session) { - i2c::driver::CloseSession(this->internal_session); + if (m_has_session) { + i2c::driver::CloseSession(m_internal_session); } } Result OpenSession(DeviceCode device_code) { - AMS_ABORT_UNLESS(!this->has_session); + AMS_ABORT_UNLESS(!m_has_session); - R_TRY(i2c::driver::OpenSession(std::addressof(this->internal_session), device_code)); - this->has_session = true; + R_TRY(i2c::driver::OpenSession(std::addressof(m_internal_session), device_code)); + m_has_session = true; return ResultSuccess(); } public: /* Actual commands. */ Result SendOld(const ams::sf::InBuffer &in_data, i2c::TransactionOption option) { - return i2c::driver::Send(this->internal_session, in_data.GetPointer(), in_data.GetSize(), option); + return i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option); } Result ReceiveOld(const ams::sf::OutBuffer &out_data, i2c::TransactionOption option) { - return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), this->internal_session, option); + return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option); } Result ExecuteCommandListOld(const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray &command_list){ - return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), this->internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); + return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); } Result Send(const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option) { - return i2c::driver::Send(this->internal_session, in_data.GetPointer(), in_data.GetSize(), option); + return i2c::driver::Send(m_internal_session, in_data.GetPointer(), in_data.GetSize(), option); } Result Receive(const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option) { - return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), this->internal_session, option); + return i2c::driver::Receive(out_data.GetPointer(), out_data.GetSize(), m_internal_session, option); } Result ExecuteCommandList(const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray &command_list) { - return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), this->internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); + return i2c::driver::ExecuteCommandList(rcv_buf.GetPointer(), rcv_buf.GetSize(), m_internal_session, command_list.GetPointer(), command_list.GetSize() * sizeof(i2c::I2cCommand)); } Result SetRetryPolicy(s32 max_retry_count, s32 retry_interval_us) { - return i2c::driver::SetRetryPolicy(this->internal_session, max_retry_count, retry_interval_us); + return i2c::driver::SetRetryPolicy(m_internal_session, max_retry_count, retry_interval_us); } }; static_assert(i2c::sf::IsISession); diff --git a/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp b/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp index d4e3df298..80e27d441 100644 --- a/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp +++ b/libraries/libstratosphere/source/kvdb/kvdb_archive.cpp @@ -68,22 +68,22 @@ namespace ams::kvdb { /* Reader functionality. */ Result ArchiveReader::Peek(void *dst, size_t size) { /* Bounds check. */ - R_UNLESS(this->offset + size <= this->buffer.GetSize(), kvdb::ResultInvalidKeyValue()); - R_UNLESS(this->offset < this->offset + size, kvdb::ResultInvalidKeyValue()); + R_UNLESS(m_offset + size <= m_buffer.GetSize(), kvdb::ResultInvalidKeyValue()); + R_UNLESS(m_offset < m_offset + size, kvdb::ResultInvalidKeyValue()); - std::memcpy(dst, this->buffer.Get() + this->offset, size); + std::memcpy(dst, m_buffer.Get() + m_offset, size); return ResultSuccess(); } Result ArchiveReader::Read(void *dst, size_t size) { R_TRY(this->Peek(dst, size)); - this->offset += size; + m_offset += size; return ResultSuccess(); } Result ArchiveReader::ReadEntryCount(size_t *out) { /* This should only be called at the start of reading stream. */ - AMS_ABORT_UNLESS(this->offset == 0); + AMS_ABORT_UNLESS(m_offset == 0); /* Read and validate header. */ ArchiveHeader header; @@ -96,7 +96,7 @@ namespace ams::kvdb { Result ArchiveReader::GetEntrySize(size_t *out_key_size, size_t *out_value_size) { /* This should only be called after ReadEntryCount. */ - AMS_ABORT_UNLESS(this->offset != 0); + AMS_ABORT_UNLESS(m_offset != 0); /* Peek the next entry header. */ ArchiveEntryHeader header; @@ -110,7 +110,7 @@ namespace ams::kvdb { Result ArchiveReader::ReadEntry(void *out_key, size_t key_size, void *out_value, size_t value_size) { /* This should only be called after ReadEntryCount. */ - AMS_ABORT_UNLESS(this->offset != 0); + AMS_ABORT_UNLESS(m_offset != 0); /* Read the next entry header. */ ArchiveEntryHeader header; @@ -129,17 +129,17 @@ namespace ams::kvdb { /* Writer functionality. */ Result ArchiveWriter::Write(const void *src, size_t size) { /* Bounds check. */ - R_UNLESS(this->offset + size <= this->buffer.GetSize(), kvdb::ResultInvalidKeyValue()); - R_UNLESS(this->offset < this->offset + size, kvdb::ResultInvalidKeyValue()); + R_UNLESS(m_offset + size <= m_buffer.GetSize(), kvdb::ResultInvalidKeyValue()); + R_UNLESS(m_offset < m_offset + size, kvdb::ResultInvalidKeyValue()); - std::memcpy(this->buffer.Get() + this->offset, src, size); - this->offset += size; + std::memcpy(m_buffer.Get() + m_offset, src, size); + m_offset += size; return ResultSuccess(); } void ArchiveWriter::WriteHeader(size_t entry_count) { /* This should only be called at start of write. */ - AMS_ABORT_UNLESS(this->offset == 0); + AMS_ABORT_UNLESS(m_offset == 0); ArchiveHeader header = ArchiveHeader::Make(entry_count); R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header))); @@ -147,7 +147,7 @@ namespace ams::kvdb { void ArchiveWriter::WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size) { /* This should only be called after writing header. */ - AMS_ABORT_UNLESS(this->offset != 0); + AMS_ABORT_UNLESS(m_offset != 0); ArchiveEntryHeader header = ArchiveEntryHeader::Make(key_size, value_size); R_ABORT_UNLESS(this->Write(std::addressof(header), sizeof(header))); @@ -156,12 +156,12 @@ namespace ams::kvdb { } /* Size helper functionality. */ - ArchiveSizeHelper::ArchiveSizeHelper() : size(sizeof(ArchiveHeader)) { + ArchiveSizeHelper::ArchiveSizeHelper() : m_size(sizeof(ArchiveHeader)) { /* ... */ } void ArchiveSizeHelper::AddEntry(size_t key_size, size_t value_size) { - this->size += sizeof(ArchiveEntryHeader) + key_size + value_size; + m_size += sizeof(ArchiveEntryHeader) + key_size + value_size; } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp index 1228063e9..8748e1395 100644 --- a/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp +++ b/libraries/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp @@ -19,25 +19,25 @@ namespace ams::kvdb { /* Cache implementation. */ void *FileKeyValueStore::Cache::Allocate(size_t size) { - if (this->backing_buffer_size - this->backing_buffer_free_offset < size) { + if (m_backing_buffer_size - m_backing_buffer_free_offset < size) { return nullptr; } - ON_SCOPE_EXIT { this->backing_buffer_free_offset += size; }; - return this->backing_buffer + this->backing_buffer_free_offset; + ON_SCOPE_EXIT { m_backing_buffer_free_offset += size; }; + return m_backing_buffer + m_backing_buffer_free_offset; } Result FileKeyValueStore::Cache::Initialize(void *buffer, size_t buffer_size, size_t capacity) { - this->backing_buffer = static_cast(buffer); - this->backing_buffer_size = buffer_size; - this->backing_buffer_free_offset = 0; - this->entries = nullptr; - this->count = 0; - this->capacity = capacity; + m_backing_buffer = static_cast(buffer); + m_backing_buffer_size = buffer_size; + m_backing_buffer_free_offset = 0; + m_entries = nullptr; + m_count = 0; + m_capacity = capacity; /* If we have memory to work with, ensure it's at least enough for the cache entries. */ - if (this->backing_buffer != nullptr) { - this->entries = static_castentries)>(this->Allocate(sizeof(*this->entries) * this->capacity)); - R_UNLESS(this->entries != nullptr, kvdb::ResultBufferInsufficient()); + if (m_backing_buffer != nullptr) { + m_entries = static_cast(this->Allocate(sizeof(*m_entries) * m_capacity)); + R_UNLESS(m_entries != nullptr, kvdb::ResultBufferInsufficient()); } return ResultSuccess(); @@ -49,10 +49,10 @@ namespace ams::kvdb { } /* Reset the allocation pool. */ - this->backing_buffer_free_offset = 0; - this->count = 0; - this->entries = static_castentries)>(this->Allocate(sizeof(*this->entries) * this->capacity)); - AMS_ABORT_UNLESS(this->entries != nullptr); + m_backing_buffer_free_offset = 0; + m_count = 0; + m_entries = static_cast(this->Allocate(sizeof(*m_entries) * m_capacity)); + AMS_ABORT_UNLESS(m_entries != nullptr); } util::optional FileKeyValueStore::Cache::TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size) { @@ -61,8 +61,8 @@ namespace ams::kvdb { } /* Try to find the entry. */ - for (size_t i = 0; i < this->count; i++) { - const auto &entry = this->entries[i]; + for (size_t i = 0; i < m_count; i++) { + const auto &entry = m_entries[i]; if (entry.key_size == key_size && std::memcmp(entry.key, key, key_size) == 0) { /* If we don't have enough space, fail to read from cache. */ if (max_out_size < entry.value_size) { @@ -83,8 +83,8 @@ namespace ams::kvdb { } /* Try to find the entry. */ - for (size_t i = 0; i < this->count; i++) { - const auto &entry = this->entries[i]; + for (size_t i = 0; i < m_count; i++) { + const auto &entry = m_entries[i]; if (entry.key_size == key_size && std::memcmp(entry.key, key, key_size) == 0) { return entry.value_size; } @@ -102,7 +102,7 @@ namespace ams::kvdb { AMS_ABORT_UNLESS(key_size <= MaxKeySize); /* If we're at capacity, invalidate the cache. */ - if (this->count == this->capacity) { + if (m_count == m_capacity) { this->Invalidate(); } @@ -118,7 +118,7 @@ namespace ams::kvdb { } } - auto &entry = this->entries[this->count++]; + auto &entry = m_entries[m_count++]; std::memcpy(entry.key, key, key_size); entry.key_size = key_size; entry.value = value_buf; @@ -133,7 +133,7 @@ namespace ams::kvdb { /* Store functionality. */ FileKeyValueStore::Path FileKeyValueStore::GetPath(const void *_key, size_t key_size) { /* Format is "/.val" */ - FileKeyValueStore::Path key_path(this->dir_path.Get()); + FileKeyValueStore::Path key_path(m_dir_path.Get()); key_path.Append('/'); /* Append hex formatted key. */ @@ -184,22 +184,22 @@ namespace ams::kvdb { R_UNLESS(entry_type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound()); /* Set path. */ - this->dir_path.Set(dir); + m_dir_path.Set(dir); /* Initialize our cache. */ - R_TRY(this->cache.Initialize(cache_buffer, cache_buffer_size, cache_capacity)); + R_TRY(m_cache.Initialize(cache_buffer, cache_buffer_size, cache_capacity)); return ResultSuccess(); } Result FileKeyValueStore::Get(size_t *out_size, void *out_value, size_t max_out_size, const void *key, size_t key_size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Ensure key size is small enough. */ R_UNLESS(key_size <= MaxKeySize, kvdb::ResultOutOfKeyResource()); /* Try to get from cache. */ { - auto size = this->cache.TryGet(out_value, max_out_size, key, key_size); + auto size = m_cache.TryGet(out_value, max_out_size, key, key_size); if (size) { *out_size = *size; return ResultSuccess(); @@ -226,19 +226,19 @@ namespace ams::kvdb { *out_size = value_size; /* Cache the newly read value. */ - this->cache.Set(key, key_size, out_value, value_size); + m_cache.Set(key, key_size, out_value, value_size); return ResultSuccess(); } Result FileKeyValueStore::GetSize(size_t *out_size, const void *key, size_t key_size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Ensure key size is small enough. */ R_UNLESS(key_size <= MaxKeySize, kvdb::ResultOutOfKeyResource()); /* Try to get from cache. */ { - auto size = this->cache.TryGetSize(key, key_size); + auto size = m_cache.TryGetSize(key, key_size); if (size) { *out_size = *size; return ResultSuccess(); @@ -261,14 +261,14 @@ namespace ams::kvdb { } Result FileKeyValueStore::Set(const void *key, size_t key_size, const void *value, size_t value_size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Ensure key size is small enough. */ R_UNLESS(key_size <= MaxKeySize, kvdb::ResultOutOfKeyResource()); /* When the cache contains the key being set, Nintendo invalidates the cache. */ - if (this->cache.Contains(key, key_size)) { - this->cache.Invalidate(); + if (m_cache.Contains(key, key_size)) { + m_cache.Invalidate(); } /* Delete the file, if it exists. Don't check result, since it's okay if it's already deleted. */ @@ -290,14 +290,14 @@ namespace ams::kvdb { } Result FileKeyValueStore::Remove(const void *key, size_t key_size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Ensure key size is small enough. */ R_UNLESS(key_size <= MaxKeySize, kvdb::ResultOutOfKeyResource()); /* When the cache contains the key being set, Nintendo invalidates the cache. */ - if (this->cache.Contains(key, key_size)) { - this->cache.Invalidate(); + if (m_cache.Contains(key, key_size)) { + m_cache.Invalidate(); } /* Remove the file. */ diff --git a/libraries/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp b/libraries/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp index 7cb3316b5..001257ef1 100644 --- a/libraries/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp +++ b/libraries/libstratosphere/source/lmem/impl/lmem_impl_common_heap.hpp @@ -26,17 +26,17 @@ namespace ams::lmem::impl { NON_COPYABLE(ScopedHeapLock); NON_MOVEABLE(ScopedHeapLock); private: - HeapHandle handle; + HeapHandle m_handle; public: - explicit ScopedHeapLock(HeapHandle h) : handle(h) { - if (this->handle->option & CreateOption_ThreadSafe) { - os::LockSdkMutex(std::addressof(this->handle->mutex)); + explicit ScopedHeapLock(HeapHandle h) : m_handle(h) { + if (m_handle->option & CreateOption_ThreadSafe) { + os::LockSdkMutex(std::addressof(m_handle->mutex)); } } ~ScopedHeapLock() { - if (this->handle->option & CreateOption_ThreadSafe) { - os::UnlockSdkMutex(std::addressof(this->handle->mutex)); + if (m_handle->option & CreateOption_ThreadSafe) { + os::UnlockSdkMutex(std::addressof(m_handle->mutex)); } } }; diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp index f76a44464..a22ffd2ec 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.cpp @@ -21,7 +21,7 @@ namespace ams::lr { Result AddOnContentLocationResolverImpl::ResolveAddOnContentPath(sf::Out out, ncm::DataId id) { /* Find a storage that contains the given program id. */ ncm::StorageId storage_id = ncm::StorageId::None; - R_UNLESS(this->registered_storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound()); + R_UNLESS(m_registered_storages.Find(std::addressof(storage_id), id), lr::ResultAddOnContentNotFound()); /* Obtain a content meta database for the storage id. */ ncm::ContentMetaDatabase content_meta_database; @@ -44,28 +44,28 @@ namespace ams::lr { Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorageDeprecated(ncm::DataId id, ncm::StorageId storage_id) { /* Register storage for the given program id. 2.0.0-8.1.0 did not require an owner application id. */ - R_UNLESS(this->registered_storages.Register(id, storage_id, ncm::InvalidApplicationId), lr::ResultTooManyRegisteredPaths()); + R_UNLESS(m_registered_storages.Register(id, storage_id, ncm::InvalidApplicationId), lr::ResultTooManyRegisteredPaths()); return ResultSuccess(); } Result AddOnContentLocationResolverImpl::RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) { /* Register storage for the given program id and owner application. */ - R_UNLESS(this->registered_storages.Register(id, storage_id, application_id), lr::ResultTooManyRegisteredPaths()); + R_UNLESS(m_registered_storages.Register(id, storage_id, application_id), lr::ResultTooManyRegisteredPaths()); return ResultSuccess(); } Result AddOnContentLocationResolverImpl::UnregisterAllAddOnContentPath() { - this->registered_storages.Clear(); + m_registered_storages.Clear(); return ResultSuccess(); } Result AddOnContentLocationResolverImpl::RefreshApplicationAddOnContent(const sf::InArray &ids) { if (ids.GetSize() == 0) { /* Clear all registered storages. */ - this->registered_storages.Clear(); + m_registered_storages.Clear(); } else { /* Clear all registered storages excluding the provided program ids. */ - this->registered_storages.ClearExcluding(reinterpret_cast(ids.GetPointer()), ids.GetSize()); + m_registered_storages.ClearExcluding(reinterpret_cast(ids.GetPointer()), ids.GetSize()); } return ResultSuccess(); @@ -73,7 +73,7 @@ namespace ams::lr { Result AddOnContentLocationResolverImpl::UnregisterApplicationAddOnContent(ncm::ApplicationId id) { /* Remove entries belonging to the provided application. */ - this->registered_storages.UnregisterOwnerProgram(id); + m_registered_storages.UnregisterOwnerProgram(id); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp index 990481fdb..2b033f668 100644 --- a/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_add_on_content_location_resolver_impl.hpp @@ -24,9 +24,9 @@ namespace ams::lr { class AddOnContentLocationResolverImpl { private: /* Storage for RegisteredData entries by data id. */ - RegisteredStorages registered_storages; + RegisteredStorages m_registered_storages; public: - AddOnContentLocationResolverImpl() : registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ } + AddOnContentLocationResolverImpl() : m_registered_storages(hos::GetVersion() < hos::Version_9_0_0 ? 0x800 : 0x2) { /* ... */ } /* Actual commands. */ Result ResolveAddOnContentPath(sf::Out out, ncm::DataId id); diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp index ec73341cc..f2491f188 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.cpp @@ -25,16 +25,16 @@ namespace ams::lr { /* Helper function. */ void ContentLocationResolverImpl::GetContentStoragePath(Path *out, ncm::ContentId content_id) { static_assert(sizeof(lr::Path) == sizeof(ncm::Path)); - this->content_storage.GetPath(reinterpret_cast(out), content_id); + m_content_storage.GetPath(reinterpret_cast(out), content_id); } Result ContentLocationResolverImpl::ResolveProgramPath(sf::Out out, ncm::ProgramId id) { /* Use a redirection if present. */ - R_SUCCEED_IF(this->program_redirector.FindRedirection(out.GetPointer(), id)); + R_SUCCEED_IF(m_program_redirector.FindRedirection(out.GetPointer(), id)); /* Find the latest program content for the program id. */ ncm::ContentId program_content_id; - R_TRY_CATCH(this->content_meta_database.GetLatestProgram(std::addressof(program_content_id), id)) { + R_TRY_CATCH(m_content_meta_database.GetLatestProgram(std::addressof(program_content_id), id)) { R_CONVERT(ncm::ResultContentMetaNotFound, lr::ResultProgramNotFound()) } R_END_TRY_CATCH; @@ -45,24 +45,24 @@ namespace ams::lr { } Result ContentLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id) { - this->program_redirector.SetRedirection(id, path); + m_program_redirector.SetRedirection(id, path); return ResultSuccess(); } Result ContentLocationResolverImpl::ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->app_control_redirector.FindRedirection(out.GetPointer(), id), lr::ResultControlNotFound()); + R_UNLESS(m_app_control_redirector.FindRedirection(out.GetPointer(), id), lr::ResultControlNotFound()); return ResultSuccess(); } Result ContentLocationResolverImpl::ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->html_docs_redirector.FindRedirection(out.GetPointer(), id), lr::ResultHtmlDocumentNotFound()); + R_UNLESS(m_html_docs_redirector.FindRedirection(out.GetPointer(), id), lr::ResultHtmlDocumentNotFound()); return ResultSuccess(); } Result ContentLocationResolverImpl::ResolveDataPath(sf::Out out, ncm::DataId id) { /* Find the latest data content for the program id. */ ncm::ContentId data_content_id; - R_TRY(this->content_meta_database.GetLatestData(std::addressof(data_content_id), id)); + R_TRY(m_content_meta_database.GetLatestData(std::addressof(data_content_id), id)); /* Obtain the content path. */ this->GetContentStoragePath(out.GetPointer(), data_content_id); @@ -71,37 +71,37 @@ namespace ams::lr { } Result ContentLocationResolverImpl::RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) { - this->app_control_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_app_control_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->app_control_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_app_control_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - this->html_docs_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_html_docs_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->html_docs_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_html_docs_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->legal_info_redirector.FindRedirection(out.GetPointer(), id), lr::ResultLegalInformationNotFound()); + R_UNLESS(m_legal_info_redirector.FindRedirection(out.GetPointer(), id), lr::ResultLegalInformationNotFound()); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) { - this->legal_info_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_legal_info_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->legal_info_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_legal_info_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } @@ -109,12 +109,12 @@ namespace ams::lr { /* Obtain content meta database and content storage objects for this resolver's storage. */ ncm::ContentMetaDatabase meta_db; ncm::ContentStorage storage; - R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), this->storage_id)); - R_TRY(ncm::OpenContentStorage(std::addressof(storage), this->storage_id)); + R_TRY(ncm::OpenContentMetaDatabase(std::addressof(meta_db), m_storage_id)); + R_TRY(ncm::OpenContentStorage(std::addressof(storage), m_storage_id)); /* Store the acquired objects. */ - this->content_meta_database = std::move(meta_db); - this->content_storage = std::move(storage); + m_content_meta_database = std::move(meta_db); + m_content_storage = std::move(storage); /* Remove any existing redirections. */ this->ClearRedirections(); @@ -123,12 +123,12 @@ namespace ams::lr { } Result ContentLocationResolverImpl::RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) { - this->program_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } @@ -143,28 +143,28 @@ namespace ams::lr { } Result ContentLocationResolverImpl::EraseProgramRedirection(ncm::ProgramId id) { - this->program_redirector.EraseRedirection(id); + m_program_redirector.EraseRedirection(id); return ResultSuccess(); } Result ContentLocationResolverImpl::EraseApplicationControlRedirection(ncm::ProgramId id) { - this->app_control_redirector.EraseRedirection(id); + m_app_control_redirector.EraseRedirection(id); return ResultSuccess(); } Result ContentLocationResolverImpl::EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) { - this->html_docs_redirector.EraseRedirection(id); + m_html_docs_redirector.EraseRedirection(id); return ResultSuccess(); } Result ContentLocationResolverImpl::EraseApplicationLegalInformationRedirection(ncm::ProgramId id) { - this->legal_info_redirector.EraseRedirection(id); + m_legal_info_redirector.EraseRedirection(id); return ResultSuccess(); } Result ContentLocationResolverImpl::ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) { /* Use a redirection if present. */ - R_SUCCEED_IF(this->debug_program_redirector.FindRedirection(out.GetPointer(), id)); + R_SUCCEED_IF(m_debug_program_redirector.FindRedirection(out.GetPointer(), id)); /* Otherwise find the path for the program id. */ R_TRY_CATCH(this->ResolveProgramPath(out.GetPointer(), id)) { @@ -175,22 +175,22 @@ namespace ams::lr { } Result ContentLocationResolverImpl::RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) { - this->debug_program_redirector.SetRedirection(id, path); + m_debug_program_redirector.SetRedirection(id, path); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) { - this->debug_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_debug_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->debug_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_debug_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result ContentLocationResolverImpl::EraseProgramRedirectionForDebug(ncm::ProgramId id) { - this->debug_program_redirector.EraseRedirection(id); + m_debug_program_redirector.EraseRedirection(id); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp index 0d7a50e6b..9f02fe998 100644 --- a/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_content_location_resolver_impl.hpp @@ -21,13 +21,13 @@ namespace ams::lr { class ContentLocationResolverImpl : public LocationResolverImplBase { private: - ncm::StorageId storage_id; + ncm::StorageId m_storage_id; /* Objects for this storage type. */ - ncm::ContentMetaDatabase content_meta_database; - ncm::ContentStorage content_storage; + ncm::ContentMetaDatabase m_content_meta_database; + ncm::ContentStorage m_content_storage; public: - ContentLocationResolverImpl(ncm::StorageId storage_id) : storage_id(storage_id) { /* ... */ } + ContentLocationResolverImpl(ncm::StorageId storage_id) : m_storage_id(storage_id) { /* ... */ } ~ContentLocationResolverImpl(); private: diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp index fd4e34eb8..4a7859126 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.cpp @@ -22,38 +22,38 @@ namespace ams::lr { NON_COPYABLE(Redirection); NON_MOVEABLE(Redirection); private: - ncm::ProgramId program_id; - ncm::ProgramId owner_id; - Path path; - u32 flags; + ncm::ProgramId m_program_id; + ncm::ProgramId m_owner_id; + Path m_path; + u32 m_flags; public: Redirection(ncm::ProgramId program_id, ncm::ProgramId owner_id, const Path &path, u32 flags) : - program_id(program_id), owner_id(owner_id), path(path), flags(flags) { /* ... */ } + m_program_id(program_id), m_owner_id(owner_id), m_path(path), m_flags(flags) { /* ... */ } ncm::ProgramId GetProgramId() const { - return this->program_id; + return m_program_id; } ncm::ProgramId GetOwnerProgramId() const { - return this->owner_id; + return m_owner_id; } void GetPath(Path *out) const { - *out = this->path; + *out = m_path; } u32 GetFlags() const { - return this->flags; + return m_flags; } void SetFlags(u32 flags) { - this->flags = flags; + m_flags = flags; } }; bool LocationRedirector::FindRedirection(Path *out, ncm::ProgramId program_id) const { /* Obtain the path of a matching redirection. */ - for (const auto &redirection : this->redirection_list) { + for (const auto &redirection : m_redirection_list) { if (redirection.GetProgramId() == program_id) { redirection.GetPath(out); return true; @@ -71,12 +71,12 @@ namespace ams::lr { this->EraseRedirection(program_id); /* Insert a new redirection into the list. */ - this->redirection_list.push_back(*(new Redirection(program_id, owner_id, path, flags))); + m_redirection_list.push_back(*(new Redirection(program_id, owner_id, path, flags))); } void LocationRedirector::SetRedirectionFlags(ncm::ProgramId program_id, u32 flags) { /* Set the flags of a redirection with a matching program id. */ - for (auto &redirection : this->redirection_list) { + for (auto &redirection : m_redirection_list) { if (redirection.GetProgramId() == program_id) { redirection.SetFlags(flags); break; @@ -86,10 +86,10 @@ namespace ams::lr { void LocationRedirector::EraseRedirection(ncm::ProgramId program_id) { /* Remove any redirections with a matching program id. */ - for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) { + for (auto it = m_redirection_list.begin(); it != m_redirection_list.end();) { if (it->GetProgramId() == program_id) { auto *redirection = std::addressof(*it); - this->redirection_list.erase(it); + m_redirection_list.erase(it); delete redirection; break; } @@ -98,10 +98,10 @@ namespace ams::lr { void LocationRedirector::ClearRedirections(u32 flags) { /* Remove any redirections with matching flags. */ - for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) { + for (auto it = m_redirection_list.begin(); it != m_redirection_list.end();) { if ((it->GetFlags() & flags) == flags) { auto *redirection = std::addressof(*it); - it = this->redirection_list.erase(it); + it = m_redirection_list.erase(it); delete redirection; } else { it++; @@ -110,7 +110,7 @@ namespace ams::lr { } void LocationRedirector::ClearRedirectionsExcludingOwners(const ncm::ProgramId *excluding_ids, size_t num_ids) { - for (auto it = this->redirection_list.begin(); it != this->redirection_list.end();) { + for (auto it = m_redirection_list.begin(); it != m_redirection_list.end();) { /* Skip removal if the redirection has an excluded owner program id. */ if (this->IsExcluded(it->GetOwnerProgramId(), excluding_ids, num_ids)) { it++; @@ -119,7 +119,7 @@ namespace ams::lr { /* Remove the redirection. */ auto *redirection = std::addressof(*it); - it = this->redirection_list.erase(it); + it = m_redirection_list.erase(it); delete redirection; } } diff --git a/libraries/libstratosphere/source/lr/lr_location_redirector.hpp b/libraries/libstratosphere/source/lr/lr_location_redirector.hpp index 78e1bde55..5d30f95a7 100644 --- a/libraries/libstratosphere/source/lr/lr_location_redirector.hpp +++ b/libraries/libstratosphere/source/lr/lr_location_redirector.hpp @@ -32,9 +32,9 @@ namespace ams::lr { private: using RedirectionList = ams::util::IntrusiveListBaseTraits::ListType; private: - RedirectionList redirection_list; + RedirectionList m_redirection_list; public: - LocationRedirector() { /* ... */ } + LocationRedirector() : m_redirection_list() { /* ... */ } ~LocationRedirector() { this->ClearRedirections(); } /* API. */ diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp index ce4aac43c..08d9b4407 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_impl_base.hpp @@ -25,29 +25,29 @@ namespace ams::lr { NON_MOVEABLE(LocationResolverImplBase); protected: /* Location redirectors. */ - LocationRedirector program_redirector; - LocationRedirector debug_program_redirector; - LocationRedirector app_control_redirector; - LocationRedirector html_docs_redirector; - LocationRedirector legal_info_redirector; + LocationRedirector m_program_redirector; + LocationRedirector m_debug_program_redirector; + LocationRedirector m_app_control_redirector; + LocationRedirector m_html_docs_redirector; + LocationRedirector m_legal_info_redirector; protected: - LocationResolverImplBase() : program_redirector(), debug_program_redirector(), app_control_redirector(), html_docs_redirector(), legal_info_redirector() { /* ... */ } + LocationResolverImplBase() : m_program_redirector(), m_debug_program_redirector(), m_app_control_redirector(), m_html_docs_redirector(), m_legal_info_redirector() { /* ... */ } protected: /* Helper functions. */ void ClearRedirections(u32 flags = RedirectionFlags_None) { - this->program_redirector.ClearRedirections(flags); - this->debug_program_redirector.ClearRedirections(flags); - this->app_control_redirector.ClearRedirections(flags); - this->html_docs_redirector.ClearRedirections(flags); - this->legal_info_redirector.ClearRedirections(flags); + m_program_redirector.ClearRedirections(flags); + m_debug_program_redirector.ClearRedirections(flags); + m_app_control_redirector.ClearRedirections(flags); + m_html_docs_redirector.ClearRedirections(flags); + m_legal_info_redirector.ClearRedirections(flags); } void ClearRedirections(const ncm::ProgramId *excluding_ids, size_t num_ids) { - this->program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); - this->debug_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); - this->app_control_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); - this->html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); - this->legal_info_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_debug_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_app_control_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_legal_info_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); } }; diff --git a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp index 20afd4450..525267bff 100644 --- a/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_location_resolver_manager_impl.cpp @@ -30,22 +30,22 @@ namespace ams::lr { } Result LocationResolverManagerImpl::OpenLocationResolver(sf::Out> out, ncm::StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Find an existing resolver. */ - auto resolver = this->location_resolvers.Find(storage_id); + auto resolver = m_location_resolvers.Find(storage_id); /* No existing resolver is present, create one. */ if (!resolver) { if (storage_id == ncm::StorageId::Host) { - AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, RedirectOnlyLocationResolverFactory::CreateSharedEmplaced())); + AMS_ABORT_UNLESS(m_location_resolvers.Insert(storage_id, RedirectOnlyLocationResolverFactory::CreateSharedEmplaced())); } else { auto content_resolver = ContentLocationResolverFactory::CreateSharedEmplaced(storage_id); R_TRY(content_resolver->Refresh()); - AMS_ABORT_UNLESS(this->location_resolvers.Insert(storage_id, std::move(content_resolver))); + AMS_ABORT_UNLESS(m_location_resolvers.Insert(storage_id, std::move(content_resolver))); } /* Acquire the newly-created resolver. */ - resolver = this->location_resolvers.Find(storage_id); + resolver = m_location_resolvers.Find(storage_id); } /* Copy the output interface. */ @@ -54,23 +54,23 @@ namespace ams::lr { } Result LocationResolverManagerImpl::OpenRegisteredLocationResolver(sf::Out> out) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* No existing resolver is present, create one. */ - if (!this->registered_location_resolver) { - this->registered_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced(); + if (!m_registered_location_resolver) { + m_registered_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced(); } /* Copy the output interface. */ - *out = this->registered_location_resolver; + *out = m_registered_location_resolver; return ResultSuccess(); } Result LocationResolverManagerImpl::RefreshLocationResolver(ncm::StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Attempt to find an existing resolver. */ - auto resolver = this->location_resolvers.Find(storage_id); + auto resolver = m_location_resolvers.Find(storage_id); R_UNLESS(resolver, lr::ResultUnknownStorageId()); /* Refresh the resolver. */ @@ -82,15 +82,15 @@ namespace ams::lr { } Result LocationResolverManagerImpl::OpenAddOnContentLocationResolver(sf::Out> out) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* No existing resolver is present, create one. */ - if (!this->add_on_content_location_resolver) { - this->add_on_content_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced(); + if (!m_add_on_content_location_resolver) { + m_add_on_content_location_resolver = ContentLocationResolverFactory::CreateSharedEmplaced(); } /* Copy the output interface. */ - *out = this->add_on_content_location_resolver; + *out = m_add_on_content_location_resolver; return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp index 98c1473f1..c9ea4aa6e 100644 --- a/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_redirect_only_location_resolver_impl.cpp @@ -24,22 +24,22 @@ namespace ams::lr { } Result RedirectOnlyLocationResolverImpl::ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->program_redirector.FindRedirection(out.GetPointer(), id), lr::ResultProgramNotFound()); + R_UNLESS(m_program_redirector.FindRedirection(out.GetPointer(), id), lr::ResultProgramNotFound()); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id) { - this->program_redirector.SetRedirection(id, path); + m_program_redirector.SetRedirection(id, path); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->app_control_redirector.FindRedirection(out.GetPointer(), id), lr::ResultControlNotFound()); + R_UNLESS(m_app_control_redirector.FindRedirection(out.GetPointer(), id), lr::ResultControlNotFound()); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->html_docs_redirector.FindRedirection(out.GetPointer(), id), lr::ResultHtmlDocumentNotFound()); + R_UNLESS(m_html_docs_redirector.FindRedirection(out.GetPointer(), id), lr::ResultHtmlDocumentNotFound()); return ResultSuccess(); } @@ -49,37 +49,37 @@ namespace ams::lr { } Result RedirectOnlyLocationResolverImpl::RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) { - this->app_control_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_app_control_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->app_control_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_app_control_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - this->html_docs_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_html_docs_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->html_docs_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_html_docs_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(this->legal_info_redirector.FindRedirection(out.GetPointer(), id), lr::ResultLegalInformationNotFound()); + R_UNLESS(m_legal_info_redirector.FindRedirection(out.GetPointer(), id), lr::ResultLegalInformationNotFound()); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) { - this->legal_info_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_legal_info_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->legal_info_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_legal_info_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } @@ -89,12 +89,12 @@ namespace ams::lr { } Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) { - this->program_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } @@ -109,52 +109,52 @@ namespace ams::lr { } Result RedirectOnlyLocationResolverImpl::EraseProgramRedirection(ncm::ProgramId id) { - this->program_redirector.EraseRedirection(id); + m_program_redirector.EraseRedirection(id); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::EraseApplicationControlRedirection(ncm::ProgramId id) { - this->app_control_redirector.EraseRedirection(id); + m_app_control_redirector.EraseRedirection(id); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) { - this->html_docs_redirector.EraseRedirection(id); + m_html_docs_redirector.EraseRedirection(id); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::EraseApplicationLegalInformationRedirection(ncm::ProgramId id) { - this->legal_info_redirector.EraseRedirection(id); + m_legal_info_redirector.EraseRedirection(id); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::ResolveProgramPathForDebug(sf::Out out, ncm::ProgramId id) { /* If a debug program redirection is present, use it. */ - R_SUCCEED_IF(this->debug_program_redirector.FindRedirection(out.GetPointer(), id)); + R_SUCCEED_IF(m_debug_program_redirector.FindRedirection(out.GetPointer(), id)); /* Otherwise, try to find a normal program redirection. */ - R_UNLESS(this->program_redirector.FindRedirection(out.GetPointer(), id), lr::ResultDebugProgramNotFound()); + R_UNLESS(m_program_redirector.FindRedirection(out.GetPointer(), id), lr::ResultDebugProgramNotFound()); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) { - this->debug_program_redirector.SetRedirection(id, path); + m_debug_program_redirector.SetRedirection(id, path); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathForDebugDeprecated(const Path &path, ncm::ProgramId id) { - this->debug_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); + m_debug_program_redirector.SetRedirection(id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->debug_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); + m_debug_program_redirector.SetRedirection(id, owner_id, path, RedirectionFlags_Application); return ResultSuccess(); } Result RedirectOnlyLocationResolverImpl::EraseProgramRedirectionForDebug(ncm::ProgramId id) { - this->debug_program_redirector.EraseRedirection(id); + m_debug_program_redirector.EraseRedirection(id); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_registered_data.hpp b/libraries/libstratosphere/source/lr/lr_registered_data.hpp index 63db416fc..ffbb7f2b5 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_data.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_data.hpp @@ -31,8 +31,8 @@ namespace ams::lr { bool is_valid; }; private: - Entry entries[NumEntries]; - size_t capacity; + Entry m_entries[NumEntries]; + size_t m_capacity; private: inline bool IsExcluded(const ncm::ProgramId id, const ncm::ProgramId *excluding_ids, size_t num_ids) const { /* Try to find program id in exclusions. */ @@ -47,21 +47,21 @@ namespace ams::lr { inline void RegisterImpl(size_t i, const Key &key, const Value &value, const ncm::ProgramId owner_id) { /* Populate entry. */ - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; entry.key = key; entry.value = value; entry.owner_id = owner_id; entry.is_valid = true; } public: - RegisteredData(size_t capacity = NumEntries) : capacity(capacity) { + RegisteredData(size_t capacity = NumEntries) : m_capacity(capacity) { this->Clear(); } bool Register(const Key &key, const Value &value, const ncm::ProgramId owner_id) { /* Try to find an existing value. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; if (entry.is_valid && entry.key == key) { this->RegisterImpl(i, key, value, owner_id); return true; @@ -70,7 +70,7 @@ namespace ams::lr { /* We didn't find an existing entry, so try to create a new one. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; if (!entry.is_valid) { this->RegisterImpl(i, key, value, owner_id); return true; @@ -83,7 +83,7 @@ namespace ams::lr { void Unregister(const Key &key) { /* Invalidate entries with a matching key. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; if (entry.is_valid && entry.key == key) { entry.is_valid = false; } @@ -93,7 +93,7 @@ namespace ams::lr { void UnregisterOwnerProgram(ncm::ProgramId owner_id) { /* Invalidate entries with a matching owner id. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; if (entry.owner_id == owner_id) { entry.is_valid = false; } @@ -103,7 +103,7 @@ namespace ams::lr { bool Find(Value *out, const Key &key) const { /* Locate a matching entry. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - const Entry &entry = this->entries[i]; + const Entry &entry = m_entries[i]; if (entry.is_valid && entry.key == key) { *out = entry.value; return true; @@ -116,14 +116,14 @@ namespace ams::lr { void Clear() { /* Invalidate all entries. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - this->entries[i].is_valid = false; + m_entries[i].is_valid = false; } } void ClearExcluding(const ncm::ProgramId *ids, size_t num_ids) { /* Invalidate all entries unless excluded. */ for (size_t i = 0; i < this->GetCapacity(); i++) { - Entry &entry = this->entries[i]; + Entry &entry = m_entries[i]; if (!this->IsExcluded(entry.owner_id, ids, num_ids)) { entry.is_valid = false; @@ -132,7 +132,7 @@ namespace ams::lr { } size_t GetCapacity() const { - return this->capacity; + return m_capacity; } }; diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp index b4b7a5c71..5fbb54611 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.cpp @@ -53,8 +53,8 @@ namespace ams::lr { /* Helper function. */ void RegisteredLocationResolverImpl::ClearRedirections(u32 flags) { - this->html_docs_redirector.ClearRedirections(flags); - this->program_redirector.ClearRedirections(flags); + m_html_docs_redirector.ClearRedirections(flags); + m_program_redirector.ClearRedirections(flags); } Result RegisteredLocationResolverImpl::RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids) { @@ -66,76 +66,76 @@ namespace ams::lr { if (num_ids) { /* If we have exclusion lists, explicitly clear our locations. */ - this->registered_program_locations.ClearExcluding(excluding_ids, num_ids); - this->registered_html_docs_locations.ClearExcluding(excluding_ids, num_ids); + m_registered_program_locations.ClearExcluding(excluding_ids, num_ids); + m_registered_html_docs_locations.ClearExcluding(excluding_ids, num_ids); } else { /* If we don't, just perform a general clear (as pre 9.0.0 did). */ this->ClearRedirections(); } /* Clear redirectors using exclusion lists. */ - this->program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); - this->html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_program_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); + m_html_docs_redirector.ClearRedirectionsExcludingOwners(excluding_ids, num_ids); return ResultSuccess(); } Result RegisteredLocationResolverImpl::ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(ResolvePath(out.GetPointer(), this->program_redirector, this->registered_program_locations, id), lr::ResultProgramNotFound()); + R_UNLESS(ResolvePath(out.GetPointer(), m_program_redirector, m_registered_program_locations, id), lr::ResultProgramNotFound()); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) { - RegisterPath(this->registered_program_locations, id, path, ncm::InvalidProgramId); + RegisterPath(m_registered_program_locations, id, path, ncm::InvalidProgramId); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - RegisterPath(this->registered_program_locations, id, path, owner_id); + RegisterPath(m_registered_program_locations, id, path, owner_id); return ResultSuccess(); } Result RegisteredLocationResolverImpl::UnregisterProgramPath(ncm::ProgramId id) { - this->registered_program_locations.Unregister(id); + m_registered_program_locations.Unregister(id); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RedirectProgramPathDeprecated(const Path &path, ncm::ProgramId id) { - this->program_redirector.SetRedirection(id, path); + m_program_redirector.SetRedirection(id, path); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->program_redirector.SetRedirection(id, owner_id, path); + m_program_redirector.SetRedirection(id, owner_id, path); return ResultSuccess(); } Result RegisteredLocationResolverImpl::ResolveHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { - R_UNLESS(ResolvePath(out.GetPointer(), this->html_docs_redirector, this->registered_html_docs_locations, id), lr::ResultHtmlDocumentNotFound()); + R_UNLESS(ResolvePath(out.GetPointer(), m_html_docs_redirector, m_registered_html_docs_locations, id), lr::ResultHtmlDocumentNotFound()); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RegisterHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - RegisterPath(this->registered_html_docs_locations, id, path, ncm::InvalidProgramId); + RegisterPath(m_registered_html_docs_locations, id, path, ncm::InvalidProgramId); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - RegisterPath(this->registered_html_docs_locations, id, path, owner_id); + RegisterPath(m_registered_html_docs_locations, id, path, owner_id); return ResultSuccess(); } Result RegisteredLocationResolverImpl::UnregisterHtmlDocumentPath(ncm::ProgramId id) { - this->registered_html_docs_locations.Unregister(id); + m_registered_html_docs_locations.Unregister(id); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RedirectHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - this->html_docs_redirector.SetRedirection(id, path); + m_html_docs_redirector.SetRedirection(id, path); return ResultSuccess(); } Result RegisteredLocationResolverImpl::RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - this->html_docs_redirector.SetRedirection(id, owner_id, path); + m_html_docs_redirector.SetRedirection(id, owner_id, path); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp index 747420d7a..bfd3cb186 100644 --- a/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_registered_location_resolver_impl.hpp @@ -36,16 +36,16 @@ namespace ams::lr { } private: /* Redirection and registered location storage. */ - LocationRedirector program_redirector; - RegisteredLocations registered_program_locations; - LocationRedirector html_docs_redirector; - RegisteredLocations registered_html_docs_locations; + LocationRedirector m_program_redirector; + RegisteredLocations m_registered_program_locations; + LocationRedirector m_html_docs_redirector; + RegisteredLocations m_registered_html_docs_locations; private: /* Helper functions. */ void ClearRedirections(u32 flags = RedirectionFlags_None); Result RefreshImpl(const ncm::ProgramId *excluding_ids, size_t num_ids); public: - RegisteredLocationResolverImpl() : registered_program_locations(GetMaxRegisteredLocations()), registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ } + RegisteredLocationResolverImpl() : m_registered_program_locations(GetMaxRegisteredLocations()), m_registered_html_docs_locations(GetMaxRegisteredLocations()) { /* ... */ } ~RegisteredLocationResolverImpl(); public: /* Actual commands. */ diff --git a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp index 500e2757a..b84003098 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_location_resolver_impl.hpp @@ -20,63 +20,63 @@ namespace ams::lr { class RemoteLocationResolverImpl { private: - ::LrLocationResolver srv; + ::LrLocationResolver m_srv; public: - RemoteLocationResolverImpl(::LrLocationResolver &l) : srv(l) { /* ... */ } + RemoteLocationResolverImpl(::LrLocationResolver &l) : m_srv(l) { /* ... */ } - ~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); } + ~RemoteLocationResolverImpl() { ::serviceClose(std::addressof(m_srv.s)); } public: /* Actual commands. */ Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveProgramPath(std::addressof(this->srv), id.value, out->str); + return ::lrLrResolveProgramPath(std::addressof(m_srv), id.value, out->str); } Result RedirectProgramPath(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectProgramPath(std::addressof(this->srv), id.value, path.str); + return ::lrLrRedirectProgramPath(std::addressof(m_srv), id.value, path.str); } Result ResolveApplicationControlPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationControlPath(std::addressof(this->srv), id.value, out->str); + return ::lrLrResolveApplicationControlPath(std::addressof(m_srv), id.value, out->str); } Result ResolveApplicationHtmlDocumentPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, out->str); + return ::lrLrResolveApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, out->str); } Result ResolveDataPath(sf::Out out, ncm::DataId id) { - return ::lrLrResolveDataPath(std::addressof(this->srv), id.value, out->str); + return ::lrLrResolveDataPath(std::addressof(m_srv), id.value, out->str); } Result RedirectApplicationControlPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, 0, path.str); + return ::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, 0, path.str); } Result RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationControlPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + return ::lrLrRedirectApplicationControlPath(std::addressof(m_srv), id.value, owner_id.value, path.str); } Result RedirectApplicationHtmlDocumentPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, 0, path.str); + return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, 0, path.str); } Result RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + return ::lrLrRedirectApplicationHtmlDocumentPath(std::addressof(m_srv), id.value, owner_id.value, path.str); } Result ResolveApplicationLegalInformationPath(sf::Out out, ncm::ProgramId id) { - return ::lrLrResolveApplicationLegalInformationPath(std::addressof(this->srv), id.value, out->str); + return ::lrLrResolveApplicationLegalInformationPath(std::addressof(m_srv), id.value, out->str); } Result RedirectApplicationLegalInformationPathDeprecated(const Path &path, ncm::ProgramId id) { - return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, 0, path.str); + return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, 0, path.str); } Result RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) { - return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(this->srv), id.value, owner_id.value, path.str); + return ::lrLrRedirectApplicationLegalInformationPath(std::addressof(m_srv), id.value, owner_id.value, path.str); } Result Refresh() { - return ::lrLrRefresh(std::addressof(this->srv)); + return ::lrLrRefresh(std::addressof(m_srv)); } Result RedirectApplicationProgramPathDeprecated(const Path &path, ncm::ProgramId id) { @@ -103,7 +103,7 @@ namespace ams::lr { } Result EraseProgramRedirection(ncm::ProgramId id) { - return ::lrLrEraseProgramRedirection(std::addressof(this->srv), id.value); + return ::lrLrEraseProgramRedirection(std::addressof(m_srv), id.value); } Result EraseApplicationControlRedirection(ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp index e57a78faf..20687a5c0 100644 --- a/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp +++ b/libraries/libstratosphere/source/lr/lr_remote_registered_location_resolver_impl.hpp @@ -21,15 +21,15 @@ namespace ams::lr { class RemoteRegisteredLocationResolverImpl { private: - ::LrRegisteredLocationResolver srv; + ::LrRegisteredLocationResolver m_srv; public: - RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : srv(l) { /* ... */ } + RemoteRegisteredLocationResolverImpl(::LrRegisteredLocationResolver &l) : m_srv(l) { /* ... */ } - ~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(srv.s)); } + ~RemoteRegisteredLocationResolverImpl() { ::serviceClose(std::addressof(m_srv.s)); } public: /* Actual commands. */ Result ResolveProgramPath(sf::Out out, ncm::ProgramId id) { - return ::lrRegLrResolveProgramPath(std::addressof(this->srv), static_cast(id), out->str); + return ::lrRegLrResolveProgramPath(std::addressof(m_srv), id.value, out->str); } Result RegisterProgramPathDeprecated(const Path &path, ncm::ProgramId id) { diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp index e379a57b6..4a4bf2ae7 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_cached_heap.cpp @@ -21,43 +21,43 @@ namespace ams::mem::impl::heap { void *CachedHeap::Allocate(size_t n) { - return this->tls_heap_cache->Allocate(n); + return m_tls_heap_cache->Allocate(n); } void *CachedHeap::Allocate(size_t n, size_t align) { - return this->tls_heap_cache->Allocate(n, align); + return m_tls_heap_cache->Allocate(n, align); } size_t CachedHeap::GetAllocationSize(const void *ptr) { - return this->tls_heap_cache->GetAllocationSize(ptr); + return m_tls_heap_cache->GetAllocationSize(ptr); } errno_t CachedHeap::Free(void *p) { - return this->tls_heap_cache->Free(p); + return m_tls_heap_cache->Free(p); } errno_t CachedHeap::FreeWithSize(void *p, size_t size) { - return this->tls_heap_cache->FreeWithSize(p, size); + return m_tls_heap_cache->FreeWithSize(p, size); } errno_t CachedHeap::Reallocate(void *ptr, size_t size, void **p) { - return this->tls_heap_cache->Reallocate(ptr, size, p); + return m_tls_heap_cache->Reallocate(ptr, size, p); } errno_t CachedHeap::Shrink(void *ptr, size_t size) { - return this->tls_heap_cache->Shrink(ptr, size); + return m_tls_heap_cache->Shrink(ptr, size); } void CachedHeap::ReleaseAllCache() { - if (this->tls_heap_cache) { - this->tls_heap_cache->ReleaseAllCache(); + if (m_tls_heap_cache) { + m_tls_heap_cache->ReleaseAllCache(); } } void CachedHeap::Finalize() { - if (this->tls_heap_cache) { - this->tls_heap_cache->Finalize(); - this->tls_heap_cache = nullptr; + if (m_tls_heap_cache) { + m_tls_heap_cache->Finalize(); + m_tls_heap_cache = nullptr; } } @@ -78,7 +78,7 @@ namespace ams::mem::impl::heap { { bool *out = va_arg(vl, bool *); if (out) { - *out = (this->tls_heap_cache == nullptr) || this->tls_heap_cache->CheckCache(); + *out = (m_tls_heap_cache == nullptr) || m_tls_heap_cache->CheckCache(); } return 0; } @@ -107,12 +107,12 @@ namespace ams::mem::impl::heap { void CachedHeap::Reset(TlsHeapCache *thc) { this->Finalize(); - this->tls_heap_cache = thc; + m_tls_heap_cache = thc; } TlsHeapCache *CachedHeap::Release() { - TlsHeapCache *ret = this->tls_heap_cache; - this->tls_heap_cache = nullptr; + TlsHeapCache *ret = m_tls_heap_cache; + m_tls_heap_cache = nullptr; return ret; } diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp index f9ef0d319..e52b05348 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_central_heap.cpp @@ -27,7 +27,7 @@ namespace ams::mem::impl::heap { } /* Don't allow initializing twice. */ - if (this->start) { + if (m_start) { return EEXIST; } @@ -39,17 +39,17 @@ namespace ams::mem::impl::heap { return EINVAL; } - this->start = aligned_start; - this->end = aligned_end; - this->option = option; - this->tls_heap_central = std::construct_at(reinterpret_cast(this->start)); - if (auto err = this->tls_heap_central->Initialize(this->start, this->end - this->start, false); err != 0) { - std::destroy_at(this->tls_heap_central); - this->tls_heap_central = nullptr; + m_start = aligned_start; + m_end = aligned_end; + m_option = option; + m_tls_heap_central = std::construct_at(reinterpret_cast(m_start)); + if (auto err = m_tls_heap_central->Initialize(m_start, m_end - m_start, false); err != 0) { + std::destroy_at(m_tls_heap_central); + m_tls_heap_central = nullptr; AMS_ASSERT(err == 0); return err; } - this->use_virtual_memory = false; + m_use_virtual_memory = false; } else { /* We were not provided with a region to use as backing. */ void *mem = nullptr; @@ -63,39 +63,39 @@ namespace ams::mem::impl::heap { return err; } } - this->start = static_cast(mem); - this->end = this->start + size; - this->option = option; + m_start = static_cast(mem); + m_end = m_start + size; + m_option = option; void *central = reinterpret_cast(util::AlignUp(reinterpret_cast(mem), PageSize)); if (auto err = AllocatePhysicalMemory(central, sizeof(TlsHeapCentral)); err != 0) { return err; } - this->tls_heap_central = std::construct_at(static_cast(central)); - if (auto err = this->tls_heap_central->Initialize(central, size, true); err != 0) { - std::destroy_at(this->tls_heap_central); - this->tls_heap_central = nullptr; + m_tls_heap_central = std::construct_at(static_cast(central)); + if (auto err = m_tls_heap_central->Initialize(central, size, true); err != 0) { + std::destroy_at(m_tls_heap_central); + m_tls_heap_central = nullptr; AMS_ASSERT(err == 0); return err; } - this->use_virtual_memory = true; + m_use_virtual_memory = true; } return 0; } void CentralHeap::Finalize() { - if (this->tls_heap_central) { - std::destroy_at(this->tls_heap_central); + if (m_tls_heap_central) { + std::destroy_at(m_tls_heap_central); } - if (this->use_virtual_memory) { - mem::impl::physical_free(util::AlignUp(static_cast(this->start), PageSize), this->end - this->start); - mem::impl::virtual_free(this->start, this->end - this->start); + if (m_use_virtual_memory) { + mem::impl::physical_free(util::AlignUp(static_cast(m_start), PageSize), m_end - m_start); + mem::impl::virtual_free(m_start, m_end - m_start); } - this->tls_heap_central = nullptr; - this->use_virtual_memory = false; - this->option = 0; - this->start = nullptr; - this->end = nullptr; + m_tls_heap_central = nullptr; + m_use_virtual_memory = false; + m_option = 0; + m_start = nullptr; + m_end = nullptr; } void *CentralHeap::Allocate(size_t n, size_t align) { @@ -106,23 +106,23 @@ namespace ams::mem::impl::heap { return nullptr; } if (align > PageSize) { - return this->tls_heap_central->CacheLargeMemoryWithBigAlign(util::AlignUp(n, PageSize), align); + return m_tls_heap_central->CacheLargeMemoryWithBigAlign(util::AlignUp(n, PageSize), align); } const size_t real_size = TlsHeapStatic::GetRealSizeFromSizeAndAlignment(util::AlignUp(n, align), align); const auto cls = TlsHeapStatic::GetClassFromSize(real_size); if (!cls) { - return this->tls_heap_central->CacheLargeMemory(real_size); + return m_tls_heap_central->CacheLargeMemory(real_size); } if (real_size == 0) { return nullptr; } AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); - return this->tls_heap_central->CacheSmallMemory(cls, align); + return m_tls_heap_central->CacheSmallMemory(cls, align); } size_t CentralHeap::GetAllocationSize(const void *ptr) { - const auto cls = this->tls_heap_central->GetClassFromPointer(ptr); + const auto cls = m_tls_heap_central->GetClassFromPointer(ptr); if (cls > 0) { /* Check that the pointer has alignment from out allocator. */ if (!util::IsAligned(reinterpret_cast(ptr), MinimumAlignment)) { @@ -131,7 +131,7 @@ namespace ams::mem::impl::heap { AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); return TlsHeapStatic::GetChunkSize(cls); } else if (ptr != nullptr) { - return this->tls_heap_central->GetAllocationSize(ptr); + return m_tls_heap_central->GetAllocationSize(ptr); } else { return 0; } @@ -149,13 +149,13 @@ namespace ams::mem::impl::heap { return EFAULT; } - const auto cls = this->tls_heap_central->GetClassFromPointer(ptr); + const auto cls = m_tls_heap_central->GetClassFromPointer(ptr); if (cls >= 0) { AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); if (cls) { - return this->tls_heap_central->UncacheSmallMemory(ptr); + return m_tls_heap_central->UncacheSmallMemory(ptr); } else { - return this->tls_heap_central->UncacheLargeMemory(ptr); + return m_tls_heap_central->UncacheLargeMemory(ptr); } } else { AMS_ASSERT(cls >= 0); @@ -165,9 +165,9 @@ namespace ams::mem::impl::heap { errno_t CentralHeap::FreeWithSize(void *ptr, size_t size) { if (TlsHeapStatic::GetClassFromSize(size)) { - return this->tls_heap_central->UncacheSmallMemory(ptr); + return m_tls_heap_central->UncacheSmallMemory(ptr); } else { - return this->tls_heap_central->UncacheLargeMemory(ptr); + return m_tls_heap_central->UncacheLargeMemory(ptr); } } @@ -181,7 +181,7 @@ namespace ams::mem::impl::heap { } const auto cls_from_size = TlsHeapStatic::GetClassFromSize(size); - const auto cls_from_ptr = this->tls_heap_central->GetClassFromPointer(ptr); + const auto cls_from_ptr = m_tls_heap_central->GetClassFromPointer(ptr); if (cls_from_ptr) { if (cls_from_ptr <= 0) { return EFAULT; @@ -193,7 +193,7 @@ namespace ams::mem::impl::heap { *p = this->Allocate(new_chunk_size); if (*p) { std::memcpy(*p, ptr, size); - return this->tls_heap_central->UncacheSmallMemory(ptr); + return m_tls_heap_central->UncacheSmallMemory(ptr); } else { return ENOMEM; } @@ -202,12 +202,12 @@ namespace ams::mem::impl::heap { *p = this->Allocate(size); if (*p) { std::memcpy(*p, ptr, size); - return this->tls_heap_central->UncacheLargeMemory(ptr); + return m_tls_heap_central->UncacheLargeMemory(ptr); } else { return ENOMEM; } } else { - return this->tls_heap_central->ReallocateLargeMemory(ptr, size, p); + return m_tls_heap_central->ReallocateLargeMemory(ptr, size, p); } } @@ -221,7 +221,7 @@ namespace ams::mem::impl::heap { } const auto cls_from_size = TlsHeapStatic::GetClassFromSize(size); - const auto cls_from_ptr = this->tls_heap_central->GetClassFromPointer(ptr); + const auto cls_from_ptr = m_tls_heap_central->GetClassFromPointer(ptr); if (cls_from_ptr) { if (cls_from_ptr <= 0) { return EFAULT; @@ -231,9 +231,9 @@ namespace ams::mem::impl::heap { return EINVAL; } } else if (cls_from_size) { - return this->tls_heap_central->ShrinkLargeMemory(ptr, PageSize); + return m_tls_heap_central->ShrinkLargeMemory(ptr, PageSize); } else { - return this->tls_heap_central->ShrinkLargeMemory(ptr, size); + return m_tls_heap_central->ShrinkLargeMemory(ptr, size); } } @@ -242,16 +242,16 @@ namespace ams::mem::impl::heap { return false; } - AMS_ASSERT(this->tls_heap_central != nullptr); + AMS_ASSERT(m_tls_heap_central != nullptr); const auto cls = TlsHeapStatic::GetClassFromSize(sizeof(*cached_heap)); - void *tls_heap_cache = this->tls_heap_central->CacheSmallMemoryForSystem(cls); + void *tls_heap_cache = m_tls_heap_central->CacheSmallMemoryForSystem(cls); if (tls_heap_cache == nullptr) { return false; } - std::construct_at(static_cast(tls_heap_cache), this->tls_heap_central, this->option); - if (this->tls_heap_central->AddThreadCache(reinterpret_cast(tls_heap_cache)) != 0) { - this->tls_heap_central->UncacheSmallMemory(tls_heap_cache); + std::construct_at(static_cast(tls_heap_cache), m_tls_heap_central, m_option); + if (m_tls_heap_central->AddThreadCache(reinterpret_cast(tls_heap_cache)) != 0) { + m_tls_heap_central->UncacheSmallMemory(tls_heap_cache); return false; } @@ -260,10 +260,10 @@ namespace ams::mem::impl::heap { } errno_t CentralHeap::WalkAllocatedPointers(HeapWalkCallback callback, void *user_data) { - if (!callback || !this->tls_heap_central) { + if (!callback || !m_tls_heap_central) { return EINVAL; } - return this->tls_heap_central->WalkAllocatedPointers(callback, user_data); + return m_tls_heap_central->WalkAllocatedPointers(callback, user_data); } errno_t CentralHeap::QueryV(int query, std::va_list vl) { @@ -286,8 +286,8 @@ namespace ams::mem::impl::heap { { auto dump_mode = static_cast(va_arg(*vl_ptr, int)); auto fd = va_arg(*vl_ptr, int); - if (this->tls_heap_central) { - this->tls_heap_central->Dump(dump_mode, fd, query == AllocQuery_DumpJson); + if (m_tls_heap_central) { + m_tls_heap_central->Dump(dump_mode, fd, query == AllocQuery_DumpJson); } return 0; } @@ -308,12 +308,12 @@ namespace ams::mem::impl::heap { if (!out) { return 0; } - if (!this->tls_heap_central) { + if (!m_tls_heap_central) { *out = 0; return 0; } TlsHeapMemStats stats; - this->tls_heap_central->GetMemStats(std::addressof(stats)); + m_tls_heap_central->GetMemStats(std::addressof(stats)); switch (query) { case AllocQuery_AllocatedSize: default: @@ -335,7 +335,7 @@ namespace ams::mem::impl::heap { { int *out = va_arg(*vl_ptr, int *); if (out) { - *out = !this->tls_heap_central || this->tls_heap_central->IsClean(); + *out = !m_tls_heap_central || m_tls_heap_central->IsClean(); } return 0; } @@ -343,8 +343,8 @@ namespace ams::mem::impl::heap { { HeapHash *out = va_arg(*vl_ptr, HeapHash *); if (out) { - if (this->tls_heap_central) { - this->tls_heap_central->CalculateHeapHash(out); + if (m_tls_heap_central) { + m_tls_heap_central->CalculateHeapHash(out); } else { *out = {}; } @@ -353,28 +353,28 @@ namespace ams::mem::impl::heap { } case AllocQuery_UnifyFreeList: /* NOTE: Nintendo does not check that the ptr is not null for this query, even though they do for other queries. */ - this->tls_heap_central->IsClean(); + m_tls_heap_central->IsClean(); return 0; case AllocQuery_SetColor: { /* NOTE: Nintendo does not check that the ptr is not null for this query, even though they do for other queries. */ void *ptr = va_arg(*vl_ptr, void *); int color = va_arg(*vl_ptr, int); - return this->tls_heap_central->SetColor(ptr, color); + return m_tls_heap_central->SetColor(ptr, color); } case AllocQuery_GetColor: { /* NOTE: Nintendo does not check that the ptr is not null for this query, even though they do for other queries. */ void *ptr = va_arg(*vl_ptr, void *); int *out = va_arg(*vl_ptr, int *); - return this->tls_heap_central->GetColor(ptr, out); + return m_tls_heap_central->GetColor(ptr, out); } case AllocQuery_SetName: { /* NOTE: Nintendo does not check that the ptr is not null for this query, even though they do for other queries. */ void *ptr = va_arg(*vl_ptr, void *); const char *name = va_arg(*vl_ptr, const char *); - return this->tls_heap_central->SetName(ptr, name); + return m_tls_heap_central->SetName(ptr, name); } case AllocQuery_GetName: { @@ -382,7 +382,7 @@ namespace ams::mem::impl::heap { void *ptr = va_arg(*vl_ptr, void *); char *dst = va_arg(*vl_ptr, char *); size_t dst_size = va_arg(*vl_ptr, size_t); - return this->tls_heap_central->GetName(ptr, dst, dst_size); + return m_tls_heap_central->GetName(ptr, dst, dst_size); } case AllocQuery_FreeSizeMapped: case AllocQuery_MaxAllocatableSizeMapped: @@ -391,7 +391,7 @@ namespace ams::mem::impl::heap { size_t *out = va_arg(*vl_ptr, size_t *); size_t free_size; size_t max_allocatable_size; - auto err = this->tls_heap_central->GetMappedMemStats(std::addressof(free_size), std::addressof(max_allocatable_size)); + auto err = m_tls_heap_central->GetMappedMemStats(std::addressof(free_size), std::addressof(max_allocatable_size)); if (err == 0) { if (query == AllocQuery_FreeSizeMapped) { *out = free_size; diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.cpp index 3e730bc3f..4727cdcf0 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.cpp @@ -24,54 +24,54 @@ namespace ams::mem::impl::heap { TlsHeapCache::TlsHeapCache(TlsHeapCentral *central, u32 option) { /* Choose function impls based on option. */ if ((option & HeapOption_DisableCache) != 0) { - this->allocate = AllocateImpl; - this->allocate_aligned = AllocateAlignedImpl; - this->free = FreeImpl; - this->free_with_size = FreeWithSizeImpl; - this->get_allocation_size = GetAllocationSizeImpl; - this->reallocate = ReallocateImpl; - this->shrink = ShrinkImpl; + m_allocate = AllocateImpl; + m_allocate_aligned = AllocateAlignedImpl; + m_free = FreeImpl; + m_free_with_size = FreeWithSizeImpl; + m_get_allocation_size = GetAllocationSizeImpl; + m_reallocate = ReallocateImpl; + m_shrink = ShrinkImpl; } else { - this->allocate = AllocateImpl; - this->allocate_aligned = AllocateAlignedImpl; - this->free = FreeImpl; - this->free_with_size = FreeWithSizeImpl; - this->get_allocation_size = GetAllocationSizeImpl; - this->reallocate = ReallocateImpl; - this->shrink = ShrinkImpl; + m_allocate = AllocateImpl; + m_allocate_aligned = AllocateAlignedImpl; + m_free = FreeImpl; + m_free_with_size = FreeWithSizeImpl; + m_get_allocation_size = GetAllocationSizeImpl; + m_reallocate = ReallocateImpl; + m_shrink = ShrinkImpl; } /* Generate random bytes to mangle pointers. */ - if (auto err = gen_random(std::addressof(this->mangle_val), sizeof(this->mangle_val)); err != 0) { + if (auto err = gen_random(std::addressof(m_mangle_val), sizeof(m_mangle_val)); err != 0) { s64 epoch_time; epochtime(std::addressof(epoch_time)); - this->mangle_val = reinterpret_cast(std::addressof(epoch_time)) ^ static_cast(epoch_time); + m_mangle_val = reinterpret_cast(std::addressof(epoch_time)) ^ static_cast(epoch_time); } /* Set member variables. */ - this->central = central; - this->total_heap_size = central->GetTotalHeapSize(); - this->heap_option = option; - this->total_cached_size = 0; - this->largest_class = 0; + m_central = central; + m_total_heap_size = central->GetTotalHeapSize(); + m_heap_option = option; + m_total_cached_size = 0; + m_largest_class = 0; /* Setup chunks. */ for (size_t i = 0; i < TlsHeapStatic::NumClassInfo; i++) { - this->small_mem_lists[i] = nullptr; - this->cached_size[i] = 0; - this->chunk_count[i] = 1; + m_small_mem_lists[i] = nullptr; + m_cached_size[i] = 0; + m_chunk_count[i] = 1; } /* Set fixed chunk counts for particularly small chunks. */ - this->chunk_count[1] = MaxChunkCount; - this->chunk_count[2] = MaxChunkCount; - this->chunk_count[3] = MaxChunkCount; - this->chunk_count[4] = MaxChunkCount / 2; - this->chunk_count[5] = MaxChunkCount / 2; - this->chunk_count[6] = MaxChunkCount / 2; - this->chunk_count[7] = MaxChunkCount / 4; - this->chunk_count[8] = MaxChunkCount / 4; - this->chunk_count[9] = MaxChunkCount / 4; + m_chunk_count[1] = MaxChunkCount; + m_chunk_count[2] = MaxChunkCount; + m_chunk_count[3] = MaxChunkCount; + m_chunk_count[4] = MaxChunkCount / 2; + m_chunk_count[5] = MaxChunkCount / 2; + m_chunk_count[6] = MaxChunkCount / 2; + m_chunk_count[7] = MaxChunkCount / 4; + m_chunk_count[8] = MaxChunkCount / 4; + m_chunk_count[9] = MaxChunkCount / 4; } void TlsHeapCache::Finalize() { @@ -79,15 +79,15 @@ namespace ams::mem::impl::heap { this->ReleaseAllCache(); /* Remove this cache from the owner central heap. */ - this->central->RemoveThreadCache(this); - this->central->UncacheSmallMemory(this); + m_central->RemoveThreadCache(this); + m_central->UncacheSmallMemory(this); } bool TlsHeapCache::CheckCache() const { - for (size_t i = 0; i < util::size(this->small_mem_lists); i++) { - void *ptr = this->small_mem_lists[i]; + for (size_t i = 0; i < util::size(m_small_mem_lists); i++) { + void *ptr = m_small_mem_lists[i]; if (ptr) { - s64 depth = -static_cast(this->cached_size[i] / TlsHeapStatic::GetChunkSize(i)); + s64 depth = -static_cast(m_cached_size[i] / TlsHeapStatic::GetChunkSize(i)); while (ptr) { ptr = *reinterpret_cast(this->ManglePointer(ptr)); if ((++depth) == 0) { @@ -102,20 +102,20 @@ namespace ams::mem::impl::heap { } void TlsHeapCache::ReleaseAllCache() { - for (size_t i = 0; i < util::size(this->small_mem_lists); i++) { - if (this->small_mem_lists[i]) { - this->central->UncacheSmallMemoryList(this, this->small_mem_lists[i]); - this->small_mem_lists[i] = nullptr; - this->cached_size[i] = 0; + for (size_t i = 0; i < util::size(m_small_mem_lists); i++) { + if (m_small_mem_lists[i]) { + m_central->UncacheSmallMemoryList(this, m_small_mem_lists[i]); + m_small_mem_lists[i] = nullptr; + m_cached_size[i] = 0; } } - this->total_cached_size = 0; - this->largest_class = 0; + m_total_cached_size = 0; + m_largest_class = 0; } template<> - void *TlsHeapCache::AllocateImpl(TlsHeapCache *_this, size_t size) { + void *TlsHeapCache::AllocateImpl(TlsHeapCache *tls_heap_cache, size_t size) { /* Validate allocation size. */ if (size == 0 || size > MaxSize) { return nullptr; @@ -123,18 +123,18 @@ namespace ams::mem::impl::heap { if (const size_t cls = TlsHeapStatic::GetClassFromSize(size); cls != 0) { AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); - return _this->central->CacheSmallMemory(cls); + return tls_heap_cache->m_central->CacheSmallMemory(cls); } else { /* If allocating a huge size, release our cache. */ - if (size >= _this->total_heap_size / 4) { - _this->ReleaseAllCache(); + if (size >= tls_heap_cache->m_total_heap_size / 4) { + tls_heap_cache->ReleaseAllCache(); } - return _this->central->CacheLargeMemory(size); + return tls_heap_cache->m_central->CacheLargeMemory(size); } } template<> - void *TlsHeapCache::AllocateImpl(TlsHeapCache *_this, size_t size) { + void *TlsHeapCache::AllocateImpl(TlsHeapCache *tls_heap_cache, size_t size) { /* Validate allocation size. */ if (size == 0 || size > MaxSize) { return nullptr; @@ -143,12 +143,12 @@ namespace ams::mem::impl::heap { if (size_t cls = TlsHeapStatic::GetClassFromSize(size); cls != 0) { AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); /* Allocate a chunk. */ - void *ptr = _this->small_mem_lists[cls]; + void *ptr = tls_heap_cache->m_small_mem_lists[cls]; if (ptr == nullptr) { const size_t prev_cls = cls; - size_t count = _this->chunk_count[cls]; + size_t count = tls_heap_cache->m_chunk_count[cls]; - size_t n = _this->central->CacheSmallMemoryList(_this, std::addressof(cls), count, std::addressof(ptr)); + size_t n = tls_heap_cache->m_central->CacheSmallMemoryList(tls_heap_cache, std::addressof(cls), count, std::addressof(ptr)); if (n == 0) { return nullptr; } @@ -157,35 +157,35 @@ namespace ams::mem::impl::heap { if (count < MaxChunkCount) { count++; } - _this->chunk_count[cls] = std::max(count, n); + tls_heap_cache->m_chunk_count[cls] = std::max(count, n); } else { AMS_ASSERT(n == 1); } const size_t csize = TlsHeapStatic::GetChunkSize(cls) * (n - 1); - _this->cached_size[cls] += csize; - if (_this->cached_size[cls] > _this->cached_size[_this->largest_class]) { - _this->largest_class = cls; + tls_heap_cache->m_cached_size[cls] += csize; + if (tls_heap_cache->m_cached_size[cls] > tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]) { + tls_heap_cache->m_largest_class = cls; } - _this->total_cached_size += csize; + tls_heap_cache->m_total_cached_size += csize; } /* Demangle our pointer, update free list. */ - ptr = _this->ManglePointer(ptr); - _this->small_mem_lists[cls] = *reinterpret_cast(ptr); + ptr = tls_heap_cache->ManglePointer(ptr); + tls_heap_cache->m_small_mem_lists[cls] = *reinterpret_cast(ptr); return ptr; } else { /* If allocating a huge size, release our cache. */ - if (size >= _this->total_heap_size / 4) { - _this->ReleaseAllCache(); + if (size >= tls_heap_cache->m_total_heap_size / 4) { + tls_heap_cache->ReleaseAllCache(); } - return _this->central->CacheLargeMemory(size); + return tls_heap_cache->m_central->CacheLargeMemory(size); } } template<> - void *TlsHeapCache::AllocateAlignedImpl(TlsHeapCache *_this, size_t size, size_t align) { + void *TlsHeapCache::AllocateAlignedImpl(TlsHeapCache *tls_heap_cache, size_t size, size_t align) { /* Ensure valid alignment. */ if (!util::IsPowerOfTwo(align)) { return nullptr; @@ -198,7 +198,7 @@ namespace ams::mem::impl::heap { /* Handle big alignment. */ if (align > TlsHeapStatic::PageSize) { - return _this->central->CacheLargeMemoryWithBigAlign(util::AlignUp(size, TlsHeapStatic::PageSize), align); + return tls_heap_cache->m_central->CacheLargeMemoryWithBigAlign(util::AlignUp(size, TlsHeapStatic::PageSize), align); } const size_t real_size = TlsHeapStatic::GetRealSizeFromSizeAndAlignment(util::AlignUp(size, align), align); @@ -209,18 +209,18 @@ namespace ams::mem::impl::heap { } AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); - return _this->central->CacheSmallMemory(cls, align); + return tls_heap_cache->m_central->CacheSmallMemory(cls, align); } else { /* If allocating a huge size, release our cache. */ - if (real_size >= _this->total_heap_size / 4) { - _this->ReleaseAllCache(); + if (real_size >= tls_heap_cache->m_total_heap_size / 4) { + tls_heap_cache->ReleaseAllCache(); } - return _this->central->CacheLargeMemory(real_size); + return tls_heap_cache->m_central->CacheLargeMemory(real_size); } } template<> - void *TlsHeapCache::AllocateAlignedImpl(TlsHeapCache *_this, size_t size, size_t align) { + void *TlsHeapCache::AllocateAlignedImpl(TlsHeapCache *tls_heap_cache, size_t size, size_t align) { /* Ensure valid alignment. */ if (!util::IsPowerOfTwo(align)) { return nullptr; @@ -233,7 +233,7 @@ namespace ams::mem::impl::heap { /* Handle big alignment. */ if (align > TlsHeapStatic::PageSize) { - return _this->central->CacheLargeMemoryWithBigAlign(util::AlignUp(size, TlsHeapStatic::PageSize), align); + return tls_heap_cache->m_central->CacheLargeMemoryWithBigAlign(util::AlignUp(size, TlsHeapStatic::PageSize), align); } const size_t real_size = TlsHeapStatic::GetRealSizeFromSizeAndAlignment(util::AlignUp(size, align), align); @@ -246,12 +246,12 @@ namespace ams::mem::impl::heap { AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); /* Allocate a chunk. */ - void *ptr = _this->small_mem_lists[cls]; + void *ptr = tls_heap_cache->m_small_mem_lists[cls]; if (ptr == nullptr) { const size_t prev_cls = cls; - size_t count = _this->chunk_count[cls]; + size_t count = tls_heap_cache->m_chunk_count[cls]; - size_t n = _this->central->CacheSmallMemoryList(_this, std::addressof(cls), count, std::addressof(ptr), align); + size_t n = tls_heap_cache->m_central->CacheSmallMemoryList(tls_heap_cache, std::addressof(cls), count, std::addressof(ptr), align); if (n == 0) { return nullptr; } @@ -260,44 +260,44 @@ namespace ams::mem::impl::heap { if (count < MaxChunkCount) { count++; } - _this->chunk_count[cls] = std::max(count, n); + tls_heap_cache->m_chunk_count[cls] = std::max(count, n); } else { AMS_ASSERT(n == 1); } const s32 csize = TlsHeapStatic::GetChunkSize(cls) * (n - 1); - _this->total_cached_size += csize; - _this->cached_size[cls] += csize; - if (_this->cached_size[cls] > _this->cached_size[_this->largest_class]) { - _this->largest_class = cls; + tls_heap_cache->m_total_cached_size += csize; + tls_heap_cache->m_cached_size[cls] += csize; + if (tls_heap_cache->m_cached_size[cls] > tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]) { + tls_heap_cache->m_largest_class = cls; } } /* Demangle our pointer, update free list. */ - ptr = _this->ManglePointer(ptr); - _this->small_mem_lists[cls] = *reinterpret_cast(ptr); + ptr = tls_heap_cache->ManglePointer(ptr); + tls_heap_cache->m_small_mem_lists[cls] = *reinterpret_cast(ptr); return ptr; } else { /* If allocating a huge size, release our cache. */ - if (size >= _this->total_heap_size / 4) { - _this->ReleaseAllCache(); + if (size >= tls_heap_cache->m_total_heap_size / 4) { + tls_heap_cache->ReleaseAllCache(); } - return _this->central->CacheLargeMemory(size); + return tls_heap_cache->m_central->CacheLargeMemory(size); } } template<> - errno_t TlsHeapCache::FreeImpl(TlsHeapCache *_this, void *ptr) { - const auto cls = _this->central->GetClassFromPointer(ptr); + errno_t TlsHeapCache::FreeImpl(TlsHeapCache *tls_heap_cache, void *ptr) { + const auto cls = tls_heap_cache->m_central->GetClassFromPointer(ptr); if (cls == 0) { - return _this->central->UncacheLargeMemory(ptr); + return tls_heap_cache->m_central->UncacheLargeMemory(ptr); } AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); if (cls >= 0) { - return _this->central->UncacheSmallMemory(ptr); + return tls_heap_cache->m_central->UncacheSmallMemory(ptr); } else if (ptr == nullptr) { return 0; } else { @@ -306,41 +306,41 @@ namespace ams::mem::impl::heap { } template<> - errno_t TlsHeapCache::FreeImpl(TlsHeapCache *_this, void *ptr) { - const auto cls = _this->central->GetClassFromPointer(ptr); + errno_t TlsHeapCache::FreeImpl(TlsHeapCache *tls_heap_cache, void *ptr) { + const auto cls = tls_heap_cache->m_central->GetClassFromPointer(ptr); if (cls == 0) { - return _this->central->UncacheLargeMemory(ptr); + return tls_heap_cache->m_central->UncacheLargeMemory(ptr); } AMS_ASSERT(cls < TlsHeapStatic::NumClassInfo); if (cls >= 0) { - *reinterpret_cast(ptr) = _this->small_mem_lists[cls]; - _this->small_mem_lists[cls] = _this->ManglePointer(ptr); + *reinterpret_cast(ptr) = tls_heap_cache->m_small_mem_lists[cls]; + tls_heap_cache->m_small_mem_lists[cls] = tls_heap_cache->ManglePointer(ptr); const s32 csize = TlsHeapStatic::GetChunkSize(cls); - _this->total_cached_size += csize; - _this->cached_size[cls] += csize; - if (_this->cached_size[cls] > _this->cached_size[_this->largest_class]) { - _this->largest_class = cls; + tls_heap_cache->m_total_cached_size += csize; + tls_heap_cache->m_cached_size[cls] += csize; + if (tls_heap_cache->m_cached_size[cls] > tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]) { + tls_heap_cache->m_largest_class = cls; } errno_t err = 0; - if (!_this->central->CheckCachedSize(_this->total_cached_size)) { - _this->central->UncacheSmallMemoryList(_this, _this->small_mem_lists[_this->largest_class]); - _this->small_mem_lists[_this->largest_class] = nullptr; - _this->total_cached_size -= _this->cached_size[_this->largest_class]; - _this->cached_size[_this->largest_class] = 0; + if (!tls_heap_cache->m_central->CheckCachedSize(tls_heap_cache->m_total_cached_size)) { + tls_heap_cache->m_central->UncacheSmallMemoryList(tls_heap_cache, tls_heap_cache->m_small_mem_lists[tls_heap_cache->m_largest_class]); + tls_heap_cache->m_small_mem_lists[tls_heap_cache->m_largest_class] = nullptr; + tls_heap_cache->m_total_cached_size -= tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]; + tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class] = 0; s32 largest_class = 0; s32 biggest_size = -1; for (size_t i = 0; i < TlsHeapStatic::NumClassInfo; i++) { - if (biggest_size < _this->cached_size[i]) { - biggest_size = _this->cached_size[i]; + if (biggest_size < tls_heap_cache->m_cached_size[i]) { + biggest_size = tls_heap_cache->m_cached_size[i]; largest_class = static_cast(i); } } - _this->largest_class = largest_class; + tls_heap_cache->m_largest_class = largest_class; } return err; } else if (ptr == nullptr) { @@ -351,72 +351,72 @@ namespace ams::mem::impl::heap { } template<> - errno_t TlsHeapCache::FreeWithSizeImpl(TlsHeapCache *_this, void *ptr, size_t size) { + errno_t TlsHeapCache::FreeWithSizeImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size) { if (ptr == nullptr) { return 0; } const size_t cls = TlsHeapStatic::GetClassFromSize(size); if (cls == 0) { - return _this->central->UncacheLargeMemory(ptr); + return tls_heap_cache->m_central->UncacheLargeMemory(ptr); } else { - return _this->central->UncacheSmallMemory(ptr); + return tls_heap_cache->m_central->UncacheSmallMemory(ptr); } } template<> - errno_t TlsHeapCache::FreeWithSizeImpl(TlsHeapCache *_this, void *ptr, size_t size) { + errno_t TlsHeapCache::FreeWithSizeImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size) { if (ptr == nullptr) { return 0; } const size_t cls = TlsHeapStatic::GetClassFromSize(size); if (cls == 0) { - return _this->central->UncacheLargeMemory(ptr); + return tls_heap_cache->m_central->UncacheLargeMemory(ptr); } else { - *reinterpret_cast(ptr) = _this->small_mem_lists[cls]; - _this->small_mem_lists[cls] = _this->ManglePointer(ptr); + *reinterpret_cast(ptr) = tls_heap_cache->m_small_mem_lists[cls]; + tls_heap_cache->m_small_mem_lists[cls] = tls_heap_cache->ManglePointer(ptr); const s32 csize = TlsHeapStatic::GetChunkSize(cls); - _this->total_cached_size += csize; - _this->cached_size[cls] += csize; - if (_this->cached_size[cls] > _this->cached_size[_this->largest_class]) { - _this->largest_class = cls; + tls_heap_cache->m_total_cached_size += csize; + tls_heap_cache->m_cached_size[cls] += csize; + if (tls_heap_cache->m_cached_size[cls] > tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]) { + tls_heap_cache->m_largest_class = cls; } errno_t err = 0; - if (!_this->central->CheckCachedSize(_this->total_cached_size)) { - _this->central->UncacheSmallMemoryList(_this, _this->small_mem_lists[_this->largest_class]); - _this->small_mem_lists[_this->largest_class] = nullptr; - _this->total_cached_size -= _this->cached_size[_this->largest_class]; - _this->cached_size[_this->largest_class] = 0; + if (!tls_heap_cache->m_central->CheckCachedSize(tls_heap_cache->m_total_cached_size)) { + tls_heap_cache->m_central->UncacheSmallMemoryList(tls_heap_cache, tls_heap_cache->m_small_mem_lists[tls_heap_cache->m_largest_class]); + tls_heap_cache->m_small_mem_lists[tls_heap_cache->m_largest_class] = nullptr; + tls_heap_cache->m_total_cached_size -= tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class]; + tls_heap_cache->m_cached_size[tls_heap_cache->m_largest_class] = 0; s32 largest_class = 0; s32 biggest_size = -1; for (size_t i = 0; i < TlsHeapStatic::NumClassInfo; i++) { - if (biggest_size < _this->cached_size[i]) { - biggest_size = _this->cached_size[i]; + if (biggest_size < tls_heap_cache->m_cached_size[i]) { + biggest_size = tls_heap_cache->m_cached_size[i]; largest_class = static_cast(i); } } - _this->largest_class = largest_class; + tls_heap_cache->m_largest_class = largest_class; } return err; } } template<> - size_t TlsHeapCache::GetAllocationSizeImpl(TlsHeapCache *_this, const void *ptr) { - return _this->GetAllocationSizeCommonImpl(ptr); + size_t TlsHeapCache::GetAllocationSizeImpl(TlsHeapCache *tls_heap_cache, const void *ptr) { + return tls_heap_cache->GetAllocationSizeCommonImpl(ptr); } template<> - size_t TlsHeapCache::GetAllocationSizeImpl(TlsHeapCache *_this, const void *ptr) { - return _this->GetAllocationSizeCommonImpl(ptr); + size_t TlsHeapCache::GetAllocationSizeImpl(TlsHeapCache *tls_heap_cache, const void *ptr) { + return tls_heap_cache->GetAllocationSizeCommonImpl(ptr); } size_t TlsHeapCache::GetAllocationSizeCommonImpl(const void *ptr) const { - const s32 cls = this->central->GetClassFromPointer(ptr); + const s32 cls = m_central->GetClassFromPointer(ptr); if (cls > 0) { if (!util::IsAligned(ptr, alignof(u64))) { /* All pointers we allocate have alignment at least 8. */ @@ -431,14 +431,14 @@ namespace ams::mem::impl::heap { return TlsHeapStatic::GetChunkSize(cls); } else if (ptr != nullptr) { - return this->central->GetAllocationSize(ptr); + return m_central->GetAllocationSize(ptr); } else { return 0; } } template<> - errno_t TlsHeapCache::ReallocateImpl(TlsHeapCache *_this, void *ptr, size_t size, void **p) { + errno_t TlsHeapCache::ReallocateImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size, void **p) { AMS_ASSERT(ptr != nullptr && size != 0); if (size > MaxSize) { return ENOMEM; @@ -447,7 +447,7 @@ namespace ams::mem::impl::heap { size_t alloc_size, copy_size; const s32 cls_from_size = TlsHeapStatic::GetClassFromSize(size); - const s32 cls_from_ptr = _this->central->GetClassFromPointer(ptr); + const s32 cls_from_ptr = tls_heap_cache->m_central->GetClassFromPointer(ptr); if (cls_from_ptr < 0) { /* error case. */ return EFAULT; @@ -465,22 +465,22 @@ namespace ams::mem::impl::heap { copy_size = size; } } else if (cls_from_ptr == 0) { - return _this->central->ReallocateLargeMemory(ptr, size, p); + return tls_heap_cache->m_central->ReallocateLargeMemory(ptr, size, p); } else /* if (cls_from_ptr > 0) */ { alloc_size = size; copy_size = TlsHeapStatic::GetChunkSize(cls_from_ptr); } - *p = AllocateImpl(_this, alloc_size); + *p = AllocateImpl(tls_heap_cache, alloc_size); if (*p == nullptr) { return ENOMEM; } std::memcpy(*p, ptr, copy_size); - return FreeImpl(_this, ptr); + return FreeImpl(tls_heap_cache, ptr); } template<> - errno_t TlsHeapCache::ReallocateImpl(TlsHeapCache *_this, void *ptr, size_t size, void **p) { + errno_t TlsHeapCache::ReallocateImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size, void **p) { AMS_ASSERT(ptr != nullptr && size != 0); if (size > MaxSize) { return ENOMEM; @@ -489,7 +489,7 @@ namespace ams::mem::impl::heap { size_t alloc_size, copy_size; const s32 cls_from_size = TlsHeapStatic::GetClassFromSize(size); - const s32 cls_from_ptr = _this->central->GetClassFromPointer(ptr); + const s32 cls_from_ptr = tls_heap_cache->m_central->GetClassFromPointer(ptr); if (cls_from_ptr < 0) { /* error case. */ return EFAULT; @@ -507,28 +507,28 @@ namespace ams::mem::impl::heap { copy_size = size; } } else if (cls_from_ptr == 0) { - return _this->central->ReallocateLargeMemory(ptr, size, p); + return tls_heap_cache->m_central->ReallocateLargeMemory(ptr, size, p); } else /* if (cls_from_ptr > 0) */ { alloc_size = size; copy_size = TlsHeapStatic::GetChunkSize(cls_from_ptr); } - *p = AllocateImpl(_this, alloc_size); + *p = AllocateImpl(tls_heap_cache, alloc_size); if (*p == nullptr) { return ENOMEM; } std::memcpy(*p, ptr, copy_size); - return FreeImpl(_this, ptr); + return FreeImpl(tls_heap_cache, ptr); } template<> - errno_t TlsHeapCache::ShrinkImpl(TlsHeapCache *_this, void *ptr, size_t size) { - return _this->ShrinkCommonImpl(ptr, size); + errno_t TlsHeapCache::ShrinkImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size) { + return tls_heap_cache->ShrinkCommonImpl(ptr, size); } template<> - errno_t TlsHeapCache::ShrinkImpl(TlsHeapCache *_this, void *ptr, size_t size) { - return _this->ShrinkCommonImpl(ptr, size); + errno_t TlsHeapCache::ShrinkImpl(TlsHeapCache *tls_heap_cache, void *ptr, size_t size) { + return tls_heap_cache->ShrinkCommonImpl(ptr, size); } errno_t TlsHeapCache::ShrinkCommonImpl(void *ptr, size_t size) const { @@ -538,7 +538,7 @@ namespace ams::mem::impl::heap { } const s32 cls_from_size = TlsHeapStatic::GetClassFromSize(size); - const s32 cls_from_ptr = this->central->GetClassFromPointer(ptr); + const s32 cls_from_ptr = m_central->GetClassFromPointer(ptr); if (cls_from_ptr) { if (cls_from_ptr <= 0) { return EFAULT; @@ -548,9 +548,9 @@ namespace ams::mem::impl::heap { return EINVAL; } } else if (cls_from_size) { - return this->central->ShrinkLargeMemory(ptr, TlsHeapStatic::PageSize); + return m_central->ShrinkLargeMemory(ptr, TlsHeapStatic::PageSize); } else { - return this->central->ShrinkLargeMemory(ptr, size); + return m_central->ShrinkLargeMemory(ptr, size); } } diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.hpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.hpp index f206ca4bc..31d4f8e64 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.hpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_cache.hpp @@ -22,14 +22,14 @@ namespace ams::mem::impl::heap { class TlsHeapCentral; - #define FOREACH_TLS_HEAP_CACHE_FUNC(HANDLER) \ - HANDLER(void *, Allocate, allocate, size_t size); \ - HANDLER(void *, AllocateAligned, allocate_aligned, size_t size, size_t align); \ - HANDLER(errno_t, Free, free, void *ptr); \ - HANDLER(errno_t, FreeWithSize, free_with_size, void *ptr, size_t size); \ - HANDLER(size_t, GetAllocationSize, get_allocation_size, const void *ptr); \ - HANDLER(errno_t, Reallocate, reallocate, void *ptr, size_t size, void **p); \ - HANDLER(errno_t, Shrink, shrink, void *ptr, size_t size); + #define FOREACH_TLS_HEAP_CACHE_FUNC(HANDLER) \ + HANDLER(void *, Allocate, m_allocate, size_t size); \ + HANDLER(void *, AllocateAligned, m_allocate_aligned, size_t size, size_t align); \ + HANDLER(errno_t, Free, m_free, void *ptr); \ + HANDLER(errno_t, FreeWithSize, m_free_with_size, void *ptr, size_t size); \ + HANDLER(size_t, GetAllocationSize, m_get_allocation_size, const void *ptr); \ + HANDLER(errno_t, Reallocate, m_reallocate, void *ptr, size_t size, void **p); \ + HANDLER(errno_t, Shrink, m_shrink, void *ptr, size_t size); class TlsHeapCache { public: @@ -49,21 +49,21 @@ namespace ams::mem::impl::heap { #undef TLS_HEAP_CACHE_DECLARE_MEMBER - uintptr_t mangle_val; - TlsHeapCentral *central; - size_t total_heap_size; - u32 heap_option; - s32 total_cached_size; - s32 largest_class; - void *small_mem_lists[TlsHeapStatic::NumClassInfo]; - s32 cached_size[TlsHeapStatic::NumClassInfo]; - u8 chunk_count[TlsHeapStatic::NumClassInfo]; + uintptr_t m_mangle_val; + TlsHeapCentral *m_central; + size_t m_total_heap_size; + u32 m_heap_option; + s32 m_total_cached_size; + s32 m_largest_class; + void *m_small_mem_lists[TlsHeapStatic::NumClassInfo]; + s32 m_cached_size[TlsHeapStatic::NumClassInfo]; + u8 m_chunk_count[TlsHeapStatic::NumClassInfo]; public: TlsHeapCache(TlsHeapCentral *central, u32 option); void Finalize(); void *ManglePointer(void *ptr) const { - return reinterpret_cast(reinterpret_cast(ptr) ^ this->mangle_val); + return reinterpret_cast(reinterpret_cast(ptr) ^ m_mangle_val); } bool CheckCache() const; @@ -71,16 +71,16 @@ namespace ams::mem::impl::heap { public: /* TODO: Better handler with type info to macro this? */ - ALWAYS_INLINE void *Allocate(size_t size) { return this->allocate(this, size); } - ALWAYS_INLINE void *Allocate(size_t size, size_t align) { return this->allocate_aligned(this, size, align); } - ALWAYS_INLINE errno_t Free(void *ptr) { return this->free(this, ptr); } - ALWAYS_INLINE errno_t FreeWithSize(void *ptr, size_t size) { return this->free_with_size(this, ptr, size); } - ALWAYS_INLINE size_t GetAllocationSize(const void *ptr) { return this->get_allocation_size(this, ptr); } - ALWAYS_INLINE errno_t Reallocate(void *ptr, size_t size, void **p) { return this->reallocate(this, ptr, size, p); } - ALWAYS_INLINE errno_t Shrink(void *ptr, size_t size) { return this->shrink(this, ptr, size); } + ALWAYS_INLINE void *Allocate(size_t size) { return m_allocate(this, size); } + ALWAYS_INLINE void *Allocate(size_t size, size_t align) { return m_allocate_aligned(this, size, align); } + ALWAYS_INLINE errno_t Free(void *ptr) { return m_free(this, ptr); } + ALWAYS_INLINE errno_t FreeWithSize(void *ptr, size_t size) { return m_free_with_size(this, ptr, size); } + ALWAYS_INLINE size_t GetAllocationSize(const void *ptr) { return m_get_allocation_size(this, ptr); } + ALWAYS_INLINE errno_t Reallocate(void *ptr, size_t size, void **p) { return m_reallocate(this, ptr, size, p); } + ALWAYS_INLINE errno_t Shrink(void *ptr, size_t size) { return m_shrink(this, ptr, size); } private: #define TLS_HEAP_CACHE_DECLARE_TEMPLATE(RETURN, NAME, MEMBER_NAME, ...) \ - template static RETURN NAME##Impl(TlsHeapCache *_this, ## __VA_ARGS__ ) + template static RETURN NAME##Impl(TlsHeapCache *tls_heap_cache, ## __VA_ARGS__ ) FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_TEMPLATE) @@ -90,9 +90,9 @@ namespace ams::mem::impl::heap { errno_t ShrinkCommonImpl(void *ptr, size_t size) const; }; - #define TLS_HEAP_CACHE_DECLARE_INSTANTIATION(RETURN, NAME, MEMBER_NAME, ...) \ - template<> RETURN TlsHeapCache::NAME##Impl(TlsHeapCache *_this, ##__VA_ARGS__); \ - template<> RETURN TlsHeapCache::NAME##Impl(TlsHeapCache *_this, ##__VA_ARGS__) + #define TLS_HEAP_CACHE_DECLARE_INSTANTIATION(RETURN, NAME, MEMBER_NAME, ...) \ + template<> RETURN TlsHeapCache::NAME##Impl(TlsHeapCache *tls_heap_cache, ##__VA_ARGS__); \ + template<> RETURN TlsHeapCache::NAME##Impl(TlsHeapCache *tls_heap_cache, ##__VA_ARGS__) FOREACH_TLS_HEAP_CACHE_FUNC(TLS_HEAP_CACHE_DECLARE_INSTANTIATION) diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp index ed9ae33e7..6b3fd5756 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.cpp @@ -301,35 +301,35 @@ namespace ams::mem::impl::heap { AMS_ASSERT(TlsHeapStatic::IsPageAligned(size)); /* Clear lists. */ - ListClearLink(std::addressof(this->spanpage_list)); - ListClearLink(std::addressof(this->full_spanpage_list)); - for (size_t i = 0; i < util::size(this->freelists); i++) { - ListClearLink(std::addressof(this->freelists[i])); + ListClearLink(std::addressof(m_spanpage_list)); + ListClearLink(std::addressof(m_full_spanpage_list)); + for (size_t i = 0; i < util::size(m_freelists); i++) { + ListClearLink(std::addressof(m_freelists[i])); } - for (size_t i = 0; i < util::size(this->freelists_bitmap); i++) { - this->freelists_bitmap[i] = 0; + for (size_t i = 0; i < util::size(m_freelists_bitmap); i++) { + m_freelists_bitmap[i] = 0; } - for (size_t i = 0; i < util::size(this->smallmem_lists); i++) { - ListClearLink(std::addressof(this->smallmem_lists[i])); + for (size_t i = 0; i < util::size(m_smallmem_lists); i++) { + ListClearLink(std::addressof(m_smallmem_lists[i])); } /* Setup span table. */ const size_t total_pages = TlsHeapStatic::GetPageIndex(size); const size_t n = total_pages * sizeof(Span *); - this->span_table.total_pages = total_pages; - this->span_table.page_to_span = reinterpret_cast(static_cast(start) + sizeof(*this)); - this->span_table.pageclass_cache = static_cast(start) + sizeof(*this) + n; + m_span_table.total_pages = total_pages; + m_span_table.page_to_span = reinterpret_cast(static_cast(start) + sizeof(*this)); + m_span_table.pageclass_cache = static_cast(start) + sizeof(*this) + n; - u8 *meta_end = this->span_table.pageclass_cache + total_pages; + u8 *meta_end = m_span_table.pageclass_cache + total_pages; size_t num_physical_page_flags; if (use_virtual_memory) { - this->physical_page_flags = meta_end; + m_physical_page_flags = meta_end; const uintptr_t phys_start = TlsHeapStatic::AlignDownPhysicalPage(reinterpret_cast(start)); const uintptr_t phys_end = TlsHeapStatic::AlignUpPhysicalPage(reinterpret_cast(start) + size); num_physical_page_flags = TlsHeapStatic::GetPhysicalPageIndex(phys_end - phys_start); meta_end = TlsHeapStatic::AlignUpPage(meta_end + num_physical_page_flags); } else { - this->physical_page_flags = nullptr; + m_physical_page_flags = nullptr; num_physical_page_flags = 0; meta_end = TlsHeapStatic::AlignUpPage(meta_end); } @@ -340,19 +340,19 @@ namespace ams::mem::impl::heap { size_t phys_size = phys_end - reinterpret_cast(start); phys_size = std::min(phys_size, size); if (auto err = AllocatePhysicalMemory(start, phys_size); err != 0) { - this->span_table.total_pages = 0; + m_span_table.total_pages = 0; return err; } - std::memset(this->physical_page_flags, 0, num_physical_page_flags); - std::memset(this->physical_page_flags, 1, TlsHeapStatic::GetPhysicalPageIndex(phys_end) - TlsHeapStatic::GetPhysicalPageIndex(reinterpret_cast(start))); + std::memset(m_physical_page_flags, 0, num_physical_page_flags); + std::memset(m_physical_page_flags, 1, TlsHeapStatic::GetPhysicalPageIndex(phys_end) - TlsHeapStatic::GetPhysicalPageIndex(reinterpret_cast(start))); } - std::memset(this->span_table.page_to_span, 0, n); - std::memset(this->span_table.pageclass_cache, 0, total_pages); + std::memset(m_span_table.page_to_span, 0, n); + std::memset(m_span_table.pageclass_cache, 0, total_pages); SpanPage *span_page = reinterpret_cast(meta_end); InitializeSpanPage(span_page); - ListInsertAfter(std::addressof(this->spanpage_list), span_page); + ListInsertAfter(std::addressof(m_spanpage_list), span_page); meta_end += TlsHeapStatic::PageSize; AMS_ASSERT(TlsHeapStatic::IsPageAligned(meta_end)); @@ -387,28 +387,28 @@ namespace ams::mem::impl::heap { span_admin->status = Span::Status_InUseSystem; span_admin->id = 0; - RegisterSpan(std::addressof(this->span_table), span_admin); - RegisterSpan(std::addressof(this->span_table), std::addressof(span_page->info.span_of_spanpage)); - RegisterSpan(std::addressof(this->span_table), span); + RegisterSpan(std::addressof(m_span_table), span_admin); + RegisterSpan(std::addressof(m_span_table), std::addressof(span_page->info.span_of_spanpage)); + RegisterSpan(std::addressof(m_span_table), span); this->AddToFreeBlockList(span); - this->num_threads = 1; - this->static_thread_quota = std::min((this->span_table.total_pages * TlsHeapStatic::PageSize) / sizeof(void *), 2_MB); - this->dynamic_thread_quota = this->static_thread_quota; - this->use_virtual_memory = use_virtual_memory; + m_num_threads = 1; + m_static_thread_quota = std::min((m_span_table.total_pages * TlsHeapStatic::PageSize) / sizeof(void *), 2_MB); + m_dynamic_thread_quota = m_static_thread_quota; + m_use_virtual_memory = use_virtual_memory; return 0; } bool TlsHeapCentral::IsClean() { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); this->MakeFreeSpan(std::numeric_limits::max()); Span *span = this->GetFirstSpan(); - Span *next = GetNextSpan(std::addressof(this->span_table), span); - if (next && next->status == Span::Status_InFreeList && GetNextSpan(std::addressof(this->span_table), next) == nullptr) { + Span *next = GetNextSpan(std::addressof(m_span_table), span); + if (next && next->status == Span::Status_InFreeList && GetNextSpan(std::addressof(m_span_table), next) == nullptr) { return true; } else { return false; @@ -424,12 +424,12 @@ namespace ams::mem::impl::heap { /* NOTE: This function uses locks unsafely (unscoped) */ - this->lock.Lock(); + m_lock.Lock(); - Span *ptr_span = GetSpanFromPointer(std::addressof(this->span_table), ptr); + Span *ptr_span = GetSpanFromPointer(std::addressof(m_span_table), ptr); if (!ptr_span) { AMS_ASSERT(ptr_span != nullptr); - this->lock.Unlock(); + m_lock.Unlock(); return EFAULT; } @@ -442,16 +442,16 @@ namespace ams::mem::impl::heap { span->num_pages = ptr_span->num_pages - num_pages; span->id = 0; span->status = Span::Status_InUse; - ChangeRangeOfSpan(std::addressof(this->span_table), ptr_span, ptr_span->start.u, num_pages); - RegisterSpan(std::addressof(this->span_table), span); + ChangeRangeOfSpan(std::addressof(m_span_table), ptr_span, ptr_span->start.u, num_pages); + RegisterSpan(std::addressof(m_span_table), span); this->FreePagesImpl(span); } } else { - Span *next_span = GetNextSpan(std::addressof(this->span_table), ptr_span); + Span *next_span = GetNextSpan(std::addressof(m_span_table), ptr_span); if (!next_span || next_span->status != Span::Status_InFreeList || next_span->num_pages < num_pages - ptr_span->num_pages) { - this->lock.Unlock(); + m_lock.Unlock(); - this->lock.Lock(); + m_lock.Lock(); Span *span = this->AllocatePagesImpl(num_pages); if (span) { @@ -461,44 +461,44 @@ namespace ams::mem::impl::heap { *p = nullptr; } - this->lock.Unlock(); + m_lock.Unlock(); if (*p == nullptr) { return ENOMEM; } std::memcpy(*p, ptr, num_pages * TlsHeapStatic::PageSize); - this->lock.Lock(); + m_lock.Lock(); this->FreePagesImpl(ptr_span); - this->lock.Unlock(); + m_lock.Unlock(); return 0; } - if (this->use_virtual_memory && this->AllocatePhysical(next_span->start.p, (num_pages - ptr_span->num_pages) * TlsHeapStatic::PageSize)) { - this->lock.Unlock(); + if (m_use_virtual_memory && this->AllocatePhysical(next_span->start.p, (num_pages - ptr_span->num_pages) * TlsHeapStatic::PageSize)) { + m_lock.Unlock(); return ENOMEM; } this->RemoveFromFreeBlockList(next_span); if (next_span->num_pages == num_pages - ptr_span->num_pages) { - UnregisterSpan(std::addressof(this->span_table), next_span); - ChangeRangeOfSpan(std::addressof(this->span_table), ptr_span, ptr_span->start.u, num_pages); + UnregisterSpan(std::addressof(m_span_table), next_span); + ChangeRangeOfSpan(std::addressof(m_span_table), ptr_span, ptr_span->start.u, num_pages); SpanPage *sp = GetSpanPage(next_span); this->FreeSpanToSpanPage(next_span, sp); this->DestroySpanPageIfEmpty(sp, false); } else { const uintptr_t new_end = ptr_span->start.u + num_pages * TlsHeapStatic::PageSize; const size_t new_num_pages = next_span->num_pages - (num_pages - ptr_span->num_pages); - ChangeRangeOfSpan(std::addressof(this->span_table), next_span, new_end, new_num_pages); - ChangeRangeOfSpan(std::addressof(this->span_table), ptr_span, ptr_span->start.u, num_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), next_span, new_end, new_num_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), ptr_span, ptr_span->start.u, num_pages); this->MergeIntoFreeList(next_span); } } } *p = ptr; - this->lock.Unlock(); + m_lock.Unlock(); return 0; } @@ -509,9 +509,9 @@ namespace ams::mem::impl::heap { AMS_ASSERT(size <= MaxSize); - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - Span *ptr_span = GetSpanFromPointer(std::addressof(this->span_table), ptr); + Span *ptr_span = GetSpanFromPointer(std::addressof(m_span_table), ptr); if (!ptr_span) { AMS_ASSERT(ptr_span != nullptr); return EFAULT; @@ -528,8 +528,8 @@ namespace ams::mem::impl::heap { span->num_pages = ptr_span->num_pages - num_pages; span->id = 0; span->status = Span::Status_InUse; - ChangeRangeOfSpan(std::addressof(this->span_table), ptr_span, ptr_span->start.u, num_pages); - RegisterSpan(std::addressof(this->span_table), span); + ChangeRangeOfSpan(std::addressof(m_span_table), ptr_span, ptr_span->start.u, num_pages); + RegisterSpan(std::addressof(m_span_table), span); this->FreePagesImpl(span); } } @@ -543,9 +543,9 @@ namespace ams::mem::impl::heap { size_t hash = 0; { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - for (Span *span = GetSpanFromPointer(std::addressof(this->span_table), this); span != nullptr; span = GetNextSpan(std::addressof(this->span_table), span)) { + for (Span *span = GetSpanFromPointer(std::addressof(m_span_table), this); span != nullptr; span = GetNextSpan(std::addressof(m_span_table), span)) { if (span->status != Span::Status_InUse) { continue; } @@ -594,7 +594,7 @@ namespace ams::mem::impl::heap { } AMS_ASSERT(span->page_class == 0); - if (this->use_virtual_memory && this->AllocatePhysical(span->start.p, TlsHeapStatic::PageSize) != 0) { + if (m_use_virtual_memory && this->AllocatePhysical(span->start.p, TlsHeapStatic::PageSize) != 0) { return nullptr; } @@ -604,7 +604,7 @@ namespace ams::mem::impl::heap { Span *new_span = GetSpanPageSpan(sp); if (span->num_pages == 1) { this->RemoveFromFreeBlockList(span); - MigrateSpan(std::addressof(this->span_table), span, new_span); + MigrateSpan(std::addressof(m_span_table), span, new_span); AMS_ASSERT(new_span->num_pages == 1); new_span->status = Span::Status_InUseSystem; @@ -620,15 +620,15 @@ namespace ams::mem::impl::heap { if (span->num_pages - 1 < FreeListCount) { this->RemoveFromFreeBlockList(span); } - ChangeRangeOfSpan(std::addressof(this->span_table), span, span->start.u + TlsHeapStatic::PageSize, span->num_pages - 1); - RegisterSpan(std::addressof(this->span_table), new_span); + ChangeRangeOfSpan(std::addressof(m_span_table), span, span->start.u + TlsHeapStatic::PageSize, span->num_pages - 1); + RegisterSpan(std::addressof(m_span_table), new_span); if (span->num_pages < FreeListCount) { this->AddToFreeBlockList(span); } } - ListInsertAfter(std::addressof(this->spanpage_list), sp); + ListInsertAfter(std::addressof(m_spanpage_list), sp); return sp; } @@ -648,7 +648,7 @@ namespace ams::mem::impl::heap { if (sp->info.free_count == 0) { ListRemoveSelf(sp); - ListInsertAfter(std::addressof(this->full_spanpage_list), sp); + ListInsertAfter(std::addressof(m_full_spanpage_list), sp); } return span; @@ -671,10 +671,10 @@ namespace ams::mem::impl::heap { if (remaining_pages >= FreeListCount) { - ChangeRangeOfSpan(std::addressof(this->span_table), span, old_start, remaining_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, old_start, remaining_pages); } else { this->RemoveFromFreeBlockList(span); - ChangeRangeOfSpan(std::addressof(this->span_table), span, old_start, remaining_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, old_start, remaining_pages); this->AddToFreeBlockList(span); } @@ -686,22 +686,22 @@ namespace ams::mem::impl::heap { new_span->aux.large_clear.zero = 0; span->aux.large_clear.zero = 0; - if (this->use_virtual_memory && this->AllocatePhysical(new_span->start.p, new_span->num_pages * TlsHeapStatic::PageSize) != 0) { + if (m_use_virtual_memory && this->AllocatePhysical(new_span->start.p, new_span->num_pages * TlsHeapStatic::PageSize) != 0) { new_span->status = Span::Status_InFreeList; this->MergeIntoFreeList(new_span); return nullptr; } - RegisterSpan(std::addressof(this->span_table), new_span); + RegisterSpan(std::addressof(m_span_table), new_span); return new_span; } void TlsHeapCentral::MergeFreeSpans(Span *span, Span *span_to_merge, uintptr_t start) { const size_t total_pages = span->num_pages + span_to_merge->num_pages; - UnregisterSpan(std::addressof(this->span_table), span_to_merge); + UnregisterSpan(std::addressof(m_span_table), span_to_merge); SpanPage *span_page = GetSpanPage(span_to_merge); this->FreeSpanToSpanPage(span_to_merge, span_page); - ChangeRangeOfSpan(std::addressof(this->span_table), span, start, total_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, start, total_pages); } bool TlsHeapCentral::DestroySpanPageIfEmpty(SpanPage *sp, bool full) { @@ -716,7 +716,7 @@ namespace ams::mem::impl::heap { size_t first = this->FreeListFirstNonEmpty(0); while (first < FreeListCount) { - for (Span *target = ListGetNext(std::addressof(this->freelists[first])); target; target = ListGetNext(target)) { + for (Span *target = ListGetNext(std::addressof(m_freelists[first])); target; target = ListGetNext(target)) { AMS_ASSERT(target->status == Span::Status_InFreeList); SpanPage *target_sp = GetSpanPage(target); @@ -724,7 +724,7 @@ namespace ams::mem::impl::heap { Span *new_span = this->AllocateSpanFromSpanPage(sp); AMS_ASSERT(new_span != nullptr); - MigrateSpan(std::addressof(this->span_table), target, new_span); + MigrateSpan(std::addressof(m_span_table), target, new_span); this->FreeSpanToSpanPage(target, target_sp); this->DestroySpanPageIfEmpty(target_sp, full); } @@ -743,7 +743,7 @@ namespace ams::mem::impl::heap { if (other_sp->info.free_count > 0x10) { target = other_sp; } else { - for (target = ListGetNext(std::addressof(this->spanpage_list)); target && (target == sp || !target->info.free_count); target = ListGetNext(target)) { + for (target = ListGetNext(std::addressof(m_spanpage_list)); target && (target == sp || !target->info.free_count); target = ListGetNext(target)) { /* ... */ } if (!target) { @@ -757,7 +757,7 @@ namespace ams::mem::impl::heap { Span *new_span = this->AllocateSpanFromSpanPage(target); AMS_ASSERT(new_span != nullptr); - MigrateSpan(std::addressof(this->span_table), GetSpanPageSpan(sp), new_span); + MigrateSpan(std::addressof(m_span_table), GetSpanPageSpan(sp), new_span); ListRemoveSelf(sp); this->FreePagesImpl(new_span); @@ -768,15 +768,15 @@ namespace ams::mem::impl::heap { } Span *TlsHeapCentral::GetFirstSpan() const { - Span *span = GetSpanFromPointer(std::addressof(this->span_table), reinterpret_cast(this)); + Span *span = GetSpanFromPointer(std::addressof(m_span_table), reinterpret_cast(this)); AMS_ASSERT(span != nullptr); - return GetNextSpan(std::addressof(this->span_table), span); + return GetNextSpan(std::addressof(m_span_table), span); } Span *TlsHeapCentral::MakeFreeSpan(size_t num_pages) { while (true) { SpanPage *sp; - for (sp = ListGetNext(std::addressof(this->spanpage_list)); sp && !this->DestroySpanPageIfEmpty(sp, true); sp = ListGetNext(sp)) { + for (sp = ListGetNext(std::addressof(m_spanpage_list)); sp && !this->DestroySpanPageIfEmpty(sp, true); sp = ListGetNext(sp)) { /* ... */ } if (!sp) { @@ -798,7 +798,7 @@ namespace ams::mem::impl::heap { } } - Span *cur = ListGetNext(std::addressof(this->freelists[start])); + Span *cur = ListGetNext(std::addressof(m_freelists[start])); Span *best = cur; if (start == FreeListCount - 1) { if (num_pages >= FreeListCount) { @@ -849,7 +849,7 @@ namespace ams::mem::impl::heap { sp->info.alloc_bitmap &= ~(TopBit >> span_idx); if ((++(sp->info.free_count)) == 1) { ListRemoveSelf(sp); - ListInsertAfter(std::addressof(this->spanpage_list), sp); + ListInsertAfter(std::addressof(m_spanpage_list), sp); } } @@ -861,8 +861,8 @@ namespace ams::mem::impl::heap { AMS_ASSERT(!span->list_prev && !span->list_next); AMS_ASSERT(span->status != Span::Status_InUse); - Span *prev_span = GetPrevSpan(std::addressof(this->span_table), span); - Span *next_span = GetNextSpan(std::addressof(this->span_table), span); + Span *prev_span = GetPrevSpan(std::addressof(m_span_table), span); + Span *next_span = GetNextSpan(std::addressof(m_span_table), span); const bool prev_free = prev_span && prev_span->status == Span::Status_InFreeList; const bool prev_small = prev_span && prev_span->num_pages < FreeListCount; const bool next_free = next_span && next_span->status == Span::Status_InFreeList; @@ -936,16 +936,16 @@ namespace ams::mem::impl::heap { AMS_ASSERT(i < idx_end); if (i + 1 == idx_end) { - if (this->physical_page_flags[i]) { - this->physical_page_flags[i] = 2; + if (m_physical_page_flags[i]) { + m_physical_page_flags[i] = 2; } } else { - const void *set_flag = ::memchr(std::addressof(this->physical_page_flags[i]), 1, idx_end - i); + const void *set_flag = ::memchr(std::addressof(m_physical_page_flags[i]), 1, idx_end - i); if (set_flag) { - const uintptr_t set_idx = reinterpret_cast(set_flag) - this->physical_page_flags; - const void *lst_flag = ::memrchr(std::addressof(this->physical_page_flags[set_idx]), 1, idx_end - set_idx); - const uintptr_t lst_idx = (lst_flag) ? (reinterpret_cast(lst_flag) - this->physical_page_flags + 1) : idx_end; - std::memset(std::addressof(this->physical_page_flags[set_idx]), 2, lst_idx - set_idx); + const uintptr_t set_idx = reinterpret_cast(set_flag) - m_physical_page_flags; + const void *lst_flag = ::memrchr(std::addressof(m_physical_page_flags[set_idx]), 1, idx_end - set_idx); + const uintptr_t lst_idx = (lst_flag) ? (reinterpret_cast(lst_flag) - m_physical_page_flags + 1) : idx_end; + std::memset(std::addressof(m_physical_page_flags[set_idx]), 2, lst_idx - set_idx); } } @@ -953,7 +953,7 @@ namespace ams::mem::impl::heap { } Span *TlsHeapCentral::AllocatePagesImpl(size_t num_pages) { - if (num_pages >= this->span_table.total_pages / 4) { + if (num_pages >= m_span_table.total_pages / 4) { this->MakeFreeSpan(std::numeric_limits::max()); } @@ -968,7 +968,7 @@ namespace ams::mem::impl::heap { AMS_ASSERT(span->status == Span::Status_InFreeList); if (num_pages == span->num_pages) { - if (this->use_virtual_memory && this->AllocatePhysical(span->start.p, span->num_pages * TlsHeapStatic::PageSize) != 0) { + if (m_use_virtual_memory && this->AllocatePhysical(span->start.p, span->num_pages * TlsHeapStatic::PageSize) != 0) { return nullptr; } else { this->RemoveFromFreeBlockList(span); @@ -990,7 +990,7 @@ namespace ams::mem::impl::heap { auto new_span_guard = SCOPE_GUARD { this->FreeSpanToSpanPage(new_span); }; /* Allocating the new span potentially invalidates the span we were looking at, so find the span for it in the table. */ - span = GetSpanFromPointer(std::addressof(this->span_table), prev_ptr); + span = GetSpanFromPointer(std::addressof(m_span_table), prev_ptr); const size_t cur_pages = span->num_pages; /* If the span was partially allocated, we need to find a new one that's big enough. */ @@ -1010,7 +1010,7 @@ namespace ams::mem::impl::heap { new_span_guard.Cancel(); return this->SplitSpan(span, num_pages, new_span); - } else if (this->use_virtual_memory && this->AllocatePhysical(span->start.p, span->num_pages * TlsHeapStatic::PageSize) != 0) { + } else if (m_use_virtual_memory && this->AllocatePhysical(span->start.p, span->num_pages * TlsHeapStatic::PageSize) != 0) { return nullptr; } else { this->RemoveFromFreeBlockList(span); @@ -1023,7 +1023,7 @@ namespace ams::mem::impl::heap { } Span *TlsHeapCentral::AllocatePagesWithBigAlignImpl(size_t num_pages, size_t align) { - if (num_pages >= this->span_table.total_pages / 4) { + if (num_pages >= m_span_table.total_pages / 4) { this->MakeFreeSpan(std::numeric_limits::max()); } @@ -1054,7 +1054,7 @@ namespace ams::mem::impl::heap { AMS_ASSERT(span->status == Span::Status_InFreeList); const uintptr_t aligned_start = util::AlignUp(span->start.u, align); - if (this->use_virtual_memory && this->AllocatePhysical(reinterpret_cast(aligned_start), num_pages * TlsHeapStatic::PageSize) != 0) { + if (m_use_virtual_memory && this->AllocatePhysical(reinterpret_cast(aligned_start), num_pages * TlsHeapStatic::PageSize) != 0) { this->FreeSpanToSpanPage(before_span); this->FreeSpanToSpanPage(after_span); return nullptr; @@ -1072,9 +1072,9 @@ namespace ams::mem::impl::heap { span->status = Span::Status_InUse; span->aux.large_clear.zero = 0; - ChangeRangeOfSpan(std::addressof(this->span_table), span, aligned_start, num_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, aligned_start, num_pages); - RegisterSpan(std::addressof(this->span_table), after_span); + RegisterSpan(std::addressof(m_span_table), after_span); this->MergeIntoFreeList(after_span); return span; @@ -1100,10 +1100,10 @@ namespace ams::mem::impl::heap { span->status = Span::Status_InUse; span->aux.large_clear.zero = 0; - ChangeRangeOfSpan(std::addressof(this->span_table), span, aligned_start, num_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, aligned_start, num_pages); - RegisterSpan(std::addressof(this->span_table), before_span); - RegisterSpan(std::addressof(this->span_table), after_span); + RegisterSpan(std::addressof(m_span_table), before_span); + RegisterSpan(std::addressof(m_span_table), after_span); this->MergeIntoFreeList(before_span); this->MergeIntoFreeList(after_span); @@ -1117,9 +1117,9 @@ namespace ams::mem::impl::heap { span->status = Span::Status_InUse; span->aux.large_clear.zero = 0; - ChangeRangeOfSpan(std::addressof(this->span_table), span, aligned_start, num_pages); + ChangeRangeOfSpan(std::addressof(m_span_table), span, aligned_start, num_pages); - RegisterSpan(std::addressof(this->span_table), before_span); + RegisterSpan(std::addressof(m_span_table), before_span); this->MergeIntoFreeList(before_span); return span; @@ -1134,7 +1134,7 @@ namespace ams::mem::impl::heap { /* Double free error. */ } else { span->status = Span::Status_InFreeList; - if (this->use_virtual_memory) { + if (m_use_virtual_memory) { const uintptr_t start = span->start.u; const uintptr_t end = span->start.u + (span->num_pages * TlsHeapStatic::PageSize); uintptr_t start_alignup = TlsHeapStatic::AlignUpPhysicalPage(start); @@ -1166,7 +1166,7 @@ namespace ams::mem::impl::heap { void *TlsHeapCentral::CacheSmallMemoryImpl(size_t cls, size_t align, bool for_system) { AMS_ASSERT(cls != 0 && cls < TlsHeapStatic::NumClassInfo); - Span *span = ListGetNext(std::addressof(this->smallmem_lists[cls])); + Span *span = ListGetNext(std::addressof(m_smallmem_lists[cls])); while (true) { if (for_system) { while (span && span->status != Span::Status_InUseSystem) { @@ -1200,8 +1200,8 @@ namespace ams::mem::impl::heap { Span *new_span = this->AllocatePagesImpl(TlsHeapStatic::GetNumPages(cls)); if (new_span) { - SpanToSmallMemorySpan(std::addressof(this->span_table), new_span, cls); - ListInsertAfter(std::addressof(this->smallmem_lists[cls]), new_span); + SpanToSmallMemorySpan(std::addressof(m_span_table), new_span, cls); + ListInsertAfter(std::addressof(m_smallmem_lists[cls]), new_span); InitSmallMemorySpan(new_span, cls, for_system, 0); void *mem = AllocateSmallMemory(new_span); @@ -1212,7 +1212,7 @@ namespace ams::mem::impl::heap { } else { for (size_t cur_cls = cls; cur_cls < TlsHeapStatic::NumClassInfo; cur_cls++) { if (align == 0 || util::IsAligned(TlsHeapStatic::GetChunkSize(cur_cls), align)) { - span = ListGetNext(std::addressof(this->smallmem_lists[cur_cls])); + span = ListGetNext(std::addressof(m_smallmem_lists[cur_cls])); if (for_system) { while (span && span->status != Span::Status_InUseSystem) { span = ListGetNext(span); @@ -1242,10 +1242,10 @@ namespace ams::mem::impl::heap { } errno_t TlsHeapCentral::UncacheSmallMemoryImpl(void *ptr) { - Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); + Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); if (span && span->page_class) { if (!span->aux.small.objects) { - ListInsertAfter(std::addressof(this->smallmem_lists[span->page_class]), span); + ListInsertAfter(std::addressof(m_smallmem_lists[span->page_class]), span); } ReleaseSmallMemory(span, ptr); @@ -1254,7 +1254,7 @@ namespace ams::mem::impl::heap { span->aux.small.objects = nullptr; ListRemoveSelf(span); AMS_ASSERT(span->page_class != 0); - SmallMemorySpanToSpan(std::addressof(this->span_table), span); + SmallMemorySpanToSpan(std::addressof(m_span_table), span); this->FreePagesImpl(span); } @@ -1272,7 +1272,7 @@ namespace ams::mem::impl::heap { Span::SmallMemory head = {}; Span::SmallMemory *hptr = std::addressof(head); - Span *span = ListGetNext(std::addressof(this->smallmem_lists[*cls])); + Span *span = ListGetNext(std::addressof(m_smallmem_lists[*cls])); size_t n = 0; while (span) { @@ -1304,8 +1304,8 @@ namespace ams::mem::impl::heap { Span *new_span = this->AllocatePagesImpl(TlsHeapStatic::GetNumPages(*cls)); if (new_span) { - SpanToSmallMemorySpan(std::addressof(this->span_table), new_span, *cls); - ListInsertAfter(std::addressof(this->smallmem_lists[*cls]), new_span); + SpanToSmallMemorySpan(std::addressof(m_span_table), new_span, *cls); + ListInsertAfter(std::addressof(m_smallmem_lists[*cls]), new_span); InitSmallMemorySpan(new_span, *cls, false, cpu_id); MangledSmallMemory memlist; @@ -1329,7 +1329,7 @@ namespace ams::mem::impl::heap { } else { for (size_t cur_cls = *cls; cur_cls < TlsHeapStatic::NumClassInfo; cur_cls++) { if (align == 0 || util::IsAligned(TlsHeapStatic::GetChunkSize(cur_cls), align)) { - span = ListGetNext(std::addressof(this->smallmem_lists[cur_cls])); + span = ListGetNext(std::addressof(m_smallmem_lists[cur_cls])); while (span && (span->status == Span::Status_InUseSystem)) { span = ListGetNext(span); @@ -1363,7 +1363,7 @@ namespace ams::mem::impl::heap { errno_t TlsHeapCentral::WalkAllocatedPointersImpl(HeapWalkCallback callback, void *user_data) { errno_t err = ENOENT; - for (Span *span = GetSpanFromPointer(std::addressof(this->span_table), this); span != nullptr; span = GetNextSpan(std::addressof(this->span_table), span)) { + for (Span *span = GetSpanFromPointer(std::addressof(m_span_table), this); span != nullptr; span = GetNextSpan(std::addressof(m_span_table), span)) { if (span->status != Span::Status_InUse) { continue; } @@ -1416,7 +1416,7 @@ namespace ams::mem::impl::heap { } errno_t TlsHeapCentral::GetMappedMemStatsImpl(size_t *out_free_size, size_t *out_max_allocatable_size) { - if (!this->use_virtual_memory) { + if (!m_use_virtual_memory) { return EOPNOTSUPP; } @@ -1434,7 +1434,7 @@ namespace ams::mem::impl::heap { size_t num_free_spans = 0; size_t wip_allocatable_size = 0; - Span *span = GetSpanFromPointer(std::addressof(this->span_table), this); + Span *span = GetSpanFromPointer(std::addressof(m_span_table), this); while (span) { const size_t size = span->num_pages * TlsHeapStatic::PageSize; @@ -1463,13 +1463,13 @@ namespace ams::mem::impl::heap { wip_allocatable_size += size; } - span = GetNextSpan(std::addressof(this->span_table), span); + span = GetNextSpan(std::addressof(m_span_table), span); } max_allocatable_size = std::max(max_allocatable_size, wip_allocatable_size); bool sp_full = true; - for (SpanPage *sp = ListGetNext(std::addressof(this->spanpage_list)); sp != nullptr; sp = ListGetNext(sp)) { + for (SpanPage *sp = ListGetNext(std::addressof(m_spanpage_list)); sp != nullptr; sp = ListGetNext(sp)) { if (sp->info.is_sticky == 0 && CanAllocateSpan(sp)) { sp_full = false; break; diff --git a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp index 3564de76c..853599ded 100644 --- a/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp +++ b/libraries/libstratosphere/source/mem/impl/heap/mem_impl_heap_tls_heap_central.hpp @@ -195,21 +195,21 @@ namespace ams::mem::impl::heap { static_assert(NumFreeListBitmaps * BITSIZEOF(FreeListAvailableWord) == FreeListCount); private: - SpanTable span_table; - u8 *physical_page_flags; - s32 num_threads; - s32 static_thread_quota; - s32 dynamic_thread_quota; - bool use_virtual_memory; - os::SdkRecursiveMutex lock; - ListHeader spanpage_list; - ListHeader full_spanpage_list; - ListHeader freelists[FreeListCount]; - FreeListAvailableWord freelists_bitmap[NumFreeListBitmaps]; - ListHeader smallmem_lists[TlsHeapStatic::NumClassInfo]; + SpanTable m_span_table; + u8 *m_physical_page_flags; + s32 m_num_threads; + s32 m_static_thread_quota; + s32 m_dynamic_thread_quota; + bool m_use_virtual_memory; + os::SdkRecursiveMutex m_lock; + ListHeader m_spanpage_list; + ListHeader m_full_spanpage_list; + ListHeader m_freelists[FreeListCount]; + FreeListAvailableWord m_freelists_bitmap[NumFreeListBitmaps]; + ListHeader m_smallmem_lists[TlsHeapStatic::NumClassInfo]; public: - TlsHeapCentral() : lock() { - this->span_table.total_pages = 0; + TlsHeapCentral() : m_lock() { + m_span_table.total_pages = 0; } errno_t Initialize(void *start, size_t size, bool use_virtual_memory); @@ -223,11 +223,11 @@ namespace ams::mem::impl::heap { errno_t AddThreadCache(TlsHeapCache *cache) { AMS_UNUSED(cache); - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Add thread and recalculate. */ - this->num_threads++; - this->dynamic_thread_quota = this->GetTotalHeapSize() / (2 * this->num_threads); + m_num_threads++; + m_dynamic_thread_quota = this->GetTotalHeapSize() / (2 * m_num_threads); return 0; } @@ -235,17 +235,17 @@ namespace ams::mem::impl::heap { errno_t RemoveThreadCache(TlsHeapCache *cache) { AMS_UNUSED(cache); - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Remove thread and recalculate. */ - this->num_threads--; - this->dynamic_thread_quota = this->GetTotalHeapSize() / (2 * this->num_threads); + m_num_threads--; + m_dynamic_thread_quota = this->GetTotalHeapSize() / (2 * m_num_threads); return 0; } void *CacheLargeMemory(size_t size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); const size_t num_pages = util::AlignUp(size, TlsHeapStatic::PageSize) / TlsHeapStatic::PageSize; if (Span *span = this->AllocatePagesImpl(num_pages); span != nullptr) { @@ -256,7 +256,7 @@ namespace ams::mem::impl::heap { } void *CacheLargeMemoryWithBigAlign(size_t size, size_t align) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); const size_t num_pages = util::AlignUp(size, TlsHeapStatic::PageSize) / TlsHeapStatic::PageSize; @@ -275,19 +275,19 @@ namespace ams::mem::impl::heap { } void *CacheSmallMemory(size_t cls, size_t align = 0) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->CacheSmallMemoryImpl(cls, align, false); } void *CacheSmallMemoryForSystem(size_t cls) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->CacheSmallMemoryImpl(cls, 0, true); } size_t CacheSmallMemoryList(TlsHeapCache *cache, size_t *cls, size_t count, void **p, size_t align = 0) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); s32 cpu_id = 0; if (*cls < 8) { @@ -298,11 +298,11 @@ namespace ams::mem::impl::heap { } bool CheckCachedSize(s32 size) const { - return size < this->dynamic_thread_quota && size < this->static_thread_quota; + return size < m_dynamic_thread_quota && size < m_static_thread_quota; } void Dump(DumpMode dump_mode, int fd, bool json) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->DumpImpl(dump_mode, fd, json); } @@ -310,8 +310,8 @@ namespace ams::mem::impl::heap { if (TlsHeapStatic::IsPageAligned(ptr)) { Span *span = nullptr; { - std::scoped_lock lk(this->lock); - span = GetSpanFromPointer(std::addressof(this->span_table), ptr); + std::scoped_lock lk(m_lock); + span = GetSpanFromPointer(std::addressof(m_span_table), ptr); } if (span != nullptr) { return span->num_pages * TlsHeapStatic::PageSize; @@ -329,17 +329,17 @@ namespace ams::mem::impl::heap { std::atomic_thread_fence(std::memory_order_acquire); const size_t idx = (reinterpret_cast(ptr) - reinterpret_cast(this)) / TlsHeapStatic::PageSize; - if (idx < this->span_table.total_pages) { + if (idx < m_span_table.total_pages) { if (ptr != nullptr) { - std::scoped_lock lk(this->lock); - Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); + std::scoped_lock lk(m_lock); + Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); if (span != nullptr) { - AMS_ASSERT(span->page_class == this->span_table.pageclass_cache[idx]); + AMS_ASSERT(span->page_class == m_span_table.pageclass_cache[idx]); } else { AMS_ASSERT(span != nullptr); } } - return this->span_table.pageclass_cache[idx]; + return m_span_table.pageclass_cache[idx]; } else { /* TODO: Handle error? */ return -1; @@ -351,8 +351,8 @@ namespace ams::mem::impl::heap { return EINVAL; } - std::scoped_lock lk(this->lock); - if (Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); span != nullptr && !span->page_class) { + std::scoped_lock lk(m_lock); + if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) { *out = (span->aux.large.color[0] << 0) | (span->aux.large.color[1] << 8) | (span->aux.large.color[2] << 16); return 0; } else { @@ -361,8 +361,8 @@ namespace ams::mem::impl::heap { } errno_t SetColor(const void *ptr, int color) { - std::scoped_lock lk(this->lock); - if (Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); span != nullptr && !span->page_class) { + std::scoped_lock lk(m_lock); + if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) { span->aux.large.color[0] = (color >> 0) & 0xFF; span->aux.large.color[1] = (color >> 8) & 0xFF; span->aux.large.color[2] = (color >> 16) & 0xFF; @@ -373,20 +373,20 @@ namespace ams::mem::impl::heap { } errno_t GetMappedMemStats(size_t *out_free_size, size_t *out_max_allocatable_size) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->GetMappedMemStatsImpl(out_free_size, out_max_allocatable_size); } errno_t GetMemStats(TlsHeapMemStats *out) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->GetMemStatsImpl(out); } errno_t GetName(const void *ptr, char *dst, size_t dst_size) { - std::scoped_lock lk(this->lock); - if (Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); span != nullptr && !span->page_class) { + std::scoped_lock lk(m_lock); + if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) { util::Strlcpy(dst, span->aux.large.name, dst_size); return 0; } else { @@ -395,8 +395,8 @@ namespace ams::mem::impl::heap { } errno_t SetName(const void *ptr, const char *name) { - std::scoped_lock lk(this->lock); - if (Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); span != nullptr && !span->page_class) { + std::scoped_lock lk(m_lock); + if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr && !span->page_class) { util::Strlcpy(span->aux.large.name, name, sizeof(span->aux.large.name)); return 0; } else { @@ -405,13 +405,13 @@ namespace ams::mem::impl::heap { } size_t GetTotalHeapSize() const { - return this->span_table.total_pages * TlsHeapStatic::PageSize; + return m_span_table.total_pages * TlsHeapStatic::PageSize; } errno_t UncacheLargeMemory(void *ptr) { if (TlsHeapStatic::IsPageAligned(ptr)) { - std::scoped_lock lk(this->lock); - if (Span *span = GetSpanFromPointer(std::addressof(this->span_table), ptr); span != nullptr) { + std::scoped_lock lk(m_lock); + if (Span *span = GetSpanFromPointer(std::addressof(m_span_table), ptr); span != nullptr) { this->FreePagesImpl(span); return 0; } else { @@ -423,12 +423,12 @@ namespace ams::mem::impl::heap { } errno_t UncacheSmallMemory(void *ptr) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); return this->UncacheSmallMemoryImpl(ptr); } errno_t UncacheSmallMemoryList(TlsHeapCache *cache, void *ptr) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); while (true) { if (ptr == nullptr) { @@ -445,8 +445,8 @@ namespace ams::mem::impl::heap { errno_t WalkAllocatedPointers(HeapWalkCallback callback, void *user_data) { /* Explicitly handle locking, as we will release the lock during callback. */ - this->lock.lock(); - ON_SCOPE_EXIT { this->lock.unlock(); }; + m_lock.lock(); + ON_SCOPE_EXIT { m_lock.unlock(); }; return this->WalkAllocatedPointersImpl(callback, user_data); } @@ -488,8 +488,8 @@ namespace ams::mem::impl::heap { private: size_t FreeListFirstNonEmpty(size_t start) const { if (start < FreeListCount) { - for (size_t i = FreeListAvailableIndex(start); i < util::size(this->freelists_bitmap); i++) { - const FreeListAvailableWord masked = this->freelists_bitmap[i] & ~(FreeListAvailableMask(start) - 1); + for (size_t i = FreeListAvailableIndex(start); i < util::size(m_freelists_bitmap); i++) { + const FreeListAvailableWord masked = m_freelists_bitmap[i] & ~(FreeListAvailableMask(start) - 1); if (masked) { const size_t b = __builtin_ctzll(masked); const size_t res = i * BITSIZEOF(FreeListAvailableWord) + b; @@ -506,20 +506,20 @@ namespace ams::mem::impl::heap { AMS_ASSERT(GetSpanPageSpan(GetSpanPage(span)) != span); AMS_ASSERT(span->status == Span::Status_InFreeList); const size_t which = std::min(span->num_pages, FreeListCount) - 1; - ListInsertAfter(std::addressof(this->freelists[which]), span); - this->freelists_bitmap[FreeListAvailableIndex(which)] |= FreeListAvailableMask(which); + ListInsertAfter(std::addressof(m_freelists[which]), span); + m_freelists_bitmap[FreeListAvailableIndex(which)] |= FreeListAvailableMask(which); } ALWAYS_INLINE void RemoveFromFreeBlockList(Span *span) { const size_t which = std::min(span->num_pages, FreeListCount) - 1; ListRemoveSelf(span); - if (!ListGetNext(std::addressof(this->freelists[which]))) { - this->freelists_bitmap[FreeListAvailableIndex(which)] &= ~FreeListAvailableMask(which); + if (!ListGetNext(std::addressof(m_freelists[which]))) { + m_freelists_bitmap[FreeListAvailableIndex(which)] &= ~FreeListAvailableMask(which); } } Span *AllocateSpanStruct() { - SpanPage *sp = ListGetNext(std::addressof(this->spanpage_list)); + SpanPage *sp = ListGetNext(std::addressof(m_spanpage_list)); while (sp && (sp->info.is_sticky || !CanAllocateSpan(sp))) { sp = ListGetNext(sp); } @@ -536,9 +536,9 @@ namespace ams::mem::impl::heap { } s32 CallWalkCallback(HeapWalkCallback callback, void *ptr, size_t size, void *user_data) { - this->lock.unlock(); + m_lock.unlock(); int res = callback(ptr, size, user_data); - this->lock.lock(); + m_lock.lock(); if (res) { return 0; } else { diff --git a/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp b/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp index b6aef76f6..65712ba94 100644 --- a/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp +++ b/libraries/libstratosphere/source/mem/mem_standard_allocator.cpp @@ -66,9 +66,9 @@ namespace ams::mem { } - StandardAllocator::StandardAllocator() : initialized(false), enable_thread_cache(false), unused(0) { - static_assert(sizeof(impl::heap::CentralHeap) <= sizeof(this->central_heap_storage)); - std::construct_at(GetCentral(this->central_heap_storage)); + StandardAllocator::StandardAllocator() : m_initialized(false), m_enable_thread_cache(false), m_unused(0) { + static_assert(sizeof(impl::heap::CentralHeap) <= sizeof(m_central_heap_storage)); + std::construct_at(GetCentral(m_central_heap_storage)); } StandardAllocator::StandardAllocator(void *mem, size_t size) : StandardAllocator() { @@ -84,7 +84,7 @@ namespace ams::mem { } void StandardAllocator::Initialize(void *mem, size_t size, bool enable_cache) { - AMS_ABORT_UNLESS(!this->initialized); + AMS_ABORT_UNLESS(!m_initialized); const uintptr_t aligned_start = util::AlignUp(reinterpret_cast(mem), impl::heap::TlsHeapStatic::PageSize); const uintptr_t aligned_end = util::AlignDown(reinterpret_cast(mem) + size, impl::heap::TlsHeapStatic::PageSize); @@ -92,47 +92,47 @@ namespace ams::mem { if (mem == nullptr) { AMS_ABORT_UNLESS(os::IsVirtualAddressMemoryEnabled()); - AMS_ABORT_UNLESS(GetCentral(this->central_heap_storage)->Initialize(nullptr, size, 0) == 0); + AMS_ABORT_UNLESS(GetCentral(m_central_heap_storage)->Initialize(nullptr, size, 0) == 0); } else { AMS_ABORT_UNLESS(aligned_start < aligned_end); AMS_ABORT_UNLESS(aligned_size >= MinimumAllocatorSize); - AMS_ABORT_UNLESS(GetCentral(this->central_heap_storage)->Initialize(reinterpret_cast(aligned_start), aligned_size, 0) == 0); + AMS_ABORT_UNLESS(GetCentral(m_central_heap_storage)->Initialize(reinterpret_cast(aligned_start), aligned_size, 0) == 0); } - this->enable_thread_cache = enable_cache; - if (this->enable_thread_cache) { - R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(this->tls_slot), ThreadDestroy)); + m_enable_thread_cache = enable_cache; + if (m_enable_thread_cache) { + R_ABORT_UNLESS(os::AllocateTlsSlot(std::addressof(m_tls_slot), ThreadDestroy)); } - this->initialized = true; + m_initialized = true; } void StandardAllocator::Finalize() { - AMS_ABORT_UNLESS(this->initialized); + AMS_ABORT_UNLESS(m_initialized); - if (this->enable_thread_cache) { - os::FreeTlsSlot(this->tls_slot); + if (m_enable_thread_cache) { + os::FreeTlsSlot(m_tls_slot); } - GetCentral(this->central_heap_storage)->Finalize(); + GetCentral(m_central_heap_storage)->Finalize(); - this->initialized = false; + m_initialized = false; } void *StandardAllocator::Allocate(size_t size) { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); return this->Allocate(size, DefaultAlignment); } void *StandardAllocator::Allocate(size_t size, size_t alignment) { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); impl::heap::TlsHeapCache *heap_cache = nullptr; - if (this->enable_thread_cache) { - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); if (!heap_cache) { - GetCache(GetCentral(this->central_heap_storage), this->tls_slot); - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + GetCache(GetCentral(m_central_heap_storage), m_tls_slot); + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); } } @@ -146,34 +146,34 @@ namespace ams::mem { impl::heap::CachedHeap cache; cache.Reset(heap_cache); cache.Query(impl::AllocQuery_FinalizeCache); - os::SetTlsValue(this->tls_slot, 0); + os::SetTlsValue(m_tls_slot, 0); } - return GetCentral(this->central_heap_storage)->Allocate(size, alignment); + return GetCentral(m_central_heap_storage)->Allocate(size, alignment); } void StandardAllocator::Free(void *ptr) { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); if (ptr == nullptr) { return; } - if (this->enable_thread_cache) { - impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); if (heap_cache) { heap_cache->Free(ptr); return; } } - const auto err = GetCentral(this->central_heap_storage)->Free(ptr); + const auto err = GetCentral(m_central_heap_storage)->Free(ptr); AMS_ASSERT(err == 0); AMS_UNUSED(err); } void *StandardAllocator::Reallocate(void *ptr, size_t new_size) { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); if (new_size > impl::MaxSize) { return nullptr; @@ -192,11 +192,11 @@ namespace ams::mem { impl::heap::TlsHeapCache *heap_cache = nullptr; - if (this->enable_thread_cache) { - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); if (!heap_cache) { - GetCache(GetCentral(this->central_heap_storage), this->tls_slot); - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + GetCache(GetCentral(m_central_heap_storage), m_tls_slot); + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); } } @@ -205,7 +205,7 @@ namespace ams::mem { if (heap_cache) { err = heap_cache->Reallocate(ptr, aligned_new_size, std::addressof(p)); } else { - err = GetCentral(this->central_heap_storage)->Reallocate(ptr, aligned_new_size, std::addressof(p)); + err = GetCentral(m_central_heap_storage)->Reallocate(ptr, aligned_new_size, std::addressof(p)); } if (err == 0) { @@ -216,10 +216,10 @@ namespace ams::mem { } size_t StandardAllocator::Shrink(void *ptr, size_t new_size) { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); - if (this->enable_thread_cache) { - impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); if (heap_cache) { if (heap_cache->Shrink(ptr, new_size) == 0) { return heap_cache->GetAllocationSize(ptr); @@ -229,16 +229,16 @@ namespace ams::mem { } } - if (GetCentral(this->central_heap_storage)->Shrink(ptr, new_size) == 0) { - return GetCentral(this->central_heap_storage)->GetAllocationSize(ptr); + if (GetCentral(m_central_heap_storage)->Shrink(ptr, new_size) == 0) { + return GetCentral(m_central_heap_storage)->GetAllocationSize(ptr); } else { return 0; } } void StandardAllocator::ClearThreadCache() const { - if (this->enable_thread_cache) { - impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + impl::heap::TlsHeapCache *heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); impl::heap::CachedHeap cache; cache.Reset(heap_cache); cache.Query(impl::AllocQuery_ClearCache); @@ -247,42 +247,42 @@ namespace ams::mem { } void StandardAllocator::CleanUpManagementArea() const { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); - const auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_UnifyFreeList); + const auto err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_UnifyFreeList); AMS_ASSERT(err == 0); AMS_UNUSED(err); } size_t StandardAllocator::GetSizeOf(const void *ptr) const { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); if (!util::IsAligned(reinterpret_cast(ptr), DefaultAlignment)) { return 0; } impl::heap::TlsHeapCache *heap_cache = nullptr; - if (this->enable_thread_cache) { - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + if (m_enable_thread_cache) { + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); if (!heap_cache) { - GetCache(GetCentral(this->central_heap_storage), this->tls_slot); - heap_cache = reinterpret_cast(os::GetTlsValue(this->tls_slot)); + GetCache(GetCentral(m_central_heap_storage), m_tls_slot); + heap_cache = reinterpret_cast(os::GetTlsValue(m_tls_slot)); } } if (heap_cache) { return heap_cache->GetAllocationSize(ptr); } else { - return GetCentral(this->central_heap_storage)->GetAllocationSize(ptr); + return GetCentral(m_central_heap_storage)->GetAllocationSize(ptr); } } size_t StandardAllocator::GetTotalFreeSize() const { size_t size = 0; - auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_FreeSizeMapped, std::addressof(size)); + auto err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_FreeSizeMapped, std::addressof(size)); if (err != 0) { - err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_FreeSize, std::addressof(size)); + err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_FreeSize, std::addressof(size)); } AMS_ASSERT(err == 0); @@ -292,9 +292,9 @@ namespace ams::mem { size_t StandardAllocator::GetAllocatableSize() const { size_t size = 0; - auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSizeMapped, std::addressof(size)); + auto err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSizeMapped, std::addressof(size)); if (err != 0) { - err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSize, std::addressof(size)); + err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSize, std::addressof(size)); } AMS_ASSERT(err == 0); @@ -302,26 +302,26 @@ namespace ams::mem { } void StandardAllocator::WalkAllocatedBlocks(WalkCallback callback, void *user_data) const { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); this->ClearThreadCache(); - GetCentral(this->central_heap_storage)->WalkAllocatedPointers(callback, user_data); + GetCentral(m_central_heap_storage)->WalkAllocatedPointers(callback, user_data); } void StandardAllocator::Dump() const { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); size_t tmp; - auto err = GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSizeMapped, std::addressof(tmp)); + auto err = GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_MaxAllocatableSizeMapped, std::addressof(tmp)); if (err == 0) { - GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_Dump, impl::DumpMode_Spans | impl::DumpMode_Pointers, 1); + GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_Dump, impl::DumpMode_Spans | impl::DumpMode_Pointers, 1); } else { - GetCentral(this->central_heap_storage)->Query(impl::AllocQuery_Dump, impl::DumpMode_All, 1); + GetCentral(m_central_heap_storage)->Query(impl::AllocQuery_Dump, impl::DumpMode_All, 1); } } StandardAllocator::AllocatorHash StandardAllocator::Hash() const { - AMS_ASSERT(this->initialized); + AMS_ASSERT(m_initialized); AllocatorHash alloc_hash; { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp index d577f66bb..22549d219 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp @@ -80,7 +80,7 @@ namespace ams::ncm { ncm::ContentMetaReader meta_reader(meta.get(), meta_size); /* Insert the new metas into the database. */ - R_TRY(this->db->Set(package_meta_reader.GetKey(), meta_reader.GetData(), meta_reader.GetSize())); + R_TRY(m_db->Set(package_meta_reader.GetKey(), meta_reader.GetData(), meta_reader.GetSize())); /* We're done. */ return ResultSuccess(); @@ -123,7 +123,7 @@ namespace ams::ncm { } /* Commit our changes. */ - return this->db->Commit(); + return m_db->Commit(); } Result ContentMetaDatabaseBuilder::BuildFromPackage(const char *package_root_path) { @@ -148,7 +148,7 @@ namespace ams::ncm { })); /* Commit our changes. */ - return this->db->Commit(); + return m_db->Commit(); } Result ContentMetaDatabaseBuilder::Cleanup() { @@ -157,11 +157,11 @@ namespace ams::ncm { /* List as many keys as we can. */ constexpr s32 MaxKeys = 64; ContentMetaKey keys[MaxKeys]; - auto list_count = this->db->ListContentMeta(keys, MaxKeys); + auto list_count = m_db->ListContentMeta(keys, MaxKeys); /* Remove the listed keys. */ for (auto i = 0; i < list_count.written; i++) { - R_TRY(this->db->Remove(keys[i])); + R_TRY(m_db->Remove(keys[i])); } /* If there aren't more keys to read, we're done. */ @@ -171,7 +171,7 @@ namespace ams::ncm { } /* Commit our deletions. */ - return this->db->Commit(); + return m_db->Commit(); } Result ListApplicationPackage(s32 *out_count, ApplicationId *out_ids, size_t max_out_ids, const char *package_root_path) { diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index 9c7f02706..5ed0bf4fc 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -133,15 +133,15 @@ namespace ams::ncm { } ContentManagerImpl::~ContentManagerImpl() { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Disable and unmount all content storage roots. */ - for (auto &root : this->content_storage_roots) { + for (auto &root : m_content_storage_roots) { this->InactivateContentStorage(root.storage_id); } /* Disable and unmount all content meta database roots. */ - for (auto &root : this->content_meta_database_roots) { + for (auto &root : m_content_meta_database_roots) { this->InactivateContentMetaDatabase(root.storage_id); } } @@ -171,7 +171,7 @@ namespace ams::ncm { R_UNLESS(IsUniqueStorage(id), ncm::ResultUnknownStorage()); /* Find a root with a matching storage id. */ - for (auto &root : this->content_storage_roots) { + for (auto &root : m_content_storage_roots) { if (root.storage_id == id) { *out = std::addressof(root); return ResultSuccess(); @@ -186,7 +186,7 @@ namespace ams::ncm { R_UNLESS(IsUniqueStorage(id), ncm::ResultUnknownStorage()); /* Find a root with a matching storage id. */ - for (auto &root : this->content_meta_database_roots) { + for (auto &root : m_content_meta_database_roots) { if (root.storage_id == id) { *out = std::addressof(root); return ResultSuccess(); @@ -247,7 +247,7 @@ namespace ams::ncm { } Result ContentManagerImpl::ImportContentMetaDatabaseImpl(StorageId storage_id, const char *import_mount_name, const char *path) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content meta database root. */ ContentMetaDatabaseRoot *root; @@ -316,29 +316,29 @@ namespace ams::ncm { } Result ContentManagerImpl::Initialize(const ContentManagerConfig &config) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Check if we've already initialized. */ - R_SUCCEED_IF(this->initialized); + R_SUCCEED_IF(m_initialized); /* Clear storage id for all roots. */ - for (auto &root : this->content_storage_roots) { + for (auto &root : m_content_storage_roots) { root.storage_id = StorageId::None; } - for (auto &root : this->content_meta_database_roots) { + for (auto &root : m_content_meta_database_roots) { root.storage_id = StorageId::None; } /* First, setup the BuiltInSystem storage entry. */ - R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System)); + R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[m_num_content_storage_entries++]), StorageId::BuiltInSystem, fs::ContentStorageId::System)); if (R_FAILED(this->VerifyContentStorage(StorageId::BuiltInSystem))) { R_TRY(this->CreateContentStorage(StorageId::BuiltInSystem)); } R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem)); /* Next, the BuiltInSystem content meta entry. */ - R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource))); + R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[m_num_content_meta_entries++]), StorageId::BuiltInSystem, BuiltInSystemSystemSaveDataInfo, SystemMaxContentMetaCount, std::addressof(g_system_content_meta_memory_resource))); if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) { R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem)); @@ -365,26 +365,26 @@ namespace ams::ncm { R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem)); /* Now for BuiltInUser's content storage and content meta entries. */ - R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[this->num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User)); - R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[this->num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource))); + R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[m_num_content_storage_entries++]), StorageId::BuiltInUser, fs::ContentStorageId::User)); + R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[m_num_content_meta_entries++]), StorageId::BuiltInUser, BuiltInUserSystemSaveDataInfo, UserMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource))); /* Beyond this point, N uses hardcoded indices. */ /* Next SdCard's content storage and content meta entries. */ - R_TRY(this->InitializeContentStorageRoot(std::addressof(this->content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard)); - R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource))); + R_TRY(this->InitializeContentStorageRoot(std::addressof(m_content_storage_roots[2]), StorageId::SdCard, fs::ContentStorageId::SdCard)); + R_TRY(this->InitializeContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[2]), StorageId::SdCard, SdCardSystemSaveDataInfo, SdCardMaxContentMetaCount, std::addressof(g_sd_and_user_content_meta_memory_resource))); /* GameCard's content storage and content meta entries. */ /* N doesn't set a content storage id for game cards, so we'll just use 0 (System). */ - R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(this->content_storage_roots[3]))); - R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(this->content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource))); + R_TRY(this->InitializeGameCardContentStorageRoot(std::addressof(m_content_storage_roots[3]))); + R_TRY(this->InitializeGameCardContentMetaDatabaseRoot(std::addressof(m_content_meta_database_roots[3]), GameCardMaxContentMetaCount, std::addressof(g_gamecard_content_meta_memory_resource))); - this->initialized = true; + m_initialized = true; return ResultSuccess(); } Result ContentManagerImpl::CreateContentStorage(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content storage root. */ ContentStorageRoot *root; @@ -402,7 +402,7 @@ namespace ams::ncm { } Result ContentManagerImpl::CreateContentMetaDatabase(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); R_UNLESS(storage_id != StorageId::GameCard, ncm::ResultUnknownStorage()); @@ -422,7 +422,7 @@ namespace ams::ncm { } Result ContentManagerImpl::VerifyContentStorage(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content storage root. */ ContentStorageRoot *root; @@ -445,7 +445,7 @@ namespace ams::ncm { /* Game card content meta databases will always be valid. */ R_SUCCEED_IF(storage_id == StorageId::GameCard); - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content meta database root. */ ContentMetaDatabaseRoot *root; @@ -467,7 +467,7 @@ namespace ams::ncm { } Result ContentManagerImpl::OpenContentStorage(sf::Out> out, StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content storage root. */ ContentStorageRoot *root; @@ -488,7 +488,7 @@ namespace ams::ncm { } Result ContentManagerImpl::OpenContentMetaDatabase(sf::Out> out, StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content meta database root. */ ContentMetaDatabaseRoot *root; @@ -517,7 +517,7 @@ namespace ams::ncm { } Result ContentManagerImpl::CleanupContentMetaDatabase(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Disable and unmount content meta database root. */ R_TRY(this->InactivateContentMetaDatabase(storage_id)); @@ -531,7 +531,7 @@ namespace ams::ncm { } Result ContentManagerImpl::ActivateContentStorage(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content storage root. */ ContentStorageRoot *root; @@ -554,7 +554,7 @@ namespace ams::ncm { if (storage_id == StorageId::Host) { /* Create a host content storage. */ - auto content_storage = sf::CreateSharedObjectEmplaced(std::addressof(this->registered_host_content)); + auto content_storage = sf::CreateSharedObjectEmplaced(std::addressof(m_registered_host_content)); root->content_storage = std::move(content_storage); } else if (storage_id == StorageId::GameCard) { /* Game card content storage is read only. */ @@ -568,13 +568,13 @@ namespace ams::ncm { /* Initialize content storage with an appropriate path function. */ switch (storage_id) { case StorageId::BuiltInSystem: - R_TRY(content_storage.GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(this->rights_id_cache))); + R_TRY(content_storage.GetImpl().Initialize(root->path, MakeFlatContentFilePath, MakeFlatPlaceHolderFilePath, false, std::addressof(m_rights_id_cache))); break; case StorageId::SdCard: - R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(this->rights_id_cache))); + R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, true, std::addressof(m_rights_id_cache))); break; default: - R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(this->rights_id_cache))); + R_TRY(content_storage.GetImpl().Initialize(root->path, MakeSha256HierarchicalContentFilePath_ForFat16KCluster, MakeSha256HierarchicalPlaceHolderFilePath_ForFat16KCluster, false, std::addressof(m_rights_id_cache))); break; } @@ -587,7 +587,7 @@ namespace ams::ncm { } Result ContentManagerImpl::InactivateContentStorage(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content storage root. */ ContentStorageRoot *root; @@ -600,7 +600,7 @@ namespace ams::ncm { root->content_storage = nullptr; if (storage_id == StorageId::Host) { - this->registered_host_content.ClearPaths(); + m_registered_host_content.ClearPaths(); } else { fs::Unmount(root->mount_name); } @@ -610,7 +610,7 @@ namespace ams::ncm { } Result ContentManagerImpl::ActivateContentMetaDatabase(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content meta database root. */ ContentMetaDatabaseRoot *root; @@ -648,7 +648,7 @@ namespace ams::ncm { } Result ContentManagerImpl::InactivateContentMetaDatabase(StorageId storage_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the content meta database root. */ ContentMetaDatabaseRoot *root; @@ -671,7 +671,7 @@ namespace ams::ncm { } Result ContentManagerImpl::InvalidateRightsIdCache() { - this->rights_id_cache.Invalidate(); + m_rights_id_cache.Invalidate(); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index dc97dee72..60fbfdc80 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -22,8 +22,8 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); /* Find the meta key. */ - const auto it = this->kvs->lower_bound(key); - R_UNLESS(it != this->kvs->end(), ncm::ResultContentMetaNotFound()); + const auto it = m_kvs->lower_bound(key); + R_UNLESS(it != m_kvs->end(), ncm::ResultContentMetaNotFound()); R_UNLESS(it->GetKey().id == key.id, ncm::ResultContentMetaNotFound()); const auto found_key = it->GetKey(); @@ -51,7 +51,7 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::Set(const ContentMetaKey &key, const sf::InBuffer &value) { R_TRY(this->EnsureEnabled()); - return this->kvs->Set(key, value.GetPointer(), value.GetSize()); + return m_kvs->Set(key, value.GetPointer(), value.GetSize()); } Result ContentMetaDatabaseImpl::Get(sf::Out out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) { @@ -59,7 +59,7 @@ namespace ams::ncm { /* Get the entry from our key-value store. */ size_t size; - R_TRY_CATCH(this->kvs->Get(std::addressof(size), out_value.GetPointer(), out_value.GetSize(), key)) { + R_TRY_CATCH(m_kvs->Get(std::addressof(size), out_value.GetPointer(), out_value.GetSize(), key)) { R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound()) } R_END_TRY_CATCH; @@ -70,7 +70,7 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::Remove(const ContentMetaKey &key) { R_TRY(this->EnsureEnabled()); - R_TRY_CATCH(this->kvs->Remove(key)) { + R_TRY_CATCH(m_kvs->Remove(key)) { R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound()) } R_END_TRY_CATCH; @@ -110,7 +110,7 @@ namespace ams::ncm { size_t entries_written = 0; /* Iterate over all entries. */ - for (auto &entry : *this->kvs) { + for (auto &entry : *m_kvs) { const ContentMetaKey key = entry.GetKey(); /* Check if this entry matches the given filters. */ @@ -152,7 +152,7 @@ namespace ams::ncm { util::optional found_key = util::nullopt; /* Find the last key with the desired program id. */ - for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) { + for (auto entry = m_kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != m_kvs->end(); entry++) { /* No further entries will match the program id, discontinue. */ if (entry->GetKey().id != id) { break; @@ -178,7 +178,7 @@ namespace ams::ncm { size_t entries_written = 0; /* Iterate over all entries. */ - for (auto &entry : *this->kvs) { + for (auto &entry : *m_kvs) { const ContentMetaKey key = entry.GetKey(); /* Check if this entry matches the given filters. */ @@ -210,7 +210,7 @@ namespace ams::ncm { /* Check if key is present. */ size_t size; - R_TRY_CATCH(this->kvs->GetValueSize(&size, key)) { + R_TRY_CATCH(m_kvs->GetValueSize(&size, key)) { R_CONVERT(kvdb::ResultKeyNotFound, ResultSuccess()); } R_END_TRY_CATCH; @@ -295,7 +295,7 @@ namespace ams::ncm { } Result ContentMetaDatabaseImpl::DisableForcibly() { - this->disabled = true; + m_disabled = true; return ResultSuccess(); } @@ -320,7 +320,7 @@ namespace ams::ncm { }; /* Iterate over all entries. */ - for (auto &entry : *this->kvs) { + for (auto &entry : *m_kvs) { ContentMetaReader reader(entry.GetValuePointer(), entry.GetValueSize()); /* Check if any of this entry's content infos matches one of the content ids for lookup. */ @@ -339,8 +339,8 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); /* Save and commit. */ - R_TRY(this->kvs->Save()); - return fs::CommitSaveData(this->mount_name); + R_TRY(m_kvs->Save()); + return fs::CommitSaveData(m_mount_name); } Result ContentMetaDatabaseImpl::HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) { @@ -440,7 +440,7 @@ namespace ams::ncm { Result ContentMetaDatabaseImpl::GetCount(sf::Out out_count) { R_TRY(this->EnsureEnabled()); - out_count.SetValue(this->kvs->GetCount()); + out_count.SetValue(m_kvs->GetCount()); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp index e910dfe24..599982e0f 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp @@ -24,24 +24,24 @@ namespace ams::ncm { protected: using ContentMetaKeyValueStore = ams::kvdb::MemoryKeyValueStore; protected: - ContentMetaKeyValueStore *kvs; - char mount_name[fs::MountNameLengthMax + 1]; - bool disabled; + ContentMetaKeyValueStore *m_kvs; + char m_mount_name[fs::MountNameLengthMax + 1]; + bool m_disabled; protected: - ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : kvs(kvs), disabled(false) { /* ... */ } + ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs) : m_kvs(kvs), m_disabled(false) { /* ... */ } ContentMetaDatabaseImplBase(ContentMetaKeyValueStore *kvs, const char *mount_name) : ContentMetaDatabaseImplBase(kvs) { - std::strcpy(this->mount_name, mount_name); + std::strcpy(m_mount_name, mount_name); } protected: /* Helpers. */ Result EnsureEnabled() const { - R_UNLESS(!this->disabled, ncm::ResultInvalidContentMetaDatabase()); + R_UNLESS(!m_disabled, ncm::ResultInvalidContentMetaDatabase()); return ResultSuccess(); } Result GetContentMetaSize(size_t *out, const ContentMetaKey &key) const { - R_TRY_CATCH(this->kvs->GetValueSize(out, key)) { + R_TRY_CATCH(m_kvs->GetValueSize(out, key)) { R_CONVERT(kvdb::ResultKeyNotFound, ncm::ResultContentMetaNotFound()) } R_END_TRY_CATCH; @@ -50,7 +50,7 @@ namespace ams::ncm { Result GetContentMetaPointer(const void **out_value_ptr, size_t *out_size, const ContentMetaKey &key) const { R_TRY(this->GetContentMetaSize(out_size, key)); - return this->kvs->GetValuePointer(reinterpret_cast(out_value_ptr), key); + return m_kvs->GetValuePointer(reinterpret_cast(out_value_ptr), key); } public: /* Actual commands. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 5338c2e6f..2048935b1 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -167,19 +167,19 @@ namespace ams::ncm { } ContentStorageImpl::ContentIterator::~ContentIterator() { - for (size_t i = 0; i < this->depth; i++) { - fs::CloseDirectory(this->handles[i]); + for (size_t i = 0; i < m_depth; i++) { + fs::CloseDirectory(m_handles[i]); } } Result ContentStorageImpl::ContentIterator::Initialize(const char *root_path, size_t max_depth) { /* Initialize tracking variables. */ - this->depth = 0; - this->max_depth = max_depth; - this->entry_count = 0; + m_depth = 0; + m_max_depth = max_depth; + m_entry_count = 0; /* Create the base content directory path. */ - MakeBaseContentDirectoryPath(std::addressof(this->path), root_path); + MakeBaseContentDirectoryPath(std::addressof(m_path), root_path); /* Open the base directory. */ R_TRY(this->OpenCurrentDirectory()); @@ -192,17 +192,17 @@ namespace ams::ncm { const auto open_mode = hos::GetVersion() >= hos::Version_2_0_0 ? (fs::OpenDirectoryMode_All | fs::OpenDirectoryMode_NotRequireFileSize) : (fs::OpenDirectoryMode_All); /* Open the directory for our current path. */ - R_TRY(fs::OpenDirectory(std::addressof(this->handles[this->depth]), this->path, open_mode)); + R_TRY(fs::OpenDirectory(std::addressof(m_handles[m_depth]), m_path, open_mode)); /* Increase our depth. */ - ++this->depth; + ++m_depth; return ResultSuccess(); } Result ContentStorageImpl::ContentIterator::OpenDirectory(const char *dir) { /* Set our current path. */ - this->path.Set(dir); + m_path.Set(dir); /* Open the directory. */ return this->OpenCurrentDirectory(); @@ -215,22 +215,22 @@ namespace ams::ncm { R_TRY(this->LoadEntries()); /* If we failed to load any entries, there's nothing to get. */ - if (this->entry_count <= 0) { + if (m_entry_count <= 0) { *out = util::nullopt; return ResultSuccess(); } /* Get the next entry. */ - const auto &entry = this->entries[--this->entry_count]; + const auto &entry = m_entries[--m_entry_count]; /* Process the current entry. */ switch (entry.type) { case fs::DirectoryEntryType_Directory: /* If the entry if a directory, we want to recurse into it if we can. */ - if (this->depth < this->max_depth) { + if (m_depth < m_max_depth) { /* Construct the full path for the subdirectory. */ PathString entry_path; - entry_path.SetFormat("%s/%s", this->path.Get(), entry.name); + entry_path.SetFormat("%s/%s", m_path.Get(), entry.name); /* Open the subdirectory. */ R_TRY(this->OpenDirectory(entry_path.Get())); @@ -250,45 +250,45 @@ namespace ams::ncm { Result ContentStorageImpl::ContentIterator::LoadEntries() { /* If we already have entries loaded, we don't need to do anything. */ - R_SUCCEED_IF(this->entry_count != 0); + R_SUCCEED_IF(m_entry_count != 0); /* If we have no directories open, there's nothing for us to load. */ - if (this->depth == 0) { - this->entry_count = 0; + if (m_depth == 0) { + m_entry_count = 0; return ResultSuccess(); } /* Determine the maximum entries that we can load. */ - const s64 max_entries = this->depth == this->max_depth ? MaxDirectoryEntries : 1; + const s64 max_entries = m_depth == m_max_depth ? MaxDirectoryEntries : 1; /* Read entries from the current directory. */ s64 num_entries; - R_TRY(fs::ReadDirectory(std::addressof(num_entries), this->entries, this->handles[this->depth - 1], max_entries)); + R_TRY(fs::ReadDirectory(std::addressof(num_entries), m_entries, m_handles[m_depth - 1], max_entries)); /* If we successfully read entries, load them. */ if (num_entries > 0) { /* Reverse the order of the loaded entries, for our future convenience. */ - for (fs::DirectoryEntry *start_entry = this->entries, *end_entry = this->entries + num_entries - 1; start_entry < end_entry; ++start_entry, --end_entry) { + for (fs::DirectoryEntry *start_entry = m_entries, *end_entry = m_entries + num_entries - 1; start_entry < end_entry; ++start_entry, --end_entry) { std::swap(*start_entry, *end_entry); } /* Set our entry count. */ - this->entry_count = num_entries; + m_entry_count = num_entries; return ResultSuccess(); } /* We didn't read any entries, so we need to advance to the next directory. */ - fs::CloseDirectory(this->handles[--this->depth]); + fs::CloseDirectory(m_handles[--m_depth]); /* Find the index of the parent directory's substring. */ - size_t i = this->path.GetLength() - 1; - while (this->path.Get()[i--] != '/') { + size_t i = m_path.GetLength() - 1; + while (m_path.Get()[i--] != '/') { AMS_ABORT_UNLESS(i > 0); } /* Set the path to the parent directory. */ - this->path.Set(this->path.GetSubstring(0, i + 1)); + m_path.Set(m_path.GetSubstring(0, i + 1)); /* Try to load again from the parent directory. */ return this->LoadEntries(); @@ -349,30 +349,30 @@ namespace ams::ncm { } void ContentStorageImpl::InvalidateFileCache() { - if (this->cached_content_id != InvalidContentId) { - fs::CloseFile(this->cached_file_handle); - this->cached_content_id = InvalidContentId; + if (m_cached_content_id != InvalidContentId) { + fs::CloseFile(m_cached_file_handle); + m_cached_content_id = InvalidContentId; } - this->content_iterator = util::nullopt; + m_content_iterator = util::nullopt; } Result ContentStorageImpl::OpenContentIdFile(ContentId content_id) { /* If the file is the currently cached one, we've nothing to do. */ - R_SUCCEED_IF(this->cached_content_id == content_id); + R_SUCCEED_IF(m_cached_content_id == content_id); /* Close any cached file. */ this->InvalidateFileCache(); /* Create the content path. */ PathString path; - MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(path), content_id, m_make_content_path_func, m_root_path); /* Open the content file and store to the cache. */ - R_TRY_CATCH(fs::OpenFile(std::addressof(this->cached_file_handle), path, fs::OpenMode_Read)) { + R_TRY_CATCH(fs::OpenFile(std::addressof(m_cached_file_handle), path, fs::OpenMode_Read)) { R_CONVERT(ams::fs::ResultPathNotFound, ncm::ResultContentNotFound()) } R_END_TRY_CATCH; - this->cached_content_id = content_id; + m_cached_content_id = content_id; return ResultSuccess(); } @@ -383,10 +383,10 @@ namespace ams::ncm { R_TRY(VerifyBase(path)); /* Initialize members. */ - this->root_path = PathString(path); - this->make_content_path_func = content_path_func; - this->placeholder_accessor.Initialize(std::addressof(this->root_path), placeholder_path_func, delay_flush); - this->rights_id_cache = rights_id_cache; + m_root_path = PathString(path); + m_make_content_path_func = content_path_func; + m_placeholder_accessor.Initialize(std::addressof(m_root_path), placeholder_path_func, delay_flush); + m_rights_id_cache = rights_id_cache; return ResultSuccess(); } @@ -398,13 +398,13 @@ namespace ams::ncm { Result ContentStorageImpl::CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { R_TRY(this->EnsureEnabled()); - R_TRY(EnsureContentDirectory(content_id, this->make_content_path_func, this->root_path)); - return this->placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size); + R_TRY(EnsureContentDirectory(content_id, m_make_content_path_func, m_root_path)); + return m_placeholder_accessor.CreatePlaceHolderFile(placeholder_id, size); } Result ContentStorageImpl::DeletePlaceHolder(PlaceHolderId placeholder_id) { R_TRY(this->EnsureEnabled()); - return this->placeholder_accessor.DeletePlaceHolderFile(placeholder_id); + return m_placeholder_accessor.DeletePlaceHolderFile(placeholder_id); } Result ContentStorageImpl::HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { @@ -412,7 +412,7 @@ namespace ams::ncm { /* Create the placeholder path. */ PathString placeholder_path; - this->placeholder_accessor.MakePath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.MakePath(std::addressof(placeholder_path), placeholder_id); /* Check if placeholder file exists. */ bool has = false; @@ -425,7 +425,7 @@ namespace ams::ncm { /* Ensure offset is valid. */ R_UNLESS(offset >= 0, ncm::ResultInvalidOffset()); R_TRY(this->EnsureEnabled()); - return this->placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize()); + return m_placeholder_accessor.WritePlaceHolderFile(placeholder_id, offset, data.GetPointer(), data.GetSize()); } Result ContentStorageImpl::Register(PlaceHolderId placeholder_id, ContentId content_id) { @@ -434,11 +434,11 @@ namespace ams::ncm { /* Create the placeholder path. */ PathString placeholder_path; - this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); /* Create the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Move the placeholder to the content path. */ R_TRY_CATCH(fs::RenameFile(placeholder_path, content_path)) { @@ -452,7 +452,7 @@ namespace ams::ncm { Result ContentStorageImpl::Delete(ContentId content_id) { R_TRY(this->EnsureEnabled()); this->InvalidateFileCache(); - return DeleteContentFile(content_id, this->make_content_path_func, this->root_path); + return DeleteContentFile(content_id, m_make_content_path_func, m_root_path); } Result ContentStorageImpl::Has(sf::Out out, ContentId content_id) { @@ -460,7 +460,7 @@ namespace ams::ncm { /* Create the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Check if the content file exists. */ bool has = false; @@ -474,7 +474,7 @@ namespace ams::ncm { /* Create the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Substitute our mount name for the common mount name. */ Path common_path; @@ -489,7 +489,7 @@ namespace ams::ncm { /* Obtain the placeholder path. */ PathString placeholder_path; - this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); /* Substitute our mount name for the common mount name. */ Path common_path; @@ -503,11 +503,11 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); /* Clear the cache. */ - this->placeholder_accessor.InvalidateAll(); + m_placeholder_accessor.InvalidateAll(); /* Obtain the placeholder base directory path. */ PathString placeholder_dir; - PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), this->root_path); + PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), m_root_path); /* Cleanup the placeholder base directory. */ CleanDirectoryRecursively(placeholder_dir); @@ -519,13 +519,13 @@ namespace ams::ncm { /* Obtain the placeholder base directory path. */ PathString placeholder_dir; - PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), this->root_path); + PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(placeholder_dir), m_root_path); const size_t max_entries = out_buf.GetSize(); size_t entry_count = 0; /* Traverse the placeholder base directory finding valid placeholder files. */ - R_TRY(TraverseDirectory(placeholder_dir, placeholder_accessor.GetHierarchicalDirectoryDepth(), [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result { + R_TRY(TraverseDirectory(placeholder_dir, m_placeholder_accessor.GetHierarchicalDirectoryDepth(), [&](bool *should_continue, bool *should_retry_dir_read, const char *current_path, const fs::DirectoryEntry &entry) -> Result { AMS_UNUSED(current_path); *should_continue = true; @@ -554,9 +554,9 @@ namespace ams::ncm { /* Obtain the content base directory path. */ PathString path; - MakeBaseContentDirectoryPath(std::addressof(path), this->root_path); + MakeBaseContentDirectoryPath(std::addressof(path), m_root_path); - const auto depth = GetHierarchicalContentDirectoryDepth(this->make_content_path_func); + const auto depth = GetHierarchicalContentDirectoryDepth(m_make_content_path_func); size_t count = 0; /* Traverse the content base directory finding all files. */ @@ -582,16 +582,16 @@ namespace ams::ncm { R_UNLESS(offset >= 0, ncm::ResultInvalidOffset()); R_TRY(this->EnsureEnabled()); - if (!this->content_iterator.has_value() || !this->last_content_offset.has_value() || this->last_content_offset != offset) { + if (!m_content_iterator.has_value() || !m_last_content_offset.has_value() || m_last_content_offset != offset) { /* Create and initialize the content cache. */ - this->content_iterator.emplace(); - R_TRY(this->content_iterator->Initialize(this->root_path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func))); + m_content_iterator.emplace(); + R_TRY(m_content_iterator->Initialize(m_root_path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func))); /* Advance to the desired offset. */ for (auto current_offset = 0; current_offset < offset; /* ... */) { /* Get the next directory entry. */ util::optional dir_entry; - R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry))); + R_TRY(m_content_iterator->GetNext(std::addressof(dir_entry))); /* If we run out of entries before reaching the desired offset, we're done. */ if (!dir_entry) { @@ -611,7 +611,7 @@ namespace ams::ncm { while (count < static_cast(out.GetSize())) { /* Get the next directory entry. */ util::optional dir_entry; - R_TRY(this->content_iterator->GetNext(std::addressof(dir_entry))); + R_TRY(m_content_iterator->GetNext(std::addressof(dir_entry))); /* Don't continue if the directory entry is absent. */ if (!dir_entry) { @@ -624,7 +624,7 @@ namespace ams::ncm { out[count++] = *content_id; /* Update our last content offset. */ - this->last_content_offset = offset + count; + m_last_content_offset = offset + count; } } @@ -639,7 +639,7 @@ namespace ams::ncm { /* Create the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Open the content file. */ fs::FileHandle file; @@ -655,9 +655,9 @@ namespace ams::ncm { } Result ContentStorageImpl::DisableForcibly() { - this->disabled = true; + m_disabled = true; this->InvalidateFileCache(); - this->placeholder_accessor.InvalidateAll(); + m_placeholder_accessor.InvalidateAll(); return ResultSuccess(); } @@ -668,18 +668,18 @@ namespace ams::ncm { this->InvalidateFileCache(); /* Ensure the future content directory exists. */ - R_TRY(EnsureContentDirectory(new_content_id, this->make_content_path_func, this->root_path)); + R_TRY(EnsureContentDirectory(new_content_id, m_make_content_path_func, m_root_path)); /* Ensure the destination placeholder directory exists. */ - R_TRY(this->placeholder_accessor.EnsurePlaceHolderDirectory(placeholder_id)); + R_TRY(m_placeholder_accessor.EnsurePlaceHolderDirectory(placeholder_id)); /* Obtain the placeholder path. */ PathString placeholder_path; - this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); /* Make the old content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), old_content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), old_content_id, m_make_content_path_func, m_root_path); /* Move the content to the placeholder path. */ R_TRY_CATCH(fs::RenameFile(content_path, placeholder_path)) { @@ -692,7 +692,7 @@ namespace ams::ncm { Result ContentStorageImpl::SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { R_TRY(this->EnsureEnabled()); - return this->placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size); + return m_placeholder_accessor.SetPlaceHolderFileSize(placeholder_id, size); } Result ContentStorageImpl::ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) { @@ -702,13 +702,13 @@ namespace ams::ncm { /* Create the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Open the content file. */ R_TRY(this->OpenContentIdFile(content_id)); /* Read from the requested offset up to the requested size. */ - return fs::ReadFile(this->cached_file_handle, offset, buf.GetPointer(), buf.GetSize()); + return fs::ReadFile(m_cached_file_handle, offset, buf.GetPointer(), buf.GetSize()); } Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { @@ -746,7 +746,7 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); /* Attempt to obtain the rights id from the cache. */ - if (this->rights_id_cache->Find(out_rights_id.GetPointer(), content_id)) { + if (m_rights_id_cache->Find(out_rights_id.GetPointer(), content_id)) { return ResultSuccess(); } @@ -759,7 +759,7 @@ namespace ams::ncm { R_TRY(GetRightsId(std::addressof(rights_id), path)); /* Store the rights id to the cache. */ - this->rights_id_cache->Store(content_id, rights_id); + m_rights_id_cache->Store(content_id, rights_id); out_rights_id.SetValue(rights_id); return ResultSuccess(); @@ -778,7 +778,7 @@ namespace ams::ncm { /* Make the content path. */ PathString path; - MakeContentPath(std::addressof(path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(path), content_id, m_make_content_path_func, m_root_path); /* Open the content file. */ fs::FileHandle file; @@ -790,15 +790,15 @@ namespace ams::ncm { } Result ContentStorageImpl::GetFreeSpaceSize(sf::Out out_size) { - return fs::GetFreeSpaceSize(out_size.GetPointer(), this->root_path); + return fs::GetFreeSpaceSize(out_size.GetPointer(), m_root_path); } Result ContentStorageImpl::GetTotalSpaceSize(sf::Out out_size) { - return fs::GetTotalSpaceSize(out_size.GetPointer(), this->root_path); + return fs::GetTotalSpaceSize(out_size.GetPointer(), m_root_path); } Result ContentStorageImpl::FlushPlaceHolder() { - this->placeholder_accessor.InvalidateAll(); + m_placeholder_accessor.InvalidateAll(); return ResultSuccess(); } @@ -808,7 +808,7 @@ namespace ams::ncm { /* Attempt to get the placeholder file size. */ bool found = false; s64 file_size = 0; - R_TRY(this->placeholder_accessor.TryGetPlaceHolderFileSize(std::addressof(found), std::addressof(file_size), placeholder_id)); + R_TRY(m_placeholder_accessor.TryGetPlaceHolderFileSize(std::addressof(found), std::addressof(file_size), placeholder_id)); /* Set the output if placeholder file is found. */ if (found) { @@ -818,7 +818,7 @@ namespace ams::ncm { /* Get the path of the placeholder. */ PathString placeholder_path; - this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); /* Open the placeholder file. */ fs::FileHandle file; @@ -857,19 +857,19 @@ namespace ams::ncm { { path_checker = IsContentPath; PathString path; - MakeBaseContentDirectoryPath(std::addressof(path), this->root_path); + MakeBaseContentDirectoryPath(std::addressof(path), m_root_path); - R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func), fix_file_attributes)); + R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func), fix_file_attributes)); } /* Fix placeholders. */ - this->placeholder_accessor.InvalidateAll(); + m_placeholder_accessor.InvalidateAll(); { path_checker = IsPlaceHolderPath; PathString path; - PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), this->root_path); + PlaceHolderAccessor::MakeBaseDirectoryPath(std::addressof(path), m_root_path); - R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(this->make_content_path_func), fix_file_attributes)); + R_TRY(TraverseDirectory(path, GetHierarchicalContentDirectoryDepth(m_make_content_path_func), fix_file_attributes)); } return ResultSuccess(); @@ -879,13 +879,13 @@ namespace ams::ncm { R_TRY(this->EnsureEnabled()); /* Attempt to find the rights id in the cache. */ - if (this->rights_id_cache->Find(out_rights_id.GetPointer(), cache_content_id)) { + if (m_rights_id_cache->Find(out_rights_id.GetPointer(), cache_content_id)) { return ResultSuccess(); } /* Get the placeholder path. */ PathString placeholder_path; - this->placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); + m_placeholder_accessor.GetPath(std::addressof(placeholder_path), placeholder_id); /* Substitute mount name with the common mount name. */ Path common_path; @@ -894,7 +894,7 @@ namespace ams::ncm { /* Get the rights id. */ ncm::RightsId rights_id; R_TRY(GetRightsId(std::addressof(rights_id), common_path)); - this->rights_id_cache->Store(cache_content_id, rights_id); + m_rights_id_cache->Store(cache_content_id, rights_id); /* Set output. */ out_rights_id.SetValue(rights_id); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp index e41a97a3a..e495acc87 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp @@ -31,12 +31,12 @@ namespace ams::ncm { static constexpr size_t MaxDirectoryEntries = 0x10; public: - fs::DirectoryHandle handles[MaxDirectoryHandles]{}; - size_t depth{}; - size_t max_depth{}; - PathString path{}; - fs::DirectoryEntry entries[MaxDirectoryEntries]{}; - s64 entry_count{}; + fs::DirectoryHandle m_handles[MaxDirectoryHandles]{}; + size_t m_depth{}; + size_t m_max_depth{}; + PathString m_path{}; + fs::DirectoryEntry m_entries[MaxDirectoryEntries]{}; + s64 m_entry_count{}; public: constexpr ContentIterator() = default; ~ContentIterator(); @@ -49,18 +49,18 @@ namespace ams::ncm { Result LoadEntries(); }; protected: - PlaceHolderAccessor placeholder_accessor; - ContentId cached_content_id; - fs::FileHandle cached_file_handle; - RightsIdCache *rights_id_cache; - util::optional content_iterator; - util::optional last_content_offset; + PlaceHolderAccessor m_placeholder_accessor; + ContentId m_cached_content_id; + fs::FileHandle m_cached_file_handle; + RightsIdCache *m_rights_id_cache; + util::optional m_content_iterator; + util::optional m_last_content_offset; public: static Result InitializeBase(const char *root_path); static Result CleanupBase(const char *root_path); static Result VerifyBase(const char *root_path); public: - ContentStorageImpl() : placeholder_accessor(), cached_content_id(InvalidContentId), cached_file_handle(), rights_id_cache(nullptr), content_iterator(util::nullopt), last_content_offset(util::nullopt) { /* ... */ } + ContentStorageImpl() : m_placeholder_accessor(), m_cached_content_id(InvalidContentId), m_cached_file_handle(), m_rights_id_cache(nullptr), m_content_iterator(util::nullopt), m_last_content_offset(util::nullopt) { /* ... */ } ~ContentStorageImpl(); Result Initialize(const char *root_path, MakeContentPathFunction content_path_func, MakePlaceHolderPathFunction placeholder_path_func, bool delay_flush, RightsIdCache *rights_id_cache); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp index 7d66b8e43..bb2e82b67 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp @@ -22,15 +22,15 @@ namespace ams::ncm { NON_COPYABLE(ContentStorageImplBase); NON_MOVEABLE(ContentStorageImplBase); protected: - PathString root_path; - MakeContentPathFunction make_content_path_func; - bool disabled; + PathString m_root_path; + MakeContentPathFunction m_make_content_path_func; + bool m_disabled; protected: - ContentStorageImplBase() : make_content_path_func(), disabled(false) { /* ... */ } + ContentStorageImplBase() : m_make_content_path_func(), m_disabled(false) { /* ... */ } protected: /* Helpers. */ Result EnsureEnabled() const { - R_UNLESS(!this->disabled, ncm::ResultInvalidContentStorage()); + R_UNLESS(!m_disabled, ncm::ResultInvalidContentStorage()); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_fs_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_fs_utils.cpp index d6ee26519..aab8fcf45 100644 --- a/libraries/libstratosphere/source/ncm/ncm_fs_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_fs_utils.cpp @@ -20,21 +20,21 @@ namespace ams::ncm::impl { namespace { - std::atomic g_mount_name_count; + constinit std::atomic g_mount_name_count; } bool PathView::HasPrefix(util::string_view prefix) const { - return this->path.compare(0, prefix.length(), prefix) == 0; + return m_path.compare(0, prefix.length(), prefix) == 0; } bool PathView::HasSuffix(util::string_view suffix) const { - return this->path.compare(this->path.length() - suffix.length(), suffix.length(), suffix) == 0; + return m_path.compare(m_path.length() - suffix.length(), suffix.length(), suffix) == 0; } util::string_view PathView::GetFileName() const { - auto pos = this->path.find_last_of("/"); - return pos != util::string_view::npos ? this->path.substr(pos + 1) : this->path; + auto pos = m_path.find_last_of("/"); + return pos != util::string_view::npos ? m_path.substr(pos + 1) : m_path; } MountName CreateUniqueMountName() { diff --git a/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp b/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp index f0b3906de..6a977fa52 100644 --- a/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp @@ -22,9 +22,9 @@ namespace ams::ncm::impl { class PathView { private: - util::string_view path; + util::string_view m_path; public: - PathView(util::string_view p) : path(p) { /* ...*/ } + PathView(util::string_view p) : m_path(p) { /* ...*/ } bool HasPrefix(util::string_view prefix) const; bool HasSuffix(util::string_view suffix) const; util::string_view GetFileName() const; diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp index 540e69bfd..d2554a502 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp @@ -58,7 +58,7 @@ namespace ams::ncm { /* Attempt to locate the content. */ Path path; - R_TRY_CATCH(this->registered_content->GetPath(std::addressof(path), content_id)) { + R_TRY_CATCH(m_registered_content->GetPath(std::addressof(path), content_id)) { /* The content is absent, this is fine. */ R_CATCH(ncm::ResultContentNotFound) { out.SetValue(false); @@ -72,7 +72,7 @@ namespace ams::ncm { Result HostContentStorageImpl::GetPath(sf::Out out, ContentId content_id) { R_TRY(this->EnsureEnabled()); - return this->registered_content->GetPath(out.GetPointer(), content_id); + return m_registered_content->GetPath(out.GetPointer(), content_id); } Result HostContentStorageImpl::GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { @@ -105,7 +105,7 @@ namespace ams::ncm { } Result HostContentStorageImpl::DisableForcibly() { - this->disabled = true; + m_disabled = true; return ResultSuccess(); } @@ -149,7 +149,7 @@ namespace ams::ncm { /* Get the content path. */ Path path; - R_TRY(this->registered_content->GetPath(std::addressof(path), content_id)); + R_TRY(m_registered_content->GetPath(std::addressof(path), content_id)); /* Acquire the rights id for the content. */ RightsId rights_id; @@ -201,12 +201,12 @@ namespace ams::ncm { Result HostContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) { AMS_ABORT_UNLESS(spl::IsDevelopment()); - return this->registered_content->RegisterPath(content_id, path); + return m_registered_content->RegisterPath(content_id, path); } Result HostContentStorageImpl::ClearRegisteredPath() { AMS_ABORT_UNLESS(spl::IsDevelopment()); - this->registered_content->ClearPaths(); + m_registered_content->ClearPaths(); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp index ab93063dc..757ab540a 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp @@ -20,12 +20,12 @@ namespace ams::ncm { class HostContentStorageImpl { protected: - RegisteredHostContent *registered_content; - bool disabled; + RegisteredHostContent *m_registered_content; + bool m_disabled; protected: /* Helpers. */ Result EnsureEnabled() const { - R_UNLESS(!this->disabled, ncm::ResultInvalidContentStorage()); + R_UNLESS(!m_disabled, ncm::ResultInvalidContentStorage()); return ResultSuccess(); } @@ -39,7 +39,7 @@ namespace ams::ncm { return ResultSuccess(); } public: - HostContentStorageImpl(RegisteredHostContent *registered_content) : registered_content(registered_content), disabled(false) { /* ... */ } + HostContentStorageImpl(RegisteredHostContent *registered_content) : m_registered_content(registered_content), m_disabled(false) { /* ... */ } public: /* Actual commands. */ virtual Result GeneratePlaceHolderId(sf::Out out); diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp index 218e0ddbc..8dccff0a7 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -52,28 +52,28 @@ namespace ams::ncm { } void InstallTaskBase::Cancel() { - std::scoped_lock lk(this->cancel_mutex); - this->cancel_requested = true; + std::scoped_lock lk(m_cancel_mutex); + m_cancel_requested = true; } void InstallTaskBase::ResetCancel() { - std::scoped_lock lk(this->cancel_mutex); - this->cancel_requested = false; + std::scoped_lock lk(m_cancel_mutex); + m_cancel_requested = false; } bool InstallTaskBase::IsCancelRequested() { - std::scoped_lock lk(this->cancel_mutex); - return this->cancel_requested; + std::scoped_lock lk(m_cancel_mutex); + return m_cancel_requested; } Result InstallTaskBase::Initialize(StorageId install_storage, InstallTaskDataBase *data, u32 config) { R_UNLESS(IsInstallableStorage(install_storage), ncm::ResultUnknownStorage()); - this->install_storage = install_storage; - this->data = data; - this->config = config; + m_install_storage = install_storage; + m_data = data; + m_config = config; - return data->GetProgress(std::addressof(this->progress)); + return data->GetProgress(std::addressof(m_progress)); } Result InstallTaskBase::Prepare() { @@ -129,14 +129,14 @@ namespace ams::ncm { Result InstallTaskBase::CalculateRequiredSize(s64 *out_size) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); s64 required_size = 0; /* Iterate over each entry. */ for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); const auto reader = content_meta.GetReader(); /* Sum the sizes from the content infos. */ @@ -178,13 +178,13 @@ namespace ams::ncm { Result InstallTaskBase::Cleanup() { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Iterate over content meta. */ for (s32 i = 0; i < count; i++) { /* Get the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Cleanup the content meta. */ /* N doesn't check the result of this. */ @@ -192,7 +192,7 @@ namespace ams::ncm { } /* Cleanup the data and progress. */ - R_TRY(this->data->Cleanup()); + R_TRY(m_data->Cleanup()); this->CleanupProgress(); return ResultSuccess(); @@ -224,7 +224,7 @@ namespace ams::ncm { Result InstallTaskBase::ListContentMetaKey(s32 *out_keys_written, StorageContentMetaKey *out_keys, s32 out_keys_count, s32 offset, ListContentMetaKeyFilter filter) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Offset exceeds keys that can be written. */ if (count <= offset) { @@ -239,7 +239,7 @@ namespace ams::ncm { for (s32 i = offset; i < num_keys; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Write output StorageContentMetaKey. */ const auto reader = content_meta.GetReader(); @@ -256,7 +256,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader and check if the content has been committed. */ const auto reader = content_meta.GetReader(); @@ -289,7 +289,7 @@ namespace ams::ncm { Result InstallTaskBase::ListApplicationContentMetaKey(s32 *out_keys_written, ApplicationContentMetaKey *out_keys, s32 out_keys_count, s32 offset) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Offset exceeds keys that can be written. */ if (count <= offset) { @@ -303,7 +303,7 @@ namespace ams::ncm { for (s32 i = offset; i < max; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const auto reader = content_meta.GetReader(); @@ -332,16 +332,16 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Iterate over content meta. */ for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Update the data (and check result) when we are done. */ - const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); }; + const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); }; { auto update_guard = SCOPE_GUARD { DoUpdate(); }; @@ -385,7 +385,7 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); s32 num_not_committed = 0; @@ -393,7 +393,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const auto reader = content_meta.GetReader(); @@ -419,7 +419,7 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* List of storages to commit. */ StorageList commit_list; @@ -428,7 +428,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const auto reader = content_meta.GetReader(); @@ -447,7 +447,7 @@ namespace ams::ncm { } /* Helper for performing an update. */ - const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); }; + const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); }; /* Commit the current meta. */ { @@ -522,13 +522,13 @@ namespace ams::ncm { Result InstallTaskBase::IncludesExFatDriver(bool *out) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Iterate over content meta. */ for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Check if the attributes are set for including the exfat driver. */ if (content_meta.GetReader().GetHeader()->attributes & ContentMetaAttribute_IncludesExFatDriver) { @@ -559,26 +559,26 @@ namespace ams::ncm { } /* Update the hash for the new data. */ - this->sha256_generator.Update(data, data_size); + m_sha256_generator.Update(data, data_size); return ResultSuccess(); } Result InstallTaskBase::WritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) { if (content_info->is_sha256_calculated) { /* Update the hash with the buffered data. */ - this->sha256_generator.InitializeWithContext(std::addressof(content_info->context)); - this->sha256_generator.Update(content_info->buffered_data, content_info->buffered_data_size); + m_sha256_generator.InitializeWithContext(std::addressof(content_info->context)); + m_sha256_generator.Update(content_info->buffered_data, content_info->buffered_data_size); } else { /* Initialize the generator. */ - this->sha256_generator.Initialize(); + m_sha256_generator.Initialize(); } { ON_SCOPE_EXIT { /* Update this content info's sha256 data. */ - this->sha256_generator.GetContext(std::addressof(content_info->context)); - content_info->buffered_data_size = this->sha256_generator.GetBufferedDataSize(); - this->sha256_generator.GetBufferedData(content_info->buffered_data, this->sha256_generator.GetBufferedDataSize()); + m_sha256_generator.GetContext(std::addressof(content_info->context)); + content_info->buffered_data_size = m_sha256_generator.GetBufferedDataSize(); + m_sha256_generator.GetBufferedData(content_info->buffered_data, m_sha256_generator.GetBufferedDataSize()); content_info->is_sha256_calculated = true; }; @@ -589,11 +589,11 @@ namespace ams::ncm { /* Compare generated hash to expected hash if verification required. */ if (content_info->verify_digest) { u8 hash[crypto::Sha256Generator::HashSize]; - this->sha256_generator.GetHash(hash, crypto::Sha256Generator::HashSize); + m_sha256_generator.GetHash(hash, crypto::Sha256Generator::HashSize); R_UNLESS(std::memcmp(hash, content_info->digest.data, crypto::Sha256Generator::HashSize) == 0, ncm::ResultInvalidContentHash()); } - if (hos::GetVersion() >= hos::Version_2_0_0 && !(this->config & InstallConfig_IgnoreTicket)) { + if (hos::GetVersion() >= hos::Version_2_0_0 && !(m_config & InstallConfig_IgnoreTicket)) { ncm::RightsId rights_id; { /* Open the content storage and obtain the rights id. */ @@ -630,7 +630,7 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); for (s32 i = 0; i < count; i++) { R_UNLESS(!this->IsCancelRequested(), ncm::ResultCreatePlaceHolderCancelled()); @@ -639,10 +639,10 @@ namespace ams::ncm { std::scoped_lock lk(s_placeholder_mutex); InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Update the data (and check result) when we are done. */ - const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return this->data->Update(content_meta, i); }; + const auto DoUpdate = [&]() ALWAYS_INLINE_LAMBDA { return m_data->Update(content_meta, i); }; { auto update_guard = SCOPE_GUARD { DoUpdate(); }; @@ -768,7 +768,7 @@ namespace ams::ncm { R_TRY(this->GetInstallContentMetaDataFromPath(std::addressof(meta), path, content_info, source_version)); /* Update the storage id if BuiltInSystem. */ - if (this->install_storage == StorageId::BuiltInSystem) { + if (m_install_storage == StorageId::BuiltInSystem) { InstallContentMetaWriter writer(meta.Get(), meta.GetSize()); writer.SetStorageId(StorageId::BuiltInSystem); } @@ -780,7 +780,7 @@ namespace ams::ncm { } /* Push the data. */ - R_TRY(this->data->Push(meta.Get(), meta.GetSize())); + R_TRY(m_data->Push(meta.Get(), meta.GetSize())); /* Don't delete the placeholder if not temporary. */ if (!is_temporary) { @@ -801,7 +801,7 @@ namespace ams::ncm { reader.ConvertToInstallContentMeta(tmp_buffer.Get(), tmp_buffer.GetSize(), InstallContentInfo::Make(ContentInfo::Make(content_id, size, ContentType::Meta), meta_type)); /* Push the content meta. */ - this->data->Push(tmp_buffer.Get(), tmp_buffer.GetSize()); + m_data->Push(tmp_buffer.Get(), tmp_buffer.GetSize()); return ResultSuccess(); } @@ -825,7 +825,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); @@ -846,7 +846,7 @@ namespace ams::ncm { const ContentMetaKey content_meta_info_key = content_meta_info.ToKey(); /* If exfat driver is not included or is required, prepare the content meta. */ - if (!(content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver) || (this->config & InstallConfig_RequiresExFatDriver)) { + if (!(content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver) || (m_config & InstallConfig_RequiresExFatDriver)) { R_TRY(this->PrepareContentMetaIfLatest(content_meta_info_key)); } } @@ -863,7 +863,7 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Iterate over content meta. */ for (s32 i = 0; i < count; i++) { @@ -899,7 +899,7 @@ namespace ams::ncm { } R_END_TRY_CATCH; /* Exfat driver included, but not required. */ - if (content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver && !(this->config & InstallConfig_RequiresExFatDriver)) { + if (content_meta_info.attributes & ContentMetaAttribute_IncludesExFatDriver && !(m_config & InstallConfig_RequiresExFatDriver)) { continue; } @@ -937,7 +937,7 @@ namespace ams::ncm { Result InstallTaskBase::IsNewerThanInstalled(bool *out, const ContentMetaKey &key) { /* Obtain a list of suitable storage ids. */ - auto storage_list = GetStorageList(this->install_storage); + auto storage_list = GetStorageList(m_install_storage); /* Iterate over storage ids. */ for (s32 i = 0; i < storage_list.Count(); i++) { @@ -969,11 +969,11 @@ namespace ams::ncm { } Result InstallTaskBase::CountInstallContentMetaData(s32 *out_count) { - return this->data->Count(out_count); + return m_data->Count(out_count); } Result InstallTaskBase::GetInstallContentMetaData(InstallContentMeta *out_content_meta, s32 index) { - return this->data->Get(out_content_meta, index); + return m_data->Get(out_content_meta, index); } Result InstallTaskBase::DeleteInstallContentMetaData(const ContentMetaKey *keys, s32 num_keys) { @@ -994,7 +994,7 @@ namespace ams::ncm { } /* Delete the data if count < 1. */ - return this->data->Delete(keys, num_keys); + return m_data->Delete(keys, num_keys); } Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional source_version) { @@ -1036,13 +1036,13 @@ namespace ams::ncm { .install_state = InstallState::Prepared, .verify_digest = info.verify_digest, .storage_id = StorageId::BuiltInSystem, - .is_temporary = is_tmp ? *is_tmp : (this->install_storage != StorageId::BuiltInSystem), + .is_temporary = is_tmp ? *is_tmp : (m_install_storage != StorageId::BuiltInSystem), }; } InstallProgress InstallTaskBase::GetProgress() { - std::scoped_lock lk(this->progress_mutex); - return this->progress; + std::scoped_lock lk(m_progress_mutex); + return m_progress; } void InstallTaskBase::ResetLastResult() { @@ -1050,57 +1050,57 @@ namespace ams::ncm { } void InstallTaskBase::SetTotalSize(s64 size) { - std::scoped_lock(this->progress_mutex); - this->progress.total_size = size; + std::scoped_lock lk(m_progress_mutex); + m_progress.total_size = size; } void InstallTaskBase::IncrementProgress(s64 size) { - std::scoped_lock lk(this->progress_mutex); - this->progress.installed_size += size; + std::scoped_lock lk(m_progress_mutex); + m_progress.installed_size += size; } void InstallTaskBase::SetLastResult(Result last_result) { - std::scoped_lock lk(this->progress_mutex); - this->data->SetLastResult(last_result); - this->progress.SetLastResult(last_result); + std::scoped_lock lk(m_progress_mutex); + m_data->SetLastResult(last_result); + m_progress.SetLastResult(last_result); } void InstallTaskBase::CleanupProgress() { - std::scoped_lock(this->progress_mutex); - this->progress = {}; + std::scoped_lock lk(m_progress_mutex); + m_progress = {}; } InstallThroughput InstallTaskBase::GetThroughput() { - std::scoped_lock lk(this->throughput_mutex); - return this->throughput; + std::scoped_lock lk(m_throughput_mutex); + return m_throughput; } void InstallTaskBase::ResetThroughputMeasurement() { - std::scoped_lock lk(this->throughput_mutex); - this->throughput = { .elapsed_time = TimeSpan() }; - this->throughput_start_time = TimeSpan(); + std::scoped_lock lk(m_throughput_mutex); + m_throughput = { .elapsed_time = TimeSpan() }; + m_throughput_start_time = TimeSpan(); } void InstallTaskBase::StartThroughputMeasurement() { - std::scoped_lock lk(this->throughput_mutex); - this->throughput = { .elapsed_time = TimeSpan() }; - this->throughput_start_time = os::GetSystemTick().ToTimeSpan(); + std::scoped_lock lk(m_throughput_mutex); + m_throughput = { .elapsed_time = TimeSpan() }; + m_throughput_start_time = os::GetSystemTick().ToTimeSpan(); } void InstallTaskBase::UpdateThroughputMeasurement(s64 throughput) { - std::scoped_lock lk(this->throughput_mutex); + std::scoped_lock lk(m_throughput_mutex); /* Update throughput only if start time has been set. */ - if (this->throughput_start_time.GetNanoSeconds() != 0) { - this->throughput.installed += throughput; - this->throughput.elapsed_time = os::GetSystemTick().ToTimeSpan() - this->throughput_start_time; + if (m_throughput_start_time.GetNanoSeconds() != 0) { + m_throughput.installed += throughput; + m_throughput.elapsed_time = os::GetSystemTick().ToTimeSpan() - m_throughput_start_time; } } Result InstallTaskBase::CalculateContentsSize(s64 *out_size, const ContentMetaKey &key, StorageId storage_id) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Open the content storage. */ ContentStorage content_storage; @@ -1110,7 +1110,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); @@ -1175,7 +1175,7 @@ namespace ams::ncm { content_storage.GetPlaceHolderPath(std::addressof(path), placeholder_id); /* Read the variation list. */ - R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, this->firmware_variation_id)); + R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, m_firmware_variation_id)); /* Delete the placeholder. */ content_storage.DeletePlaceHolder(placeholder_id); @@ -1185,7 +1185,7 @@ namespace ams::ncm { Result InstallTaskBase::FindMaxRequiredApplicationVersion(u32 *out) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); u32 max_version = 0; @@ -1193,7 +1193,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); @@ -1216,14 +1216,14 @@ namespace ams::ncm { /* Count the number of content meta entries. */ s32 data_count; - R_TRY(this->data->Count(std::addressof(data_count))); + R_TRY(m_data->Count(std::addressof(data_count))); /* Iterate over content meta. */ s32 count = 0; for (s32 i = offset; i < data_count && count < out_list_size; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); @@ -1269,15 +1269,15 @@ namespace ams::ncm { } void InstallTaskBase::SetProgressState(InstallProgressState state) { - std::scoped_lock(this->progress_mutex); - this->data->SetState(state); - this->progress.state = state; + std::scoped_lock lk(m_progress_mutex); + m_data->SetState(state); + m_progress.state = state; } Result InstallTaskBase::FindMaxRequiredSystemVersion(u32 *out) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); u32 max_version = 0; @@ -1285,7 +1285,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); @@ -1330,7 +1330,7 @@ namespace ams::ncm { Result InstallTaskBase::ListRightsIds(s32 *out_count, Span out_span, const ContentMetaKey &key, s32 offset) { /* Count the number of content meta entries. */ s32 count; - R_TRY(this->data->Count(std::addressof(count))); + R_TRY(m_data->Count(std::addressof(count))); /* Ensure count is >= 1. */ R_UNLESS(count >= 1, ncm::ResultContentMetaNotFound()); @@ -1339,7 +1339,7 @@ namespace ams::ncm { for (s32 i = 0; i < count; i++) { /* Obtain the content meta. */ InstallContentMeta content_meta; - R_TRY(this->data->Get(std::addressof(content_meta), i)); + R_TRY(m_data->Get(std::addressof(content_meta), i)); /* Create a reader. */ const InstallContentMetaReader reader = content_meta.GetReader(); diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp index 7f5c9e728..101b89cbe 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_data.cpp @@ -76,13 +76,13 @@ namespace ams::ncm { Result MemoryInstallTaskData::GetProgress(InstallProgress *out_progress) { /* Initialize install progress. */ InstallProgress install_progress = { - .state = this->state, + .state = m_state, }; - install_progress.SetLastResult(this->last_result); + install_progress.SetLastResult(m_last_result); /* Only states after prepared are allowed. */ - if (this->state != InstallProgressState::NotPrepared && this->state != InstallProgressState::DataPrepared) { - for (auto &data_holder : this->data_list) { + if (m_state != InstallProgressState::NotPrepared && m_state != InstallProgressState::DataPrepared) { + for (auto &data_holder : m_data_list) { const InstallContentMetaReader reader = data_holder.GetReader(); /* Sum the sizes from this entry's content infos. */ @@ -99,22 +99,22 @@ namespace ams::ncm { } Result MemoryInstallTaskData::GetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo *out_info) { - *out_info = this->system_update_task_apply_info; + *out_info = m_system_update_task_apply_info; return ResultSuccess(); } Result MemoryInstallTaskData::SetState(InstallProgressState state) { - this->state = state; + m_state = state; return ResultSuccess(); } Result MemoryInstallTaskData::SetLastResult(Result result) { - this->last_result = result; + m_last_result = result; return ResultSuccess(); } Result MemoryInstallTaskData::SetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo info) { - this->system_update_task_apply_info = info; + m_system_update_task_apply_info = info; return ResultSuccess(); } @@ -132,7 +132,7 @@ namespace ams::ncm { std::memcpy(holder->data.get(), data, size); /* Put the data holder into the data list. */ - this->data_list.push_back(*holder); + m_data_list.push_back(*holder); /* Relinquish control over the memory allocated to the data holder. */ holder.release(); @@ -141,14 +141,14 @@ namespace ams::ncm { } Result MemoryInstallTaskData::Count(s32 *out) { - *out = this->data_list.size(); + *out = m_data_list.size(); return ResultSuccess(); } Result MemoryInstallTaskData::GetSize(size_t *out_size, s32 index) { /* Find the correct entry in the list. */ s32 count = 0; - for (auto &data_holder : this->data_list) { + for (auto &data_holder : m_data_list) { if (index == count++) { *out_size = data_holder.size; return ResultSuccess(); @@ -161,7 +161,7 @@ namespace ams::ncm { Result MemoryInstallTaskData::Get(s32 index, void *out, size_t out_size) { /* Find the correct entry in the list. */ s32 count = 0; - for (auto &data_holder : this->data_list) { + for (auto &data_holder : m_data_list) { if (index == count++) { R_UNLESS(out_size >= data_holder.size, ncm::ResultBufferInsufficient()); std::memcpy(out, data_holder.data.get(), data_holder.size); @@ -175,7 +175,7 @@ namespace ams::ncm { Result MemoryInstallTaskData::Update(s32 index, const void *data, size_t data_size) { /* Find the correct entry in the list. */ s32 count = 0; - for (auto &data_holder : this->data_list) { + for (auto &data_holder : m_data_list) { if (index == count++) { R_UNLESS(data_size == data_holder.size, ncm::ResultBufferInsufficient()); std::memcpy(data_holder.data.get(), data, data_size); @@ -191,9 +191,9 @@ namespace ams::ncm { const auto &key = keys[i]; /* Find and remove matching data from the list. */ - for (auto &data_holder : this->data_list) { + for (auto &data_holder : m_data_list) { if (key == data_holder.GetReader().GetKey()) { - this->data_list.erase(this->data_list.iterator_to(data_holder)); + m_data_list.erase(m_data_list.iterator_to(data_holder)); delete std::addressof(data_holder); break; } @@ -204,9 +204,9 @@ namespace ams::ncm { } Result MemoryInstallTaskData::Cleanup() { - while (!this->data_list.empty()) { - auto *data_holder = std::addressof(this->data_list.front()); - this->data_list.pop_front(); + while (!m_data_list.empty()) { + auto *data_holder = std::addressof(m_data_list.front()); + m_data_list.pop_front(); delete data_holder; } return ResultSuccess(); @@ -227,21 +227,21 @@ namespace ams::ncm { } Result FileInstallTaskData::Initialize(const char *path) { - std::strncpy(this->path, path, sizeof(this->path)); - this->path[sizeof(this->path) - 1] = '\x00'; - return this->Read(std::addressof(this->header), sizeof(Header), 0); + std::strncpy(m_path, path, sizeof(m_path)); + m_path[sizeof(m_path) - 1] = '\x00'; + return this->Read(std::addressof(m_header), sizeof(Header), 0); } Result FileInstallTaskData::GetProgress(InstallProgress *out_progress) { /* Initialize install progress. */ InstallProgress install_progress = { - .state = this->header.progress_state, + .state = m_header.progress_state, }; - install_progress.SetLastResult(this->header.last_result); + install_progress.SetLastResult(m_header.last_result); /* Only states after prepared are allowed. */ - if (this->header.progress_state != InstallProgressState::NotPrepared && this->header.progress_state != InstallProgressState::DataPrepared) { - for (size_t i = 0; i < this->header.count; i++) { + if (m_header.progress_state != InstallProgressState::NotPrepared && m_header.progress_state != InstallProgressState::DataPrepared) { + for (size_t i = 0; i < m_header.count; i++) { /* Obtain the content meta for this entry. */ InstallContentMeta content_meta; R_TRY(InstallTaskDataBase::Get(std::addressof(content_meta), i)); @@ -261,47 +261,47 @@ namespace ams::ncm { } Result FileInstallTaskData::GetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo *out_info) { - *out_info = this->header.system_update_task_apply_info; + *out_info = m_header.system_update_task_apply_info; return ResultSuccess(); } Result FileInstallTaskData::SetState(InstallProgressState state) { - this->header.progress_state = state; + m_header.progress_state = state; return this->WriteHeader(); } Result FileInstallTaskData::SetLastResult(Result result) { - this->header.last_result = result; + m_header.last_result = result; return this->WriteHeader(); } Result FileInstallTaskData::SetSystemUpdateTaskApplyInfo(SystemUpdateTaskApplyInfo info) { - this->header.system_update_task_apply_info = info; + m_header.system_update_task_apply_info = info; return this->WriteHeader(); } Result FileInstallTaskData::Push(const void *data, size_t data_size) { - R_UNLESS(this->header.count < this->header.max_entries, ncm::ResultBufferInsufficient()); + R_UNLESS(m_header.count < m_header.max_entries, ncm::ResultBufferInsufficient()); /* Create a new entry info. Data of the given size will be stored at the end of the file. */ - const EntryInfo entry_info = { this->header.last_data_offset, static_cast(data_size) }; + const EntryInfo entry_info = { m_header.last_data_offset, static_cast(data_size) }; /* Write the new entry info. */ - R_TRY(this->Write(std::addressof(entry_info), sizeof(EntryInfo), GetEntryInfoOffset(this->header.count))); + R_TRY(this->Write(std::addressof(entry_info), sizeof(EntryInfo), GetEntryInfoOffset(m_header.count))); /* Write the data to the offset in the entry info. */ R_TRY(this->Write(data, data_size, entry_info.offset)); /* Update the header for the new entry. */ - this->header.last_data_offset += data_size; - this->header.count++; + m_header.last_data_offset += data_size; + m_header.count++; /* Write the updated header. */ return this->WriteHeader(); } Result FileInstallTaskData::Count(s32 *out) { - *out = this->header.count; + *out = m_header.count; return ResultSuccess(); } @@ -334,12 +334,12 @@ namespace ams::ncm { Result FileInstallTaskData::Delete(const ContentMetaKey *keys, s32 num_keys) { /* Create the path for the temporary data. */ - BoundedPath tmp_path(this->path); + BoundedPath tmp_path(m_path); tmp_path.Append(".tmp"); /* Create a new temporary install task data. */ FileInstallTaskData install_task_data; - R_TRY(FileInstallTaskData::Create(tmp_path, this->header.max_entries)); + R_TRY(FileInstallTaskData::Create(tmp_path, m_header.max_entries)); R_TRY(install_task_data.Initialize(tmp_path)); /* Get the number of entries. */ @@ -361,37 +361,37 @@ namespace ams::ncm { } /* Change from our current data to the new data. */ - this->header = install_task_data.header; - R_TRY(fs::DeleteFile(this->path)); - return fs::RenameFile(tmp_path, this->path); + m_header = install_task_data.m_header; + R_TRY(fs::DeleteFile(m_path)); + return fs::RenameFile(tmp_path, m_path); } Result FileInstallTaskData::Cleanup() { - this->header = MakeInitialHeader(this->header.max_entries); + m_header = MakeInitialHeader(m_header.max_entries); return this->WriteHeader(); } Result FileInstallTaskData::GetEntryInfo(EntryInfo *out_entry_info, s32 index) { - AMS_ABORT_UNLESS(static_cast(index) < this->header.count); + AMS_ABORT_UNLESS(static_cast(index) < m_header.count); return this->Read(out_entry_info, sizeof(EntryInfo), GetEntryInfoOffset(index)); } Result FileInstallTaskData::Write(const void *data, size_t size, s64 offset) { fs::FileHandle file; - R_TRY(fs::OpenFile(std::addressof(file), this->path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); + R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); ON_SCOPE_EXIT { fs::CloseFile(file); }; return fs::WriteFile(file, offset, data, size, fs::WriteOption::Flush); } Result FileInstallTaskData::Read(void *out, size_t out_size, s64 offset) { fs::FileHandle file; - R_TRY(fs::OpenFile(std::addressof(file), this->path, fs::OpenMode_Read)); + R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read)); ON_SCOPE_EXIT { fs::CloseFile(file); }; return fs::ReadFile(file, offset, out, out_size); } Result FileInstallTaskData::WriteHeader() { - return this->Write(std::addressof(this->header), sizeof(Header), 0); + return this->Write(std::addressof(m_header), sizeof(Header), 0); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/ncm/ncm_memory_report.cpp b/libraries/libstratosphere/source/ncm/ncm_memory_report.cpp index 802c6e1d7..dfdab9aa2 100644 --- a/libraries/libstratosphere/source/ncm/ncm_memory_report.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_memory_report.cpp @@ -18,29 +18,29 @@ namespace ams::ncm { void HeapState::Initialize(lmem::HeapHandle heap_handle) { - std::scoped_lock lk(this->mutex); - this->heap_handle = heap_handle; + std::scoped_lock lk(m_mutex); + m_heap_handle = heap_handle; } void HeapState::Allocate(size_t size) { - std::scoped_lock lk(this->mutex); - this->total_alloc_size += size; - this->peak_total_alloc_size = std::max(this->total_alloc_size, this->peak_total_alloc_size); - this->peak_alloc_size = std::max(size, this->peak_alloc_size); + std::scoped_lock lk(m_mutex); + m_total_alloc_size += size; + m_peak_total_alloc_size = std::max(m_total_alloc_size, m_peak_total_alloc_size); + m_peak_alloc_size = std::max(size, m_peak_alloc_size); } void HeapState::Free(size_t size) { - std::scoped_lock lk(this->mutex); - this->total_alloc_size -= size; + std::scoped_lock lk(m_mutex); + m_total_alloc_size -= size; } void HeapState::GetMemoryResourceState(MemoryResourceState *out) { *out = {}; - std::scoped_lock lk(this->mutex); - out->peak_total_alloc_size = this->peak_total_alloc_size; - out->peak_alloc_size = this->peak_alloc_size; - out->total_free_size = lmem::GetExpHeapTotalFreeSize(this->heap_handle); - out->allocatable_size = lmem::GetExpHeapAllocatableSize(this->heap_handle, alignof(s32)); + std::scoped_lock lk(m_mutex); + out->peak_total_alloc_size = m_peak_total_alloc_size; + out->peak_alloc_size = m_peak_alloc_size; + out->total_free_size = lmem::GetExpHeapTotalFreeSize(m_heap_handle); + out->allocatable_size = lmem::GetExpHeapAllocatableSize(m_heap_handle, alignof(s32)); } HeapState &GetHeapState() { diff --git a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp index 94459aa98..5ede4b69e 100644 --- a/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_on_memory_content_meta_database_impl.cpp @@ -28,7 +28,7 @@ namespace ams::ncm { size_t entries_written = 0; /* Iterate over all entries. */ - for (auto entry = this->kvs->begin(); entry != this->kvs->end(); entry++) { + for (auto entry = m_kvs->begin(); entry != m_kvs->end(); entry++) { const ContentMetaKey key = entry->GetKey(); /* Check if this entry matches the given filters. */ @@ -70,7 +70,7 @@ namespace ams::ncm { util::optional found_key = util::nullopt; /* Find the last key with the desired program id. */ - for (auto entry = this->kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != this->kvs->end(); entry++) { + for (auto entry = m_kvs->lower_bound(ContentMetaKey::MakeUnknownType(id, 0)); entry != m_kvs->end(); entry++) { /* No further entries will match the program id, discontinue. */ if (entry->GetKey().id != id) { break; diff --git a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp index b4ac9cee6..07d3f998d 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_install_task.cpp @@ -23,7 +23,7 @@ namespace ams::ncm { } Result PackageInstallTask::Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) { - return PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(this->data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None); + return PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, storage_id, std::addressof(m_data), ignore_ticket ? InstallConfig_IgnoreTicket : InstallConfig_None); } Result PackageInstallTask::GetInstallContentMetaInfo(InstallContentMetaInfo *out_info, const ContentMetaKey &key) { diff --git a/libraries/libstratosphere/source/ncm/ncm_package_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_package_install_task_base.cpp index 379ad19ad..e9f875946 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_install_task_base.cpp @@ -19,9 +19,9 @@ namespace ams::ncm { Result PackageInstallTaskBase::Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config) { R_TRY(InstallTaskBase::Initialize(storage_id, data, config)); - this->package_root.Set(package_root_path); - this->buffer = buffer; - this->buffer_size = buffer_size; + m_package_root.Set(package_root_path); + m_buffer = buffer; + m_buffer_size = buffer_size; return ResultSuccess(); } @@ -45,7 +45,7 @@ namespace ams::ncm { while (true) { /* Read as much of the remainder of the file as possible. */ size_t size_read; - R_TRY(fs::ReadFile(std::addressof(size_read), file, content_info->written, this->buffer, this->buffer_size)); + R_TRY(fs::ReadFile(std::addressof(size_read), file, content_info->written, m_buffer, m_buffer_size)); /* There is nothing left to read. */ if (size_read == 0) { @@ -53,7 +53,7 @@ namespace ams::ncm { } /* Write the placeholder. */ - R_TRY(this->WritePlaceHolderBuffer(content_info, this->buffer, size_read)); + R_TRY(this->WritePlaceHolderBuffer(content_info, m_buffer, size_read)); } return ResultSuccess(); @@ -110,25 +110,25 @@ namespace ams::ncm { void PackageInstallTaskBase::CreateContentPath(PackagePath *out_path, ContentId content_id) { char str[ContentIdStringLength + 1] = {}; GetStringFromContentId(str, sizeof(str), content_id); - out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".nca"); + out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".nca"); } void PackageInstallTaskBase::CreateContentMetaPath(PackagePath *out_path, ContentId content_id) { char str[ContentIdStringLength + 1] = {}; GetStringFromContentId(str, sizeof(str), content_id); - out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".cnmt.nca"); + out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".cnmt.nca"); } void PackageInstallTaskBase::CreateTicketPath(PackagePath *out_path, fs::RightsId id) { char str[RightsIdStringLength + 1] = {}; GetStringFromRightsId(str, sizeof(str), id); - out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".tik"); + out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".tik"); } void PackageInstallTaskBase::CreateCertificatePath(PackagePath *out_path, fs::RightsId id) { char str[RightsIdStringLength + 1] = {}; GetStringFromRightsId(str, sizeof(str), id); - out_path->SetFormat("%s%s%s", this->package_root.Get(), str, ".cert"); + out_path->SetFormat("%s%s%s", m_package_root.Get(), str, ".cert"); } } diff --git a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp index 2327c6dec..9b3fb3d62 100644 --- a/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_package_system_update_task.cpp @@ -18,16 +18,16 @@ namespace ams::ncm { PackageSystemUpdateTask::~PackageSystemUpdateTask() { - if (this->context_path.GetLength() > 0) { - fs::DeleteFile(this->context_path); + if (m_context_path.GetLength() > 0) { + fs::DeleteFile(m_context_path); } this->Inactivate(); } void PackageSystemUpdateTask::Inactivate() { - if (this->gamecard_content_meta_database_active) { + if (m_gamecard_content_meta_database_active) { InactivateContentMetaDatabase(StorageId::GameCard); - this->gamecard_content_meta_database_active = false; + m_gamecard_content_meta_database_active = false; } } @@ -37,13 +37,13 @@ namespace ams::ncm { /* Activate the game card content meta database. */ R_TRY(ActivateContentMetaDatabase(StorageId::GameCard)); - this->gamecard_content_meta_database_active = true; + m_gamecard_content_meta_database_active = true; auto meta_db_guard = SCOPE_GUARD { this->Inactivate(); }; /* Open the game card content meta database. */ - OpenContentMetaDatabase(std::addressof(this->package_db), StorageId::GameCard); + OpenContentMetaDatabase(std::addressof(m_package_db), StorageId::GameCard); - ContentMetaDatabaseBuilder builder(std::addressof(this->package_db)); + ContentMetaDatabaseBuilder builder(std::addressof(m_package_db)); /* Cleanup and build the content meta database. */ R_TRY(builder.Cleanup()); @@ -55,18 +55,18 @@ namespace ams::ncm { auto context_guard = SCOPE_GUARD { fs::DeleteFile(context_path); }; /* Initialize data. */ - R_TRY(this->data.Initialize(context_path)); + R_TRY(m_data.Initialize(context_path)); /* Initialize PackageInstallTaskBase. */ u32 config = !requires_exfat_driver ? InstallConfig_SystemUpdate : InstallConfig_SystemUpdate | InstallConfig_RequiresExFatDriver; - R_TRY(PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, StorageId::BuiltInSystem, std::addressof(this->data), config)); + R_TRY(PackageInstallTaskBase::Initialize(package_root, buffer, buffer_size, StorageId::BuiltInSystem, std::addressof(m_data), config)); /* Cancel guards. */ context_guard.Cancel(); meta_db_guard.Cancel(); /* Set the context path. */ - this->context_path.Set(context_path); + m_context_path.Set(context_path); return ResultSuccess(); } @@ -109,7 +109,7 @@ namespace ams::ncm { Result PackageSystemUpdateTask::PrepareInstallContentMetaData() { /* Obtain a SystemUpdate key. */ ContentMetaKey key; - auto list_count = this->package_db.ListContentMeta(std::addressof(key), 1, ContentMetaType::SystemUpdate); + auto list_count = m_package_db.ListContentMeta(std::addressof(key), 1, ContentMetaType::SystemUpdate); R_UNLESS(list_count.written > 0, ncm::ResultSystemUpdateNotFoundInPackage()); /* Get the content info for the key. */ @@ -130,7 +130,7 @@ namespace ams::ncm { /* List content infos. */ s32 count; ContentInfo info; - R_TRY(this->package_db.ListContentInfo(std::addressof(count), std::addressof(info), 1, key, ofs++)); + R_TRY(m_package_db.ListContentInfo(std::addressof(count), std::addressof(info), 1, key, ofs++)); /* No content infos left to list. */ if (count == 0) { diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp index 13be1c60e..5f6eab016 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.cpp @@ -49,7 +49,7 @@ namespace ams::ncm { } void PlaceHolderAccessor::MakePath(PathString *out_placeholder_path, PlaceHolderId placeholder_id) const { - MakePlaceHolderFilePath(out_placeholder_path, placeholder_id, this->make_placeholder_path_func, *this->root_path); + MakePlaceHolderFilePath(out_placeholder_path, placeholder_id, m_make_placeholder_path_func, *m_root_path); } void PlaceHolderAccessor::MakeBaseDirectoryPath(PathString *out, const char *root_path) { @@ -95,7 +95,7 @@ namespace ams::ncm { } bool PlaceHolderAccessor::LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id) { - std::scoped_lock lk(this->cache_mutex); + std::scoped_lock lk(m_cache_mutex); /* Attempt to find an entry in the cache. */ CacheEntry *entry = this->FindInCache(placeholder_id); @@ -110,13 +110,13 @@ namespace ams::ncm { } void PlaceHolderAccessor::StoreToCache(PlaceHolderId placeholder_id, fs::FileHandle handle) { - std::scoped_lock lk(this->cache_mutex); + std::scoped_lock lk(m_cache_mutex); /* Store placeholder id and file handle to a free entry. */ CacheEntry *entry = this->GetFreeEntry(); entry->id = placeholder_id; entry->handle = handle; - entry->counter = this->cur_counter++; + entry->counter = m_cur_counter++; } void PlaceHolderAccessor::Invalidate(CacheEntry *entry) { @@ -136,8 +136,8 @@ namespace ams::ncm { /* Attempt to find a cache entry with the same placeholder id. */ for (size_t i = 0; i < MaxCacheEntries; i++) { - if (placeholder_id == this->caches[i].id) { - return std::addressof(this->caches[i]); + if (placeholder_id == m_caches[i].id) { + return std::addressof(m_caches[i]); } } return nullptr; @@ -146,16 +146,16 @@ namespace ams::ncm { PlaceHolderAccessor::CacheEntry *PlaceHolderAccessor::GetFreeEntry() { /* Try to find an already free entry. */ for (size_t i = 0; i < MaxCacheEntries; i++) { - if (this->caches[i].id == InvalidPlaceHolderId) { - return std::addressof(this->caches[i]); + if (m_caches[i].id == InvalidPlaceHolderId) { + return std::addressof(m_caches[i]); } } /* Get the oldest entry. */ - CacheEntry *entry = std::addressof(this->caches[0]); + CacheEntry *entry = std::addressof(m_caches[0]); for (size_t i = 1; i < MaxCacheEntries; i++) { - if (entry->counter < this->caches[i].counter) { - entry = std::addressof(this->caches[i]); + if (entry->counter < m_caches[i].counter) { + entry = std::addressof(m_caches[i]); } } this->Invalidate(entry); @@ -164,7 +164,7 @@ namespace ams::ncm { void PlaceHolderAccessor::GetPath(PathString *placeholder_path, PlaceHolderId placeholder_id) { { - std::scoped_lock lock(this->cache_mutex); + std::scoped_lock lock(m_cache_mutex); this->Invalidate(this->FindInCache(placeholder_id)); } this->MakePath(placeholder_path, placeholder_id); @@ -210,7 +210,7 @@ namespace ams::ncm { ON_SCOPE_EXIT { this->StoreToCache(placeholder_id, file); }; /* Write data to the placeholder file. */ - return fs::WriteFile(file, offset, buffer, size, this->delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None); + return fs::WriteFile(file, offset, buffer, size, m_delay_flush ? fs::WriteOption::Flush : fs::WriteOption::None); } Result PlaceHolderAccessor::SetPlaceHolderFileSize(PlaceHolderId placeholder_id, s64 size) { @@ -246,7 +246,7 @@ namespace ams::ncm { void PlaceHolderAccessor::InvalidateAll() { /* Invalidate all cache entries. */ - for (auto &entry : this->caches) { + for (auto &entry : m_caches) { if (entry.id != InvalidPlaceHolderId) { this->Invalidate(std::addressof(entry)); } diff --git a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp index e4511b6f3..f0113b86b 100644 --- a/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_placeholder_accessor.hpp @@ -20,21 +20,20 @@ namespace ams::ncm { class PlaceHolderAccessor { private: - class CacheEntry { - public: - PlaceHolderId id; - fs::FileHandle handle; - u64 counter; + struct CacheEntry { + PlaceHolderId id; + fs::FileHandle handle; + u64 counter; }; static constexpr size_t MaxCacheEntries = 0x2; private: - std::array caches; - PathString *root_path; - u64 cur_counter; - os::SdkMutex cache_mutex; - MakePlaceHolderPathFunction make_placeholder_path_func; - bool delay_flush; + std::array m_caches; + PathString *m_root_path; + u64 m_cur_counter; + os::SdkMutex m_cache_mutex; + MakePlaceHolderPathFunction m_make_placeholder_path_func; + bool m_delay_flush; private: Result Open(fs::FileHandle *out_handle, PlaceHolderId placeholder_id); bool LoadFromCache(fs::FileHandle *out_handle, PlaceHolderId placeholder_id); @@ -43,9 +42,9 @@ namespace ams::ncm { CacheEntry *FindInCache(PlaceHolderId placeholder_id); CacheEntry *GetFreeEntry();; public: - PlaceHolderAccessor() : cur_counter(0), cache_mutex(), delay_flush(false) { + PlaceHolderAccessor() : m_cur_counter(0), m_cache_mutex(), m_delay_flush(false) { for (size_t i = 0; i < MaxCacheEntries; i++) { - caches[i].id = InvalidPlaceHolderId; + m_caches[i].id = InvalidPlaceHolderId; } } @@ -56,9 +55,9 @@ namespace ams::ncm { public: /* API. */ void Initialize(PathString *root, MakePlaceHolderPathFunction path_func, bool delay_flush) { - this->root_path = root; - this->make_placeholder_path_func = path_func; - this->delay_flush = delay_flush; + m_root_path = root; + m_make_placeholder_path_func = path_func; + m_delay_flush = delay_flush; } Result CreatePlaceHolderFile(PlaceHolderId placeholder_id, s64 size); @@ -73,7 +72,7 @@ namespace ams::ncm { void InvalidateAll(); Result EnsurePlaceHolderDirectory(PlaceHolderId placeholder_id); - size_t GetHierarchicalDirectoryDepth() const { return GetHierarchicalPlaceHolderDirectoryDepth(this->make_placeholder_path_func); } + size_t GetHierarchicalDirectoryDepth() const { return GetHierarchicalPlaceHolderDirectoryDepth(m_make_placeholder_path_func); } }; } diff --git a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp index abb7704d7..cee0cca32 100644 --- a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp @@ -55,8 +55,8 @@ namespace ams::ncm { Result ReadOnlyContentStorageImpl::Initialize(const char *path, MakeContentPathFunction content_path_func) { R_TRY(this->EnsureEnabled()); - this->root_path.Set(path); - this->make_content_path_func = content_path_func; + m_root_path.Set(path); + m_make_content_path_func = content_path_func; return ResultSuccess(); } @@ -100,7 +100,7 @@ namespace ams::ncm { /* Make the content path. */ PathString content_path; - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Check if the file exists. */ bool has; @@ -108,7 +108,7 @@ namespace ams::ncm { /* If the file is absent, make the path for game card content meta and check presence again. */ if (!has) { - MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeGameCardContentMetaPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); R_TRY(fs::HasFile(std::addressof(has), content_path)); } @@ -121,7 +121,7 @@ namespace ams::ncm { /* Make the path for game card content meta. */ PathString content_path; - MakeGameCardContentMetaPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeGameCardContentMetaPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); /* Check if the file exists. */ bool has_file; @@ -129,7 +129,7 @@ namespace ams::ncm { /* If the file is absent, make the path for regular content. */ if (!has_file) { - MakeContentPath(std::addressof(content_path), content_id, this->make_content_path_func, this->root_path); + MakeContentPath(std::addressof(content_path), content_id, m_make_content_path_func, m_root_path); } /* Substitute mount name with the common mount name. */ @@ -169,7 +169,7 @@ namespace ams::ncm { /* Open the file for the content id. */ fs::FileHandle file; - R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, this->make_content_path_func, this->root_path)); + R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, m_make_content_path_func, m_root_path)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Determine the file size. */ @@ -181,7 +181,7 @@ namespace ams::ncm { } Result ReadOnlyContentStorageImpl::DisableForcibly() { - this->disabled = true; + m_disabled = true; return ResultSuccess(); } @@ -202,7 +202,7 @@ namespace ams::ncm { /* Open the file for the content id. */ fs::FileHandle file; - R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, this->make_content_path_func, this->root_path)); + R_TRY(OpenContentIdFileImpl(std::addressof(file), content_id, m_make_content_path_func, m_root_path)); ON_SCOPE_EXIT { fs::CloseFile(file); }; /* Read from the given offset up to the given size. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_registered_host_content.cpp b/libraries/libstratosphere/source/ncm/ncm_registered_host_content.cpp index 243b15c7a..dcb51fa0f 100644 --- a/libraries/libstratosphere/source/ncm/ncm_registered_host_content.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_registered_host_content.cpp @@ -21,23 +21,23 @@ namespace ams::ncm { NON_COPYABLE(RegisteredPath); NON_MOVEABLE(RegisteredPath); private: - ContentId content_id; - Path path; + ContentId m_content_id; + Path m_path; public: - RegisteredPath(const ncm::ContentId &content_id, const Path &p) : content_id(content_id), path(p) { + RegisteredPath(const ncm::ContentId &content_id, const Path &p) : m_content_id(content_id), m_path(p) { /* ... */ } ncm::ContentId GetContentId() const { - return this->content_id; + return m_content_id; } void GetPath(Path *out) const { - *out = this->path; + *out = m_path; } void SetPath(const Path &path) { - this->path = path; + m_path = path; } }; @@ -46,10 +46,10 @@ namespace ams::ncm { } Result RegisteredHostContent::RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Replace the path of any existing entries. */ - for (auto ®istered_path : this->path_list) { + for (auto ®istered_path : m_path_list) { if (registered_path.GetContentId() == content_id) { registered_path.SetPath(path); return ResultSuccess(); @@ -61,15 +61,15 @@ namespace ams::ncm { R_UNLESS(registered_path != nullptr, ncm::ResultBufferInsufficient()); /* Insert the path into the list. */ - this->path_list.push_back(*registered_path); + m_path_list.push_back(*registered_path); return ResultSuccess(); } Result RegisteredHostContent::GetPath(Path *out, const ncm::ContentId &content_id) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Obtain the path of the content. */ - for (const auto ®istered_path : this->path_list) { + for (const auto ®istered_path : m_path_list) { if (registered_path.GetContentId() == content_id) { registered_path.GetPath(out); return ResultSuccess(); @@ -80,9 +80,9 @@ namespace ams::ncm { void RegisteredHostContent::ClearPaths() { /* Remove all paths. */ - for (auto it = this->path_list.begin(); it != this->path_list.end(); /* ... */) { + for (auto it = m_path_list.begin(); it != m_path_list.end(); /* ... */) { auto *obj = std::addressof(*it); - it = this->path_list.erase(it); + it = m_path_list.erase(it); delete obj; } } diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp index 6cd86bf69..da5d09378 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp @@ -20,11 +20,11 @@ namespace ams::ncm { class RemoteContentMetaDatabaseImpl { private: - ::NcmContentMetaDatabase srv; + ::NcmContentMetaDatabase m_srv; public: - RemoteContentMetaDatabaseImpl(::NcmContentMetaDatabase &db) : srv(db) { /* ... */ } + RemoteContentMetaDatabaseImpl(::NcmContentMetaDatabase &db) : m_srv(db) { /* ... */ } - ~RemoteContentMetaDatabaseImpl() { ::ncmContentMetaDatabaseClose(std::addressof(srv)); } + ~RemoteContentMetaDatabaseImpl() { ::ncmContentMetaDatabaseClose(std::addressof(m_srv)); } private: ALWAYS_INLINE ::NcmContentMetaKey *Convert(ContentMetaKey *k) { static_assert(sizeof(ContentMetaKey) == sizeof(::NcmContentMetaKey)); @@ -72,88 +72,88 @@ namespace ams::ncm { } public: Result Set(const ContentMetaKey &key, const sf::InBuffer &value) { - return ncmContentMetaDatabaseSet(std::addressof(this->srv), Convert(key), value.GetPointer(), value.GetSize()); + return ncmContentMetaDatabaseSet(std::addressof(m_srv), Convert(key), value.GetPointer(), value.GetSize()); } Result Get(sf::Out out_size, const ContentMetaKey &key, const sf::OutBuffer &out_value) { - return ncmContentMetaDatabaseGet(std::addressof(this->srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize()); + return ncmContentMetaDatabaseGet(std::addressof(m_srv), Convert(key), out_size.GetPointer(), out_value.GetPointer(), out_value.GetSize()); } Result Remove(const ContentMetaKey &key) { - return ncmContentMetaDatabaseRemove(std::addressof(this->srv), Convert(key)); + return ncmContentMetaDatabaseRemove(std::addressof(m_srv), Convert(key)); } Result GetContentIdByType(sf::Out out_content_id, const ContentMetaKey &key, ContentType type) { - return ncmContentMetaDatabaseGetContentIdByType(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type)); + return ncmContentMetaDatabaseGetContentIdByType(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type)); } Result ListContentInfo(sf::Out out_entries_written, const sf::OutArray &out_info, const ContentMetaKey &key, s32 offset) { - return ncmContentMetaDatabaseListContentInfo(std::addressof(this->srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); + return ncmContentMetaDatabaseListContentInfo(std::addressof(m_srv), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), Convert(key), offset); } Result List(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_info, ContentMetaType meta_type, ApplicationId application_id, u64 min, u64 max, ContentInstallType install_type) { - return ncmContentMetaDatabaseList(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); + return ncmContentMetaDatabaseList(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_info.GetPointer()), out_info.GetSize(), static_cast<::NcmContentMetaType>(meta_type), application_id.value, min, max, static_cast<::NcmContentInstallType>(install_type)); } Result GetLatestContentMetaKey(sf::Out out_key, u64 id) { - return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(this->srv), Convert(out_key.GetPointer()), static_cast(id)); + return ncmContentMetaDatabaseGetLatestContentMetaKey(std::addressof(m_srv), Convert(out_key.GetPointer()), static_cast(id)); } Result ListApplication(sf::Out out_entries_total, sf::Out out_entries_written, const sf::OutArray &out_keys, ContentMetaType meta_type) { - return ncmContentMetaDatabaseListApplication(std::addressof(this->srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type)); + return ncmContentMetaDatabaseListApplication(std::addressof(m_srv), out_entries_total.GetPointer(), out_entries_written.GetPointer(), Convert(out_keys.GetPointer()), out_keys.GetSize(), static_cast<::NcmContentMetaType>(meta_type)); } Result Has(sf::Out out, const ContentMetaKey &key) { - return ncmContentMetaDatabaseHas(std::addressof(this->srv), out.GetPointer(), Convert(key)); + return ncmContentMetaDatabaseHas(std::addressof(m_srv), out.GetPointer(), Convert(key)); } Result HasAll(sf::Out out, const sf::InArray &keys) { - return ncmContentMetaDatabaseHasAll(std::addressof(this->srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize()); + return ncmContentMetaDatabaseHasAll(std::addressof(m_srv), out.GetPointer(), Convert(keys.GetPointer()), keys.GetSize()); } Result GetSize(sf::Out out_size, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetSize(std::addressof(this->srv), out_size.GetPointer(), Convert(key)); + return ncmContentMetaDatabaseGetSize(std::addressof(m_srv), out_size.GetPointer(), Convert(key)); } Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); + return ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key)); } Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetPatchId(std::addressof(this->srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key)); + return ncmContentMetaDatabaseGetPatchId(std::addressof(m_srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key)); } Result DisableForcibly() { - return ncmContentMetaDatabaseDisableForcibly(std::addressof(this->srv)); + return ncmContentMetaDatabaseDisableForcibly(std::addressof(m_srv)); } Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) { - return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(this->srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize())); + return ncmContentMetaDatabaseLookupOrphanContent(std::addressof(m_srv), out_orphaned.GetPointer(), Convert(content_ids.GetPointer()), std::min(out_orphaned.GetSize(), content_ids.GetSize())); } Result Commit() { - return ncmContentMetaDatabaseCommit(std::addressof(this->srv)); + return ncmContentMetaDatabaseCommit(std::addressof(m_srv)); } Result HasContent(sf::Out out, const ContentMetaKey &key, const ContentId &content_id) { - return ncmContentMetaDatabaseHasContent(std::addressof(this->srv), out.GetPointer(), Convert(key), Convert(content_id)); + return ncmContentMetaDatabaseHasContent(std::addressof(m_srv), out.GetPointer(), Convert(key), Convert(content_id)); } Result ListContentMetaInfo(sf::Out out_entries_written, const sf::OutArray &out_meta_info, const ContentMetaKey &key, s32 offset) { - return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(this->srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset); + return ncmContentMetaDatabaseListContentMetaInfo(std::addressof(m_srv), out_entries_written.GetPointer(), out_meta_info.GetPointer(), out_meta_info.GetSize(), Convert(key), offset); } Result GetAttributes(sf::Out out_attributes, const ContentMetaKey &key) { static_assert(sizeof(ContentMetaAttribute) == sizeof(u8)); - return ncmContentMetaDatabaseGetAttributes(std::addressof(this->srv), Convert(key), out_attributes.GetPointer()); + return ncmContentMetaDatabaseGetAttributes(std::addressof(m_srv), Convert(key), out_attributes.GetPointer()); } Result GetRequiredApplicationVersion(sf::Out out_version, const ContentMetaKey &key) { - return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(this->srv), out_version.GetPointer(), Convert(key)); + return ncmContentMetaDatabaseGetRequiredApplicationVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key)); } Result GetContentIdByTypeAndIdOffset(sf::Out out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) { - return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(this->srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset); + return ncmContentMetaDatabaseGetContentIdByTypeAndIdOffset(std::addressof(m_srv), Convert(out_content_id.GetPointer()), Convert(key), static_cast<::NcmContentType>(type), id_offset); } Result GetCount(sf::Out out_count) { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp index 9ebab0374..2e70fb189 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp @@ -20,11 +20,11 @@ namespace ams::ncm { class RemoteContentStorageImpl { private: - ::NcmContentStorage srv; + ::NcmContentStorage m_srv; public: - RemoteContentStorageImpl(::NcmContentStorage &cs) : srv(cs) { /* ... */ } + RemoteContentStorageImpl(::NcmContentStorage &cs) : m_srv(cs) { /* ... */ } - ~RemoteContentStorageImpl() { ::ncmContentStorageClose(std::addressof(srv)); } + ~RemoteContentStorageImpl() { ::ncmContentStorageClose(std::addressof(m_srv)); } private: ALWAYS_INLINE ::NcmPlaceHolderId *Convert(PlaceHolderId *p) { static_assert(sizeof(PlaceHolderId) == sizeof(::NcmPlaceHolderId)); @@ -57,86 +57,86 @@ namespace ams::ncm { } public: Result GeneratePlaceHolderId(sf::Out out) { - return ncmContentStorageGeneratePlaceHolderId(std::addressof(this->srv), Convert(out.GetPointer())); + return ncmContentStorageGeneratePlaceHolderId(std::addressof(m_srv), Convert(out.GetPointer())); } Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); - return ncmContentStorageCreatePlaceHolder(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id), size); + return ncmContentStorageCreatePlaceHolder(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id), size); } Result DeletePlaceHolder(PlaceHolderId placeholder_id) { - return ncmContentStorageDeletePlaceHolder(std::addressof(this->srv), Convert(placeholder_id)); + return ncmContentStorageDeletePlaceHolder(std::addressof(m_srv), Convert(placeholder_id)); } Result HasPlaceHolder(sf::Out out, PlaceHolderId placeholder_id) { - return ncmContentStorageHasPlaceHolder(std::addressof(this->srv), out.GetPointer(), Convert(placeholder_id)); + return ncmContentStorageHasPlaceHolder(std::addressof(m_srv), out.GetPointer(), Convert(placeholder_id)); } Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data) { - return ncmContentStorageWritePlaceHolder(std::addressof(this->srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize()); + return ncmContentStorageWritePlaceHolder(std::addressof(m_srv), Convert(placeholder_id), offset, data.GetPointer(), data.GetSize()); } Result Register(PlaceHolderId placeholder_id, ContentId content_id) { static_assert(alignof(ContentId) < alignof(PlaceHolderId)); - return ncmContentStorageRegister(std::addressof(this->srv), Convert(content_id), Convert(placeholder_id)); + return ncmContentStorageRegister(std::addressof(m_srv), Convert(content_id), Convert(placeholder_id)); } Result Delete(ContentId content_id) { - return ncmContentStorageDelete(std::addressof(this->srv), Convert(content_id)); + return ncmContentStorageDelete(std::addressof(m_srv), Convert(content_id)); } Result Has(sf::Out out, ContentId content_id) { - return ncmContentStorageHas(std::addressof(this->srv), out.GetPointer(), Convert(content_id)); + return ncmContentStorageHas(std::addressof(m_srv), out.GetPointer(), Convert(content_id)); } Result GetPath(sf::Out out, ContentId content_id) { - return ncmContentStorageGetPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id)); + return ncmContentStorageGetPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(content_id)); } Result GetPlaceHolderPath(sf::Out out, PlaceHolderId placeholder_id) { - return ncmContentStorageGetPlaceHolderPath(std::addressof(this->srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id)); + return ncmContentStorageGetPlaceHolderPath(std::addressof(m_srv), out.GetPointer()->str, sizeof(out.GetPointer()->str), Convert(placeholder_id)); } Result CleanupAllPlaceHolder() { - return ncmContentStorageCleanupAllPlaceHolder(std::addressof(this->srv)); + return ncmContentStorageCleanupAllPlaceHolder(std::addressof(m_srv)); } Result ListPlaceHolder(sf::Out out_count, const sf::OutArray &out_buf) { - return ncmContentStorageListPlaceHolder(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer()); + return ncmContentStorageListPlaceHolder(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer()); } Result GetContentCount(sf::Out out_count) { - return ncmContentStorageGetContentCount(std::addressof(this->srv), out_count.GetPointer()); + return ncmContentStorageGetContentCount(std::addressof(m_srv), out_count.GetPointer()); } Result ListContentId(sf::Out out_count, const sf::OutArray &out_buf, s32 offset) { - return ncmContentStorageListContentId(std::addressof(this->srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset); + return ncmContentStorageListContentId(std::addressof(m_srv), Convert(out_buf.GetPointer()), out_buf.GetSize(), out_count.GetPointer(), offset); } Result GetSizeFromContentId(sf::Out out_size, ContentId content_id) { - return ncmContentStorageGetSizeFromContentId(std::addressof(this->srv), out_size.GetPointer(), Convert(content_id)); + return ncmContentStorageGetSizeFromContentId(std::addressof(m_srv), out_size.GetPointer(), Convert(content_id)); } Result DisableForcibly() { - return ncmContentStorageDisableForcibly(std::addressof(this->srv)); + return ncmContentStorageDisableForcibly(std::addressof(m_srv)); } Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { - return ncmContentStorageRevertToPlaceHolder(std::addressof(this->srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id)); + return ncmContentStorageRevertToPlaceHolder(std::addressof(m_srv), Convert(placeholder_id), Convert(old_content_id), Convert(new_content_id)); } Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { - return ncmContentStorageSetPlaceHolderSize(std::addressof(this->srv), Convert(placeholder_id), size); + return ncmContentStorageSetPlaceHolderSize(std::addressof(m_srv), Convert(placeholder_id), size); } Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) { - return ncmContentStorageReadContentIdFile(std::addressof(this->srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset); + return ncmContentStorageReadContentIdFile(std::addressof(m_srv), buf.GetPointer(), buf.GetSize(), Convert(content_id), offset); } Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); + R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -145,7 +145,7 @@ namespace ams::ncm { Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(this->srv), std::addressof(rights_id), Convert(placeholder_id))); + R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -154,7 +154,7 @@ namespace ams::ncm { Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); + R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -163,7 +163,7 @@ namespace ams::ncm { Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(this->srv), std::addressof(rights_id), Convert(content_id))); + R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -171,41 +171,41 @@ namespace ams::ncm { } Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) { - return ncmContentStorageWriteContentForDebug(std::addressof(this->srv), Convert(content_id), offset, data.GetPointer(), data.GetSize()); + return ncmContentStorageWriteContentForDebug(std::addressof(m_srv), Convert(content_id), offset, data.GetPointer(), data.GetSize()); } Result GetFreeSpaceSize(sf::Out out_size) { - return ncmContentStorageGetFreeSpaceSize(std::addressof(this->srv), out_size.GetPointer()); + return ncmContentStorageGetFreeSpaceSize(std::addressof(m_srv), out_size.GetPointer()); } Result GetTotalSpaceSize(sf::Out out_size) { - return ncmContentStorageGetTotalSpaceSize(std::addressof(this->srv), out_size.GetPointer()); + return ncmContentStorageGetTotalSpaceSize(std::addressof(m_srv), out_size.GetPointer()); } Result FlushPlaceHolder() { - return ncmContentStorageFlushPlaceHolder(std::addressof(this->srv)); + return ncmContentStorageFlushPlaceHolder(std::addressof(m_srv)); } Result GetSizeFromPlaceHolderId(sf::Out out_size, PlaceHolderId placeholder_id) { - return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(this->srv), out_size.GetPointer(), Convert(placeholder_id)); + return ncmContentStorageGetSizeFromPlaceHolderId(std::addressof(m_srv), out_size.GetPointer(), Convert(placeholder_id)); } Result RepairInvalidFileAttribute() { - return ncmContentStorageRepairInvalidFileAttribute(std::addressof(this->srv)); + return ncmContentStorageRepairInvalidFileAttribute(std::addressof(m_srv)); } Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId)); ::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer()); - return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(this->srv), out, Convert(placeholder_id), Convert(cache_content_id)); + return ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id)); } Result RegisterPath(const ContentId &content_id, const Path &path) { - return ncmContentStorageRegisterPath(std::addressof(this->srv), Convert(content_id), path.str); + return ncmContentStorageRegisterPath(std::addressof(m_srv), Convert(content_id), path.str); } Result ClearRegisteredPath() { - return ncmContentStorageClearRegisteredPath(std::addressof(this->srv)); + return ncmContentStorageClearRegisteredPath(std::addressof(m_srv)); } }; static_assert(ncm::IsIContentStorage); diff --git a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp index bb70543c0..cb3bb4624 100644 --- a/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_submission_package_install_task.cpp @@ -20,38 +20,38 @@ namespace ams::ncm { class SubmissionPackageInstallTask::Impl { private: - fs::FileHandleStorage storage; - util::optional mount_name; + fs::FileHandleStorage m_storage; + util::optional m_mount_name; public: - explicit Impl(fs::FileHandle file) : storage(file), mount_name(util::nullopt) { /* ... */ } + explicit Impl(fs::FileHandle file) : m_storage(file), m_mount_name(util::nullopt) { /* ... */ } ~Impl() { - if (this->mount_name) { - fs::fsa::Unregister(this->mount_name->str); + if (m_mount_name) { + fs::fsa::Unregister(m_mount_name->str); } } Result Initialize() { - AMS_ASSERT(!this->mount_name); + AMS_ASSERT(!m_mount_name); /* Allocate a partition file system. */ auto partition_file_system = std::make_unique(); R_UNLESS(partition_file_system != nullptr, ncm::ResultAllocationFailed()); /* Initialize the partition file system. */ - R_TRY(partition_file_system->Initialize(std::addressof(this->storage))); + R_TRY(partition_file_system->Initialize(std::addressof(m_storage))); /* Create a mount name and register the file system. */ auto mount_name = impl::CreateUniqueMountName(); R_TRY(fs::fsa::Register(mount_name.str, std::move(partition_file_system))); /* Initialize members. */ - this->mount_name = mount_name; + m_mount_name = mount_name; return ResultSuccess(); } const impl::MountName &GetMountName() const { - return *this->mount_name; + return *m_mount_name; } }; @@ -59,17 +59,17 @@ namespace ams::ncm { SubmissionPackageInstallTask::~SubmissionPackageInstallTask() { /* ... */ } Result SubmissionPackageInstallTask::Initialize(fs::FileHandle file, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket) { - AMS_ASSERT(!this->impl); + AMS_ASSERT(!m_impl); /* Allocate impl. */ - this->impl.reset(new (std::nothrow) Impl(file)); - R_UNLESS(this->impl != nullptr, ncm::ResultAllocationFailed()); + m_impl.reset(new (std::nothrow) Impl(file)); + R_UNLESS(m_impl != nullptr, ncm::ResultAllocationFailed()); /* Initialize impl. */ - R_TRY(this->impl->Initialize()); + R_TRY(m_impl->Initialize()); /* Initialize parent. N doesn't check the result. */ - PackageInstallTask::Initialize(impl::GetRootDirectoryPath(this->impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket); + PackageInstallTask::Initialize(impl::GetRootDirectoryPath(m_impl->GetMountName()).str, storage_id, buffer, buffer_size, ignore_ticket); return ResultSuccess(); } diff --git a/libraries/libstratosphere/source/nsd/impl/device/nsd_device.cpp b/libraries/libstratosphere/source/nsd/impl/device/nsd_device.cpp index e97c59112..bcb62d1dc 100644 --- a/libraries/libstratosphere/source/nsd/impl/device/nsd_device.cpp +++ b/libraries/libstratosphere/source/nsd/impl/device/nsd_device.cpp @@ -29,18 +29,20 @@ namespace ams::nsd::impl::device { } const EnvironmentIdentifier &GetEnvironmentIdentifierFromSettings() { - std::scoped_lock lk(g_environment_identifier_lock); + if (AMS_UNLIKELY(!g_determined_environment_identifier)) { + std::scoped_lock lk(g_environment_identifier_lock); - if (!g_determined_environment_identifier) { - /* Check size. */ - AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValueSize(SettingsName, SettingsKey) != 0); + if (AMS_LIKELY(!g_determined_environment_identifier)) { + /* Check size. */ + AMS_ABORT_UNLESS(settings::fwdbg::GetSettingsItemValueSize(SettingsName, SettingsKey) != 0); - /* Get value. */ - const size_t size = settings::fwdbg::GetSettingsItemValue(g_environment_identifier.value, EnvironmentIdentifier::Size, SettingsName, SettingsKey); - AMS_ABORT_UNLESS(size < EnvironmentIdentifier::Size); - AMS_ABORT_UNLESS(g_environment_identifier == EnvironmentIdentifierOfProductDevice || g_environment_identifier == EnvironmentIdentifierOfNotProductDevice); + /* Get value. */ + const size_t size = settings::fwdbg::GetSettingsItemValue(g_environment_identifier.value, EnvironmentIdentifier::Size, SettingsName, SettingsKey); + AMS_ABORT_UNLESS(size < EnvironmentIdentifier::Size); + AMS_ABORT_UNLESS(g_environment_identifier == EnvironmentIdentifierOfProductDevice || g_environment_identifier == EnvironmentIdentifierOfNotProductDevice); - g_determined_environment_identifier = true; + g_determined_environment_identifier = true; + } } return g_environment_identifier; diff --git a/libraries/libstratosphere/source/os/impl/os_internal_condition_variable_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_internal_condition_variable_impl.os.horizon.cpp index 6b81d0183..129b391de 100644 --- a/libraries/libstratosphere/source/os/impl/os_internal_condition_variable_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_internal_condition_variable_impl.os.horizon.cpp @@ -20,27 +20,27 @@ namespace ams::os::impl { void InternalConditionVariableImpl::Signal() { - ams::svc::SignalProcessWideKey(reinterpret_cast(std::addressof(this->value)), 1); + ams::svc::SignalProcessWideKey(reinterpret_cast(std::addressof(m_value)), 1); } void InternalConditionVariableImpl::Broadcast() { - ams::svc::SignalProcessWideKey(reinterpret_cast(std::addressof(this->value)), -1); + ams::svc::SignalProcessWideKey(reinterpret_cast(std::addressof(m_value)), -1); } void InternalConditionVariableImpl::Wait(InternalCriticalSection *cs) { const auto cur_handle = GetCurrentThreadHandle(); - AMS_ASSERT((cs->Get()->thread_handle & ~ams::svc::HandleWaitMask) == cur_handle); + AMS_ASSERT((cs->Get()->m_thread_handle & ~ams::svc::HandleWaitMask) == cur_handle); - R_ABORT_UNLESS(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast(std::addressof(cs->Get()->thread_handle)), reinterpret_cast(std::addressof(this->value)), cur_handle, -1)); + R_ABORT_UNLESS(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast(std::addressof(cs->Get()->m_thread_handle)), reinterpret_cast(std::addressof(m_value)), cur_handle, -1)); } ConditionVariableStatus InternalConditionVariableImpl::TimedWait(InternalCriticalSection *cs, const TimeoutHelper &timeout_helper) { const auto cur_handle = GetCurrentThreadHandle(); - AMS_ASSERT((cs->Get()->thread_handle & ~ams::svc::HandleWaitMask) == cur_handle); + AMS_ASSERT((cs->Get()->m_thread_handle & ~ams::svc::HandleWaitMask) == cur_handle); const TimeSpan left = timeout_helper.GetTimeLeftOnTarget(); if (left > 0) { - R_TRY_CATCH(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast(std::addressof(cs->Get()->thread_handle)), reinterpret_cast(std::addressof(this->value)), cur_handle, left.GetNanoSeconds())) { + R_TRY_CATCH(ams::svc::WaitProcessWideKeyAtomic(reinterpret_cast(std::addressof(cs->Get()->m_thread_handle)), reinterpret_cast(std::addressof(m_value)), cur_handle, left.GetNanoSeconds())) { R_CATCH(svc::ResultTimedOut) { cs->Enter(); return ConditionVariableStatus::TimedOut; diff --git a/libraries/libstratosphere/source/os/impl/os_internal_critical_section_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_internal_critical_section_impl.os.horizon.cpp index 3c9f52cae..dfda7b076 100644 --- a/libraries/libstratosphere/source/os/impl/os_internal_critical_section_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_internal_critical_section_impl.os.horizon.cpp @@ -25,30 +25,30 @@ namespace ams::os::impl { AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0); /* Use the libnx impl. */ - static_assert(std::is_samethread_handle), ::Mutex>::value); - return ::mutexLock(std::addressof(this->thread_handle)); + static_assert(std::is_same::value); + return ::mutexLock(std::addressof(m_thread_handle)); } bool InternalCriticalSectionImpl::TryEnter() { AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0); /* Use the libnx impl. */ - static_assert(std::is_samethread_handle), ::Mutex>::value); - return ::mutexTryLock(std::addressof(this->thread_handle)); + static_assert(std::is_same::value); + return ::mutexTryLock(std::addressof(m_thread_handle)); } void InternalCriticalSectionImpl::Leave() { AMS_ASSERT(svc::GetThreadLocalRegion()->disable_count == 0); /* Use the libnx impl. */ - static_assert(std::is_samethread_handle), ::Mutex>::value); - return ::mutexUnlock(std::addressof(this->thread_handle)); + static_assert(std::is_same::value); + return ::mutexUnlock(std::addressof(m_thread_handle)); } bool InternalCriticalSectionImpl::IsLockedByCurrentThread() const { /* Use the libnx impl. */ - static_assert(std::is_samethread_handle), ::Mutex>::value); - return ::mutexIsLockedByCurrentThread(std::addressof(this->thread_handle)); + static_assert(std::is_same::value); + return ::mutexIsLockedByCurrentThread(std::addressof(m_thread_handle)); } #else diff --git a/libraries/libstratosphere/source/os/impl/os_interrupt_event_impl.hpp b/libraries/libstratosphere/source/os/impl/os_interrupt_event_impl.hpp index a539cae46..e4dccfe5c 100644 --- a/libraries/libstratosphere/source/os/impl/os_interrupt_event_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_interrupt_event_impl.hpp @@ -26,32 +26,32 @@ namespace ams::os::impl { class InterruptEventImpl { private: - InterruptEventTargetImpl impl; + InterruptEventTargetImpl m_impl; public: - explicit InterruptEventImpl(InterruptName name, EventClearMode clear_mode) : impl(name, clear_mode) { /* ... */ } + explicit InterruptEventImpl(InterruptName name, EventClearMode clear_mode) : m_impl(name, clear_mode) { /* ... */ } void Clear() { - return this->impl.Clear(); + return m_impl.Clear(); } void Wait() { - return this->impl.Wait(); + return m_impl.Wait(); } bool TryWait() { - return this->impl.TryWait(); + return m_impl.TryWait(); } bool TimedWait(TimeSpan timeout) { - return this->impl.TimedWait(timeout); + return m_impl.TimedWait(timeout); } TriBool IsSignaled() { - return this->impl.IsSignaled(); + return m_impl.IsSignaled(); } NativeHandle GetHandle() const { - return this->impl.GetHandle(); + return m_impl.GetHandle(); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.cpp index 5a63cbfcb..80ed60dbe 100644 --- a/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.cpp @@ -20,32 +20,32 @@ namespace ams::os::impl { InterruptEventHorizonImpl::InterruptEventHorizonImpl(InterruptName name, EventClearMode clear_mode) { - this->manual_clear = (clear_mode == EventClearMode_ManualClear); + m_manual_clear = (clear_mode == EventClearMode_ManualClear); - auto interrupt_type = this->manual_clear ? svc::InterruptType_Level : svc::InterruptType_Edge; + auto interrupt_type = m_manual_clear ? svc::InterruptType_Level : svc::InterruptType_Edge; svc::Handle handle; R_ABORT_UNLESS(svc::CreateInterruptEvent(std::addressof(handle), static_cast(name), interrupt_type)); - this->handle = handle; + m_handle = handle; } InterruptEventHorizonImpl::~InterruptEventHorizonImpl() { - R_ABORT_UNLESS(svc::CloseHandle(this->handle)); + R_ABORT_UNLESS(svc::CloseHandle(m_handle)); } void InterruptEventHorizonImpl::Clear() { - R_ABORT_UNLESS(svc::ClearEvent(this->handle)); + R_ABORT_UNLESS(svc::ClearEvent(m_handle)); } void InterruptEventHorizonImpl::Wait() { while (true) { /* Continuously wait, until success. */ s32 index; - Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, svc::WaitInfinite); + Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, svc::WaitInfinite); if (R_SUCCEEDED(res)) { /* Clear, if we must. */ - if (!this->manual_clear) { - R_TRY_CATCH(svc::ResetSignal(this->handle)) { + if (!m_manual_clear) { + R_TRY_CATCH(svc::ResetSignal(m_handle)) { /* Some other thread might have caught this before we did. */ R_CATCH(svc::ResultInvalidState) { continue; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS; @@ -60,15 +60,15 @@ namespace ams::os::impl { bool InterruptEventHorizonImpl::TryWait() { /* If we're auto clear, just try to reset. */ - if (!this->manual_clear) { - return R_SUCCEEDED(svc::ResetSignal(this->handle)); + if (!m_manual_clear) { + return R_SUCCEEDED(svc::ResetSignal(m_handle)); } /* Not auto-clear. */ while (true) { /* Continuously wait, until success or timeout. */ s32 index; - Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, 0); + Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, 0); /* If we succeeded, we're signaled. */ if (R_SUCCEEDED(res)) { @@ -90,11 +90,11 @@ namespace ams::os::impl { while (true) { /* Continuously wait, until success. */ s32 index; - Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(this->handle), 1, timeout_helper.GetTimeLeftOnTarget().GetNanoSeconds()); + Result res = svc::WaitSynchronization(std::addressof(index), std::addressof(m_handle), 1, timeout_helper.GetTimeLeftOnTarget().GetNanoSeconds()); if (R_SUCCEEDED(res)) { /* Clear, if we must. */ - if (!this->manual_clear) { - R_TRY_CATCH(svc::ResetSignal(this->handle)) { + if (!m_manual_clear) { + R_TRY_CATCH(svc::ResetSignal(m_handle)) { /* Some other thread might have caught this before we did. */ R_CATCH(svc::ResultInvalidState) { continue; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS; diff --git a/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.hpp index 5c3bab24e..672ed9108 100644 --- a/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_interrupt_event_target_impl.os.horizon.hpp @@ -20,8 +20,8 @@ namespace ams::os::impl { class InterruptEventHorizonImpl { private: - svc::Handle handle; - bool manual_clear; + svc::Handle m_handle; + bool m_manual_clear; public: explicit InterruptEventHorizonImpl(InterruptName name, EventClearMode mode); ~InterruptEventHorizonImpl(); @@ -36,7 +36,7 @@ namespace ams::os::impl { } NativeHandle GetHandle() const { - return this->handle; + return m_handle; } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_base.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_base.hpp index 6ec8c017f..1e3df3d9c 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_base.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_base.hpp @@ -23,10 +23,10 @@ namespace ams::os::impl { class MultiWaitHolderBase { private: - MultiWaitImpl *multi_wait = nullptr; + MultiWaitImpl *m_multi_wait = nullptr; public: - util::IntrusiveListNode multi_wait_node; - util::IntrusiveListNode object_list_node; + util::IntrusiveListNode m_multi_wait_node; + util::IntrusiveListNode m_object_list_node; public: /* Gets whether the held object is currently signaled. */ virtual TriBool IsSignaled() const = 0; @@ -43,15 +43,15 @@ namespace ams::os::impl { /* Interface with multi wait. */ void SetMultiWait(MultiWaitImpl *m) { - this->multi_wait = m; + m_multi_wait = m; } MultiWaitImpl *GetMultiWait() const { - return this->multi_wait; + return m_multi_wait; } bool IsLinked() const { - return this->multi_wait != nullptr; + return m_multi_wait != nullptr; } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_event.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_event.hpp index 89b491869..584453c56 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_event.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_event.hpp @@ -21,31 +21,31 @@ namespace ams::os::impl { class MultiWaitHolderOfEvent : public MultiWaitHolderOfUserObject { private: - EventType *event; + EventType *m_event; private: TriBool IsSignaledImpl() const { - return this->event->signaled ? TriBool::True : TriBool::False; + return m_event->signaled ? TriBool::True : TriBool::False; } public: - explicit MultiWaitHolderOfEvent(EventType *e) : event(e) { /* ... */ } + explicit MultiWaitHolderOfEvent(EventType *e) : m_event(e) { /* ... */ } /* IsSignaled, Link, Unlink implemented. */ virtual TriBool IsSignaled() const override { - std::scoped_lock lk(GetReference(this->event->cs_event)); + std::scoped_lock lk(GetReference(m_event->cs_event)); return this->IsSignaledImpl(); } virtual TriBool LinkToObjectList() override { - std::scoped_lock lk(GetReference(this->event->cs_event)); + std::scoped_lock lk(GetReference(m_event->cs_event)); - GetReference(this->event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this); + GetReference(m_event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this); return this->IsSignaledImpl(); } virtual void UnlinkFromObjectList() override { - std::scoped_lock lk(GetReference(this->event->cs_event)); + std::scoped_lock lk(GetReference(m_event->cs_event)); - GetReference(this->event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this); + GetReference(m_event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_handle.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_handle.hpp index 3c38560a8..2765392c1 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_handle.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_handle.hpp @@ -20,9 +20,9 @@ namespace ams::os::impl { class MultiWaitHolderOfHandle : public MultiWaitHolderOfKernelObject { private: - NativeHandle handle; + NativeHandle m_handle; public: - explicit MultiWaitHolderOfHandle(NativeHandle h) : handle(h) { /* ... */ } + explicit MultiWaitHolderOfHandle(NativeHandle h) : m_handle(h) { /* ... */ } /* IsSignaled, GetHandle both implemented. */ virtual TriBool IsSignaled() const override { @@ -30,7 +30,7 @@ namespace ams::os::impl { } virtual NativeHandle GetHandle() const override { - return this->handle; + return m_handle; } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_inter_process_event.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_inter_process_event.hpp index ff6980b65..945c0f4b1 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_inter_process_event.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_inter_process_event.hpp @@ -21,9 +21,9 @@ namespace ams::os::impl { class MultiWaitHolderOfInterProcessEvent : public MultiWaitHolderOfKernelObject { private: - InterProcessEventType *event; + InterProcessEventType *m_event; public: - explicit MultiWaitHolderOfInterProcessEvent(InterProcessEventType *e) : event(e) { /* ... */ } + explicit MultiWaitHolderOfInterProcessEvent(InterProcessEventType *e) : m_event(e) { /* ... */ } /* IsSignaled, GetHandle both implemented. */ virtual TriBool IsSignaled() const override { @@ -31,7 +31,7 @@ namespace ams::os::impl { } virtual NativeHandle GetHandle() const override { - return this->event->readable_handle; + return m_event->readable_handle; } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.cpp index 4a46589ac..24a68b518 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.cpp @@ -20,7 +20,7 @@ namespace ams::os::impl { NativeHandle MultiWaitHolderOfInterruptEvent::GetHandle() const { - return GetReference(event->impl).GetHandle(); + return GetReference(m_event->impl).GetHandle(); } } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.hpp index 6b2968e8a..5964317e0 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_interrupt_event.hpp @@ -20,9 +20,9 @@ namespace ams::os::impl { class MultiWaitHolderOfInterruptEvent : public MultiWaitHolderOfKernelObject { private: - InterruptEventType *event; + InterruptEventType *m_event; public: - explicit MultiWaitHolderOfInterruptEvent(InterruptEventType *e) : event(e) { /* ... */ } + explicit MultiWaitHolderOfInterruptEvent(InterruptEventType *e) : m_event(e) { /* ... */ } /* IsSignaled, GetHandle both implemented. */ virtual TriBool IsSignaled() const override { diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_message_queue.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_message_queue.hpp index 991247cf9..f30a83d41 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_message_queue.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_message_queue.hpp @@ -23,15 +23,15 @@ namespace ams::os::impl { class MultiWaitHolderOfMessageQueue : public MultiWaitHolderOfUserObject { static_assert(WaitType == MessageQueueWaitType::ForNotEmpty || WaitType == MessageQueueWaitType::ForNotFull); private: - MessageQueueType *mq; + MessageQueueType *m_mq; private: constexpr inline TriBool IsSignaledImpl() const { if constexpr (WaitType == MessageQueueWaitType::ForNotEmpty) { /* ForNotEmpty. */ - return this->mq->count > 0 ? TriBool::True : TriBool::False; + return m_mq->count > 0 ? TriBool::True : TriBool::False; } else if constexpr (WaitType == MessageQueueWaitType::ForNotFull) { /* ForNotFull */ - return this->mq->count < this->mq->capacity ? TriBool::True : TriBool::False; + return m_mq->count < m_mq->capacity ? TriBool::True : TriBool::False; } else { static_assert(WaitType != WaitType); } @@ -39,31 +39,31 @@ namespace ams::os::impl { constexpr inline MultiWaitObjectList &GetObjectList() const { if constexpr (WaitType == MessageQueueWaitType::ForNotEmpty) { - return GetReference(this->mq->waitlist_not_empty); + return GetReference(m_mq->waitlist_not_empty); } else if constexpr (WaitType == MessageQueueWaitType::ForNotFull) { - return GetReference(this->mq->waitlist_not_full); + return GetReference(m_mq->waitlist_not_full); } else { static_assert(WaitType != WaitType); } } public: - explicit MultiWaitHolderOfMessageQueue(MessageQueueType *mq) : mq(mq) { /* ... */ } + explicit MultiWaitHolderOfMessageQueue(MessageQueueType *mq) : m_mq(mq) { /* ... */ } /* IsSignaled, Link, Unlink implemented. */ virtual TriBool IsSignaled() const override { - std::scoped_lock lk(GetReference(this->mq->cs_queue)); + std::scoped_lock lk(GetReference(m_mq->cs_queue)); return this->IsSignaledImpl(); } virtual TriBool LinkToObjectList() override { - std::scoped_lock lk(GetReference(this->mq->cs_queue)); + std::scoped_lock lk(GetReference(m_mq->cs_queue)); this->GetObjectList().LinkMultiWaitHolder(*this); return this->IsSignaledImpl(); } virtual void UnlinkFromObjectList() override { - std::scoped_lock lk(GetReference(this->mq->cs_queue)); + std::scoped_lock lk(GetReference(m_mq->cs_queue)); this->GetObjectList().UnlinkMultiWaitHolder(*this); } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_semaphore.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_semaphore.hpp index 3c699d18a..1a09a2d63 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_semaphore.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_semaphore.hpp @@ -21,31 +21,31 @@ namespace ams::os::impl { class MultiWaitHolderOfSemaphore : public MultiWaitHolderOfUserObject { private: - SemaphoreType *semaphore; + SemaphoreType *m_semaphore; private: TriBool IsSignaledImpl() const { - return this->semaphore->count > 0 ? TriBool::True : TriBool::False; + return m_semaphore->count > 0 ? TriBool::True : TriBool::False; } public: - explicit MultiWaitHolderOfSemaphore(SemaphoreType *s) : semaphore(s) { /* ... */ } + explicit MultiWaitHolderOfSemaphore(SemaphoreType *s) : m_semaphore(s) { /* ... */ } /* IsSignaled, Link, Unlink implemented. */ virtual TriBool IsSignaled() const override { - std::scoped_lock lk(GetReference(this->semaphore->cs_sema)); + std::scoped_lock lk(GetReference(m_semaphore->cs_sema)); return this->IsSignaledImpl(); } virtual TriBool LinkToObjectList() override { - std::scoped_lock lk(GetReference(this->semaphore->cs_sema)); + std::scoped_lock lk(GetReference(m_semaphore->cs_sema)); - GetReference(this->semaphore->waitlist).LinkMultiWaitHolder(*this); + GetReference(m_semaphore->waitlist).LinkMultiWaitHolder(*this); return this->IsSignaledImpl(); } virtual void UnlinkFromObjectList() override { - std::scoped_lock lk(GetReference(this->semaphore->cs_sema)); + std::scoped_lock lk(GetReference(m_semaphore->cs_sema)); - GetReference(this->semaphore->waitlist).UnlinkMultiWaitHolder(*this); + GetReference(m_semaphore->waitlist).UnlinkMultiWaitHolder(*this); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_thread.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_thread.hpp index 2ae24f541..97a744f03 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_thread.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_thread.hpp @@ -20,31 +20,31 @@ namespace ams::os::impl { class MultiWaitHolderOfThread : public MultiWaitHolderOfUserObject { private: - ThreadType *thread; + ThreadType *m_thread; private: TriBool IsSignaledImpl() const { - return this->thread->state == ThreadType::State_Terminated ? TriBool::True : TriBool::False; + return m_thread->state == ThreadType::State_Terminated ? TriBool::True : TriBool::False; } public: - explicit MultiWaitHolderOfThread(ThreadType *t) : thread(t) { /* ... */ } + explicit MultiWaitHolderOfThread(ThreadType *t) : m_thread(t) { /* ... */ } /* IsSignaled, Link, Unlink implemented. */ virtual TriBool IsSignaled() const override { - std::scoped_lock lk(GetReference(this->thread->cs_thread)); + std::scoped_lock lk(GetReference(m_thread->cs_thread)); return this->IsSignaledImpl(); } virtual TriBool LinkToObjectList() override { - std::scoped_lock lk(GetReference(this->thread->cs_thread)); + std::scoped_lock lk(GetReference(m_thread->cs_thread)); - GetReference(this->thread->waitlist).LinkMultiWaitHolder(*this); + GetReference(m_thread->waitlist).LinkMultiWaitHolder(*this); return this->IsSignaledImpl(); } virtual void UnlinkFromObjectList() override { - std::scoped_lock lk(GetReference(this->thread->cs_thread)); + std::scoped_lock lk(GetReference(m_thread->cs_thread)); - GetReference(this->thread->waitlist).UnlinkMultiWaitHolder(*this); + GetReference(m_thread->waitlist).UnlinkMultiWaitHolder(*this); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_timer_event.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_timer_event.hpp index 28d76e71f..56f7a76bf 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_timer_event.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_holder_of_timer_event.hpp @@ -23,44 +23,44 @@ namespace ams::os::impl { class MultiWaitHolderOfTimerEvent : public MultiWaitHolderOfUserObject { private: - TimerEventType *event; + TimerEventType *m_event; private: TriBool IsSignaledImpl() const { TimeSpan cur_time = this->GetMultiWait()->GetCurrentTime(); - UpdateSignalStateAndRecalculateNextTimeToWakeupUnsafe(this->event, cur_time); - return this->event->signaled ? TriBool::True : TriBool::False; + UpdateSignalStateAndRecalculateNextTimeToWakeupUnsafe(m_event, cur_time); + return m_event->signaled ? TriBool::True : TriBool::False; } public: - explicit MultiWaitHolderOfTimerEvent(TimerEventType *e) : event(e) { /* ... */ } + explicit MultiWaitHolderOfTimerEvent(TimerEventType *e) : m_event(e) { /* ... */ } /* IsSignaled, Link, Unlink implemented. */ virtual TriBool IsSignaled() const override { - std::scoped_lock lk(GetReference(this->event->cs_timer_event)); + std::scoped_lock lk(GetReference(m_event->cs_timer_event)); return this->IsSignaledImpl(); } virtual TriBool LinkToObjectList() override { - std::scoped_lock lk(GetReference(this->event->cs_timer_event)); + std::scoped_lock lk(GetReference(m_event->cs_timer_event)); - GetReference(this->event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this); + GetReference(m_event->multi_wait_object_list_storage).LinkMultiWaitHolder(*this); return this->IsSignaledImpl(); } virtual void UnlinkFromObjectList() override { - std::scoped_lock lk(GetReference(this->event->cs_timer_event)); + std::scoped_lock lk(GetReference(m_event->cs_timer_event)); - GetReference(this->event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this); + GetReference(m_event->multi_wait_object_list_storage).UnlinkMultiWaitHolder(*this); } /* Gets the amount of time remaining until this wakes up. */ virtual TimeSpan GetAbsoluteWakeupTime() const override { - std::scoped_lock lk(GetReference(this->event->cs_timer_event)); + std::scoped_lock lk(GetReference(m_event->cs_timer_event)); - if (this->event->timer_state == TimerEventType::TimerState_Stop) { + if (m_event->timer_state == TimerEventType::TimerState_Stop) { return TimeSpan::FromNanoSeconds(std::numeric_limits::max()); } - return GetReference(this->event->next_time_to_wakeup); + return GetReference(m_event->next_time_to_wakeup); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp index ba48dcb78..8b3f7d60c 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.cpp @@ -22,15 +22,15 @@ namespace ams::os::impl { Result MultiWaitImpl::WaitAnyImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target) { /* Prepare for processing. */ - this->signaled_holder = nullptr; - this->target_impl.SetCurrentThreadHandleForCancelWait(); + m_signaled_holder = nullptr; + m_target_impl.SetCurrentThreadHandleForCancelWait(); MultiWaitHolderBase *holder = this->LinkHoldersToObjectList(); /* Check if we've been signaled. */ { - std::scoped_lock lk(this->cs_wait); - if (this->signaled_holder != nullptr) { - holder = this->signaled_holder; + std::scoped_lock lk(m_cs_wait); + if (m_signaled_holder != nullptr) { + holder = m_signaled_holder; } } @@ -39,7 +39,7 @@ namespace ams::os::impl { if (holder != nullptr) { if (reply && reply_target != os::InvalidNativeHandle) { s32 index; - wait_result = this->target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0)); + wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0)); if (R_FAILED(wait_result)) { holder = nullptr; } @@ -51,7 +51,7 @@ namespace ams::os::impl { /* Unlink holders from the current object list. */ this->UnlinkHoldersFromObjectList(); - this->target_impl.ClearCurrentThreadHandleForCancelWait(); + m_target_impl.ClearCurrentThreadHandleForCancelWait(); /* Set output holder. */ *out = holder; @@ -67,7 +67,7 @@ namespace ams::os::impl { const TimeSpan end_time = infinite ? TimeSpan::FromNanoSeconds(std::numeric_limits::max()) : GetCurrentTick().ToTimeSpan() + timeout; while (true) { - this->current_time = GetCurrentTick().ToTimeSpan(); + m_current_time = GetCurrentTick().ToTimeSpan(); TimeSpan min_timeout = 0; MultiWaitHolderBase *min_timeout_object = this->RecalculateNextTimeout(std::addressof(min_timeout), end_time); @@ -76,17 +76,17 @@ namespace ams::os::impl { Result wait_result = ResultSuccess(); if (reply) { if (infinite && min_timeout_object == nullptr) { - wait_result = this->target_impl.ReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target); + wait_result = m_target_impl.ReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target); } else { - wait_result = this->target_impl.TimedReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target, min_timeout); + wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), object_handles, MaximumHandleCount, count, reply_target, min_timeout); } } else if (infinite && min_timeout_object == nullptr) { - wait_result = this->target_impl.WaitAny(std::addressof(index), object_handles, MaximumHandleCount, count); + wait_result = m_target_impl.WaitAny(std::addressof(index), object_handles, MaximumHandleCount, count); } else { if (count == 0 && min_timeout == 0) { index = WaitTimedOut; } else { - wait_result = this->target_impl.TimedWaitAny(std::addressof(index), object_handles, MaximumHandleCount, count, min_timeout); + wait_result = m_target_impl.TimedWaitAny(std::addressof(index), object_handles, MaximumHandleCount, count, min_timeout); AMS_ABORT_UNLESS(index != WaitInvalid); } } @@ -99,11 +99,11 @@ namespace ams::os::impl { switch (index) { case WaitTimedOut: if (min_timeout_object) { - this->current_time = GetCurrentTick().ToTimeSpan(); + m_current_time = GetCurrentTick().ToTimeSpan(); if (min_timeout_object->IsSignaled() == TriBool::True) { - std::scoped_lock lk(this->cs_wait); - this->signaled_holder = min_timeout_object; - *out = min_timeout_object; + std::scoped_lock lk(m_cs_wait); + m_signaled_holder = min_timeout_object; + *out = min_timeout_object; return wait_result; } } else { @@ -113,9 +113,9 @@ namespace ams::os::impl { break; case WaitCancelled: { - std::scoped_lock lk(this->cs_wait); - if (this->signaled_holder) { - *out = this->signaled_holder; + std::scoped_lock lk(m_cs_wait); + if (m_signaled_holder) { + *out = m_signaled_holder; return wait_result; } } @@ -124,9 +124,9 @@ namespace ams::os::impl { { AMS_ASSERT(0 <= index && index < static_cast(MaximumHandleCount)); - std::scoped_lock lk(this->cs_wait); - this->signaled_holder = objects[index]; - *out = objects[index]; + std::scoped_lock lk(m_cs_wait); + m_signaled_holder = objects[index]; + *out = objects[index]; return wait_result; } break; @@ -139,7 +139,7 @@ namespace ams::os::impl { s32 MultiWaitImpl::BuildHandleArray(NativeHandle out_handles[], MultiWaitHolderBase *out_objects[], s32 num) { s32 count = 0; - for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { + for (MultiWaitHolderBase &holder_base : m_multi_wait_list) { if (auto handle = holder_base.GetHandle(); handle != os::InvalidNativeHandle) { AMS_ABORT_UNLESS(count < num); @@ -155,7 +155,7 @@ namespace ams::os::impl { MultiWaitHolderBase *MultiWaitImpl::LinkHoldersToObjectList() { MultiWaitHolderBase *signaled_holder = nullptr; - for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { + for (MultiWaitHolderBase &holder_base : m_multi_wait_list) { TriBool is_signaled = holder_base.LinkToObjectList(); if (signaled_holder == nullptr && is_signaled == TriBool::True) { @@ -167,7 +167,7 @@ namespace ams::os::impl { } void MultiWaitImpl::UnlinkHoldersFromObjectList() { - for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { + for (MultiWaitHolderBase &holder_base : m_multi_wait_list) { holder_base.UnlinkFromObjectList(); } } @@ -176,27 +176,27 @@ namespace ams::os::impl { MultiWaitHolderBase *min_timeout_holder = nullptr; TimeSpan min_time = end_time; - for (MultiWaitHolderBase &holder_base : this->multi_wait_list) { + for (MultiWaitHolderBase &holder_base : m_multi_wait_list) { if (const TimeSpan cur_time = holder_base.GetAbsoluteWakeupTime(); cur_time < min_time) { min_timeout_holder = std::addressof(holder_base); min_time = cur_time; } } - if (min_time < this->current_time) { + if (min_time < m_current_time) { *out_min_timeout = 0; } else { - *out_min_timeout = min_time - this->current_time; + *out_min_timeout = min_time - m_current_time; } return min_timeout_holder; } void MultiWaitImpl::SignalAndWakeupThread(MultiWaitHolderBase *holder_base) { - std::scoped_lock lk(this->cs_wait); + std::scoped_lock lk(m_cs_wait); - if (this->signaled_holder == nullptr) { - this->signaled_holder = holder_base; - this->target_impl.CancelWait(); + if (m_signaled_holder == nullptr) { + m_signaled_holder = holder_base; + m_target_impl.CancelWait(); } } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp index 75cd01e10..a6fa60815 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_impl.hpp @@ -30,13 +30,13 @@ namespace ams::os::impl { static constexpr s32 WaitInvalid = -3; static constexpr s32 WaitCancelled = -2; static constexpr s32 WaitTimedOut = -1; - using MultiWaitList = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::multi_wait_node>::ListType; + using MultiWaitList = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::m_multi_wait_node>::ListType; private: - MultiWaitList multi_wait_list; - MultiWaitHolderBase *signaled_holder; - TimeSpan current_time; - InternalCriticalSection cs_wait; - MultiWaitTargetImpl target_impl; + MultiWaitList m_multi_wait_list; + MultiWaitHolderBase *m_signaled_holder; + TimeSpan m_current_time; + InternalCriticalSection m_cs_wait; + MultiWaitTargetImpl m_target_impl; private: Result WaitAnyImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target); Result WaitAnyHandleImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target); @@ -76,35 +76,35 @@ namespace ams::os::impl { /* List management. */ bool IsEmpty() const { - return this->multi_wait_list.empty(); + return m_multi_wait_list.empty(); } void LinkMultiWaitHolder(MultiWaitHolderBase &holder_base) { - this->multi_wait_list.push_back(holder_base); + m_multi_wait_list.push_back(holder_base); } void UnlinkMultiWaitHolder(MultiWaitHolderBase &holder_base) { - this->multi_wait_list.erase(this->multi_wait_list.iterator_to(holder_base)); + m_multi_wait_list.erase(m_multi_wait_list.iterator_to(holder_base)); } void UnlinkAll() { while (!this->IsEmpty()) { - this->multi_wait_list.front().SetMultiWait(nullptr); - this->multi_wait_list.pop_front(); + m_multi_wait_list.front().SetMultiWait(nullptr); + m_multi_wait_list.pop_front(); } } void MoveAllFrom(MultiWaitImpl &other) { /* Set ourselves as multi wait for all of the other's holders. */ - for (auto &w : other.multi_wait_list) { + for (auto &w : other.m_multi_wait_list) { w.SetMultiWait(this); } - this->multi_wait_list.splice(this->multi_wait_list.end(), other.multi_wait_list); + m_multi_wait_list.splice(m_multi_wait_list.end(), other.m_multi_wait_list); } /* Other. */ TimeSpan GetCurrentTime() const { - return this->current_time; + return m_current_time; } void SignalAndWakeupThread(MultiWaitHolderBase *holder_base); diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp index d70eab597..cd493a365 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_object_list.hpp @@ -21,32 +21,32 @@ namespace ams::os::impl { class MultiWaitObjectList { public: - using ListType = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::object_list_node>::ListType; + using ListType = util::IntrusiveListMemberTraits<&MultiWaitHolderBase::m_object_list_node>::ListType; private: - ListType object_list; + ListType m_object_list; public: void SignalAllThreads() { - for (MultiWaitHolderBase &holder_base : this->object_list) { + for (MultiWaitHolderBase &holder_base : m_object_list) { holder_base.GetMultiWait()->SignalAndWakeupThread(std::addressof(holder_base)); } } void BroadcastAllThreads() { - for (MultiWaitHolderBase &holder_base : this->object_list) { + for (MultiWaitHolderBase &holder_base : m_object_list) { holder_base.GetMultiWait()->SignalAndWakeupThread(nullptr); } } bool IsEmpty() const { - return this->object_list.empty(); + return m_object_list.empty(); } void LinkMultiWaitHolder(MultiWaitHolderBase &holder_base) { - this->object_list.push_back(holder_base); + m_object_list.push_back(holder_base); } void UnlinkMultiWaitHolder(MultiWaitHolderBase &holder_base) { - this->object_list.erase(this->object_list.iterator_to(holder_base)); + m_object_list.erase(m_object_list.iterator_to(holder_base)); } }; diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp index d5893788b..cc5165199 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.cpp @@ -69,7 +69,7 @@ namespace ams::os::impl { } void MultiWaitHorizonImpl::CancelWait() { - R_ABORT_UNLESS(svc::CancelSynchronization(this->handle)); + R_ABORT_UNLESS(svc::CancelSynchronization(m_handle)); } } diff --git a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp index 5ad9ddb99..ca8f0f597 100644 --- a/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_multiple_wait_target_impl.os.horizon.hpp @@ -23,11 +23,13 @@ namespace ams::os::impl { public: static constexpr size_t MaximumHandleCount = static_cast(ams::svc::ArgumentHandleCountMax); private: - NativeHandle handle; + NativeHandle m_handle; private: Result WaitSynchronizationN(s32 *out_index, s32 num, NativeHandle arr[], s32 array_size, s64 ns); Result ReplyAndReceiveN(s32 *out_index, s32 num, NativeHandle arr[], s32 array_size, s64 ns, NativeHandle reply_target); public: + constexpr MultiWaitHorizonImpl() : m_handle(os::InvalidNativeHandle) { /* ... */ } + void CancelWait(); Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) { @@ -55,11 +57,11 @@ namespace ams::os::impl { } void SetCurrentThreadHandleForCancelWait() { - this->handle = GetCurrentThreadHandle(); + m_handle = GetCurrentThreadHandle(); } void ClearCurrentThreadHandleForCancelWait() { - this->handle = os::InvalidNativeHandle; + m_handle = os::InvalidNativeHandle; } }; diff --git a/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp b/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp index efdb7cb5d..5170850a1 100644 --- a/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp +++ b/libraries/libstratosphere/source/os/impl/os_resource_manager.hpp @@ -24,20 +24,20 @@ namespace ams::os::impl { class OsResourceManager { private: - RngManager rng_manager{}; - AslrSpaceManager aslr_space_manager{}; + RngManager m_rng_manager{}; + AslrSpaceManager m_aslr_space_manager{}; /* TODO */ - ThreadManager thread_manager{}; + ThreadManager m_thread_manager{}; /* TODO */ - TickManager tick_manager{}; + TickManager m_tick_manager{}; /* TODO */ public: OsResourceManager() = default; - constexpr ALWAYS_INLINE RngManager &GetRngManager() { return this->rng_manager; } - constexpr ALWAYS_INLINE AslrSpaceManager &GetAslrSpaceManager() { return this->aslr_space_manager; } - constexpr ALWAYS_INLINE ThreadManager &GetThreadManager() { return this->thread_manager; } - constexpr ALWAYS_INLINE TickManager &GetTickManager() { return this->tick_manager; } + constexpr ALWAYS_INLINE RngManager &GetRngManager() { return m_rng_manager; } + constexpr ALWAYS_INLINE AslrSpaceManager &GetAslrSpaceManager() { return m_aslr_space_manager; } + constexpr ALWAYS_INLINE ThreadManager &GetThreadManager() { return m_thread_manager; } + constexpr ALWAYS_INLINE TickManager &GetTickManager() { return m_tick_manager; } }; class ResourceManagerHolder { diff --git a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.cpp b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.cpp index 05603952a..79f105ac5 100644 --- a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.cpp +++ b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.cpp @@ -19,13 +19,13 @@ namespace ams::os::impl { u64 RngManager::GenerateRandomU64() { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - if (AMS_UNLIKELY(!this->initialized)) { + if (AMS_UNLIKELY(!m_initialized)) { this->Initialize(); } - return this->mt.GenerateRandomU64(); + return m_mt.GenerateRandomU64(); } } diff --git a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.hpp b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.hpp index 7112f662b..86c5ab50d 100644 --- a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.hpp @@ -20,13 +20,13 @@ namespace ams::os::impl { class RngManager { private: - util::TinyMT mt; - os::SdkMutex lock; - bool initialized; + util::TinyMT m_mt; + os::SdkMutex m_lock; + bool m_initialized; private: void Initialize(); public: - constexpr RngManager() : mt(), lock(), initialized() { /* ... */ } + constexpr RngManager() : m_mt(), m_lock(), m_initialized() { /* ... */ } public: u64 GenerateRandomU64(); }; diff --git a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.os.horizon.cpp b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.os.horizon.cpp index e725da5bc..51ce04301 100644 --- a/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.os.horizon.cpp +++ b/libraries/libstratosphere/source/os/impl/os_rng_manager_impl.os.horizon.cpp @@ -29,10 +29,10 @@ namespace ams::os::impl { R_ABORT_UNLESS(svc::GetInfo(reinterpret_cast(seed + 0), svc::InfoType_RandomEntropy, svc::InvalidHandle, 2)); R_ABORT_UNLESS(svc::GetInfo(reinterpret_cast(seed + 2), svc::InfoType_RandomEntropy, svc::InvalidHandle, 3)); - this->mt.Initialize(seed, util::size(seed)); + m_mt.Initialize(seed, util::size(seed)); /* Note that we've initialized. */ - this->initialized = true; + m_initialized = true; } } diff --git a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp index 2111b7ed2..30c82548c 100644 --- a/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp +++ b/libraries/libstratosphere/source/os/impl/os_rw_lock_target_impl.os.horizon.hpp @@ -23,15 +23,15 @@ namespace ams::os::impl { using LockCount = os::ReaderWriterLockType::LockCount; private: static ALWAYS_INLINE u32 GetThreadHandle(const LockCount &lc) { - return GetReference(lc.cs_storage).Get()->thread_handle; + return GetReference(lc.cs_storage).Get()->m_thread_handle; } static ALWAYS_INLINE uintptr_t GetThreadHandleAddress(LockCount &lc) { - return reinterpret_cast(std::addressof(GetReference(lc.cs_storage).Get()->thread_handle)); + return reinterpret_cast(std::addressof(GetReference(lc.cs_storage).Get()->m_thread_handle)); } static ALWAYS_INLINE void SetThreadHandle(LockCount &lc, u32 handle) { - GetReference(lc.cs_storage).Get()->thread_handle = handle; + GetReference(lc.cs_storage).Get()->m_thread_handle = handle; } static void AcquireReadLockWriteLocked(os::ReaderWriterLockType *rw_lock); diff --git a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp index 5c3af504d..f6478795a 100644 --- a/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp +++ b/libraries/libstratosphere/source/os/impl/os_thread_manager.cpp @@ -73,12 +73,12 @@ namespace ams::os::impl { manager.CleanupThread(); } - ThreadManager::ThreadManager() : impl(std::addressof(main_thread)), total_thread_stack_size(0), num_created_threads(0) { - this->main_thread.state = ThreadType::State_Started; + ThreadManager::ThreadManager() : m_impl(std::addressof(m_main_thread)), m_total_thread_stack_size(0), m_num_created_threads(0) { + m_main_thread.state = ThreadType::State_Started; - this->SetCurrentThread(std::addressof(this->main_thread)); + this->SetCurrentThread(std::addressof(m_main_thread)); - this->PlaceThreadObjectUnderThreadManagerSafe(std::addressof(this->main_thread)); + this->PlaceThreadObjectUnderThreadManagerSafe(std::addressof(m_main_thread)); } void ThreadManager::CleanupThread() { @@ -98,7 +98,7 @@ namespace ams::os::impl { SetupThreadObjectUnsafe(thread, nullptr, function, argument, stack, stack_size, priority); auto guard = SCOPE_GUARD { thread->state = ThreadType::State_NotInitialized; }; - R_TRY(this->impl.CreateThread(thread, ideal_core)); + R_TRY(m_impl.CreateThread(thread, ideal_core)); guard.Cancel(); this->PlaceThreadObjectUnderThreadManagerSafe(thread); @@ -107,7 +107,7 @@ namespace ams::os::impl { } Result ThreadManager::CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority) { - return this->CreateThread(thread, function, argument, stack, stack_size, priority, this->impl.GetDefaultCoreNumber()); + return this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber()); } void ThreadManager::DestroyThread(ThreadType *thread) { @@ -116,12 +116,12 @@ namespace ams::os::impl { if (thread->state == ThreadType::State_Initialized) { thread->state = ThreadType::State_DestroyedBeforeStarted; - this->impl.StartThread(thread); + m_impl.StartThread(thread); GetReference(thread->cv_thread).Signal(); } } - this->impl.WaitForThreadExit(thread); + m_impl.WaitForThreadExit(thread); AMS_ASSERT(thread->state == ThreadType::State_Initialized); @@ -130,7 +130,7 @@ namespace ams::os::impl { /* NOTE: Here Nintendo would cleanup the alias stack. */ - this->impl.DestroyThreadUnsafe(thread); + m_impl.DestroyThreadUnsafe(thread); thread->state = ThreadType::State_NotInitialized; @@ -140,7 +140,7 @@ namespace ams::os::impl { thread->magic = 0xCCCC; { - std::scoped_lock tlk(this->cs); + std::scoped_lock tlk(m_cs); this->EraseFromAllThreadsListUnsafe(thread); } } @@ -151,14 +151,14 @@ namespace ams::os::impl { AMS_ASSERT(thread->state == ThreadType::State_Initialized); - this->impl.StartThread(thread); + m_impl.StartThread(thread); thread->state = ThreadType::State_Started; GetReference(thread->cv_thread).Signal(); } void ThreadManager::WaitThread(ThreadType *thread) { - this->impl.WaitForThreadExit(thread); + m_impl.WaitForThreadExit(thread); { std::scoped_lock lk(GetReference(thread->cs_thread)); @@ -168,7 +168,7 @@ namespace ams::os::impl { } bool ThreadManager::TryWaitThread(ThreadType *thread) { - const bool result = this->impl.TryWaitForThreadExit(thread); + const bool result = m_impl.TryWaitForThreadExit(thread); if (result) { std::scoped_lock lk(GetReference(thread->cs_thread)); @@ -187,7 +187,7 @@ namespace ams::os::impl { thread->suspend_count = prev_suspend_count + 1; if (prev_suspend_count == 0) { - this->impl.SuspendThreadUnsafe(thread); + m_impl.SuspendThreadUnsafe(thread); } return prev_suspend_count; } @@ -199,7 +199,7 @@ namespace ams::os::impl { if (prev_suspend_count > 0) { thread->suspend_count = prev_suspend_count - 1; if (prev_suspend_count == 1) { - this->impl.ResumeThreadUnsafe(thread); + m_impl.ResumeThreadUnsafe(thread); } } return prev_suspend_count; @@ -208,7 +208,7 @@ namespace ams::os::impl { void ThreadManager::CancelThreadSynchronization(ThreadType *thread) { std::scoped_lock lk(GetReference(thread->cs_thread)); - this->impl.CancelThreadSynchronizationUnsafe(thread); + m_impl.CancelThreadSynchronizationUnsafe(thread); } /* TODO void ThreadManager::GetThreadContext(ThreadContextInfo *out_context, const ThreadType *thread); */ @@ -221,7 +221,7 @@ namespace ams::os::impl { } void ThreadManager::SetInitialThreadNameUnsafe(ThreadType *thread) { - if (thread == std::addressof(this->main_thread)) { + if (thread == std::addressof(m_main_thread)) { static_assert(sizeof(thread->name_buffer) >= sizeof(MainThreadName)); static_assert(MainThreadName[sizeof(MainThreadName) - 1] == '\x00'); std::memcpy(thread->name_buffer, MainThreadName, sizeof(MainThreadName)); diff --git a/libraries/libstratosphere/source/os/impl/os_thread_manager_types.hpp b/libraries/libstratosphere/source/os/impl/os_thread_manager_types.hpp index 38008b09b..39285e34f 100644 --- a/libraries/libstratosphere/source/os/impl/os_thread_manager_types.hpp +++ b/libraries/libstratosphere/source/os/impl/os_thread_manager_types.hpp @@ -53,17 +53,17 @@ namespace ams::os::impl { using AllThreadsList = ThreadListTraits::ListType; private: - ThreadManagerImpl impl; - ThreadType main_thread; - InternalCriticalSection cs; - AllThreadsList all_threads_list; - size_t total_thread_stack_size; - s32 num_created_threads; + ThreadManagerImpl m_impl; + ThreadType m_main_thread; + InternalCriticalSection m_cs; + AllThreadsList m_all_threads_list; + size_t m_total_thread_stack_size; + s32 m_num_created_threads; public: ThreadManager(); void CleanupThread(); - s32 GetThreadCountForDebug() const { return this->num_created_threads; } + s32 GetThreadCountForDebug() const { return m_num_created_threads; } Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority, s32 ideal_core); Result CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority); @@ -73,11 +73,11 @@ namespace ams::os::impl { void WaitThread(ThreadType *thread); bool TryWaitThread(ThreadType *thread); - void YieldThread() { return this->impl.YieldThread(); } + void YieldThread() { return m_impl.YieldThread(); } - bool ChangePriority(ThreadType *thread, s32 priority) { return this->impl.ChangePriority(thread, priority); } - s32 GetCurrentPriority(const ThreadType *thread) const { return this->impl.GetCurrentPriority(thread); } - ThreadType *GetCurrentThread() const { return this->impl.GetCurrentThread(); } + bool ChangePriority(ThreadType *thread, s32 priority) { return m_impl.ChangePriority(thread, priority); } + s32 GetCurrentPriority(const ThreadType *thread) const { return m_impl.GetCurrentPriority(thread); } + ThreadType *GetCurrentThread() const { return m_impl.GetCurrentThread(); } s32 SuspendThread(ThreadType *thread); s32 ResumeThread(ThreadType *thread); @@ -88,39 +88,39 @@ namespace ams::os::impl { void SetInitialThreadNameUnsafe(ThreadType *thread); - void NotifyThreadNameChanged(const ThreadType *thread) const { return this->impl.NotifyThreadNameChangedImpl(thread); } - void SetCurrentThread(ThreadType *thread) const { return this->impl.SetCurrentThread(thread); } - s32 GetCurrentCoreNumber() const { return this->impl.GetCurrentCoreNumber(); } - void SetThreadCoreMask(ThreadType *thread, s32 ideal_core, u64 affinity_mask) const { return this->impl.SetThreadCoreMask(thread, ideal_core, affinity_mask); } - void GetThreadCoreMask(s32 *out_ideal_core, u64 *out_affinity_mask, const ThreadType *thread) const { return this->impl.GetThreadCoreMask(out_ideal_core, out_affinity_mask, thread); } - u64 GetThreadAvailableCoreMask() const { return this->impl.GetThreadAvailableCoreMask(); } + void NotifyThreadNameChanged(const ThreadType *thread) const { return m_impl.NotifyThreadNameChangedImpl(thread); } + void SetCurrentThread(ThreadType *thread) const { return m_impl.SetCurrentThread(thread); } + s32 GetCurrentCoreNumber() const { return m_impl.GetCurrentCoreNumber(); } + void SetThreadCoreMask(ThreadType *thread, s32 ideal_core, u64 affinity_mask) const { return m_impl.SetThreadCoreMask(thread, ideal_core, affinity_mask); } + void GetThreadCoreMask(s32 *out_ideal_core, u64 *out_affinity_mask, const ThreadType *thread) const { return m_impl.GetThreadCoreMask(out_ideal_core, out_affinity_mask, thread); } + u64 GetThreadAvailableCoreMask() const { return m_impl.GetThreadAvailableCoreMask(); } void PushBackToAllThreadsListUnsafe(ThreadType *thread) { - this->all_threads_list.push_back(*thread); - ++this->num_created_threads; - this->total_thread_stack_size += thread->stack_size; + m_all_threads_list.push_back(*thread); + ++m_num_created_threads; + m_total_thread_stack_size += thread->stack_size; } void EraseFromAllThreadsListUnsafe(ThreadType *thread) { - this->all_threads_list.erase(this->all_threads_list.iterator_to(*thread)); - --this->num_created_threads; - this->total_thread_stack_size -= thread->stack_size; + m_all_threads_list.erase(m_all_threads_list.iterator_to(*thread)); + --m_num_created_threads; + m_total_thread_stack_size -= thread->stack_size; } void PushBackToAllThreadsListSafe(ThreadType *thread) { - std::scoped_lock lk(this->cs); + std::scoped_lock lk(m_cs); this->PushBackToAllThreadsListUnsafe(thread); } void EraseFromAllThreadsListSafe(ThreadType *thread) { - std::scoped_lock lk(this->cs); + std::scoped_lock lk(m_cs); this->EraseFromAllThreadsListUnsafe(thread); } void PlaceThreadObjectUnderThreadManagerSafe(ThreadType *thread) { SetInitialThreadNameUnsafe(thread); { - std::scoped_lock lk(this->cs); + std::scoped_lock lk(m_cs); this->PushBackToAllThreadsListUnsafe(thread); } } @@ -134,15 +134,15 @@ namespace ams::os::impl { } const ThreadType *GetMainThread() const { - return std::addressof(this->main_thread); + return std::addressof(m_main_thread); } size_t GetTotalThreadStackSize() const { - return this->total_thread_stack_size; + return m_total_thread_stack_size; } ThreadId GetThreadId(const ThreadType *thread) { - return this->impl.GetThreadId(thread); + return m_impl.GetThreadId(thread); } public: static void InvokeThread(ThreadType *thread); diff --git a/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.hpp b/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.hpp index c9a854df0..a8a580709 100644 --- a/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.hpp +++ b/libraries/libstratosphere/source/os/impl/os_tick_manager_impl.hpp @@ -29,28 +29,28 @@ namespace ams::os::impl { class TickManager { private: - TickManagerImpl impl; + TickManagerImpl m_impl; public: - constexpr TickManager() : impl() { /* ... */ } + constexpr TickManager() : m_impl() { /* ... */ } ALWAYS_INLINE Tick GetTick() const { - return this->impl.GetTick(); + return m_impl.GetTick(); } ALWAYS_INLINE Tick GetSystemTickOrdered() const { - return this->impl.GetSystemTickOrdered(); + return m_impl.GetSystemTickOrdered(); } ALWAYS_INLINE s64 GetTickFrequency() const { - return this->impl.GetTickFrequency(); + return m_impl.GetTickFrequency(); } ALWAYS_INLINE s64 GetMaxTick() const { - return this->impl.GetMaxTick(); + return m_impl.GetMaxTick(); } ALWAYS_INLINE s64 GetMaxTimeSpanNs() const { - return this->impl.GetMaxTimeSpanNs(); + return m_impl.GetMaxTimeSpanNs(); } TimeSpan ConvertToTimeSpan(Tick tick) const; diff --git a/libraries/libstratosphere/source/os/impl/os_timeout_helper.cpp b/libraries/libstratosphere/source/os/impl/os_timeout_helper.cpp index 49085f4d1..c26a67be3 100644 --- a/libraries/libstratosphere/source/os/impl/os_timeout_helper.cpp +++ b/libraries/libstratosphere/source/os/impl/os_timeout_helper.cpp @@ -20,18 +20,18 @@ namespace ams::os::impl { TargetTimeSpan TimeoutHelper::GetTimeLeftOnTarget() const { /* If the absolute tick is zero, we're expired. */ - if (this->absolute_end_tick.GetInt64Value() == 0) { + if (m_absolute_end_tick.GetInt64Value() == 0) { return 0; } /* Check if we've expired. */ const Tick cur_tick = impl::GetTickManager().GetTick(); - if (cur_tick >= this->absolute_end_tick) { + if (cur_tick >= m_absolute_end_tick) { return 0; } /* Return the converted difference as a timespan. */ - return TimeoutHelperImpl::ConvertToImplTime(this->absolute_end_tick - cur_tick); + return TimeoutHelperImpl::ConvertToImplTime(m_absolute_end_tick - cur_tick); } } diff --git a/libraries/libstratosphere/source/os/impl/os_timeout_helper.hpp b/libraries/libstratosphere/source/os/impl/os_timeout_helper.hpp index bd034c232..72dfc507b 100644 --- a/libraries/libstratosphere/source/os/impl/os_timeout_helper.hpp +++ b/libraries/libstratosphere/source/os/impl/os_timeout_helper.hpp @@ -27,12 +27,12 @@ namespace ams::os::impl { class TimeoutHelper { private: - Tick absolute_end_tick; + Tick m_absolute_end_tick; public: explicit TimeoutHelper(TimeSpan timeout) { if (timeout == 0) { /* If timeout is zero, don't do relative tick calculations. */ - this->absolute_end_tick = Tick(0); + m_absolute_end_tick = Tick(0); } else { const auto &tick_manager = impl::GetTickManager(); @@ -40,7 +40,7 @@ namespace ams::os::impl { const u64 timeout_tick = tick_manager.ConvertToTick(timeout).GetInt64Value(); const u64 end_tick = cur_tick + timeout_tick + 1; - this->absolute_end_tick = Tick(std::min(std::numeric_limits::max(), end_tick)); + m_absolute_end_tick = Tick(std::min(std::numeric_limits::max(), end_tick)); } } @@ -49,13 +49,13 @@ namespace ams::os::impl { } bool TimedOut() const { - if (this->absolute_end_tick.GetInt64Value() == 0) { + if (m_absolute_end_tick.GetInt64Value() == 0) { return true; } const Tick cur_tick = impl::GetTickManager().GetTick(); - return cur_tick >= this->absolute_end_tick; + return cur_tick >= m_absolute_end_tick; } TargetTimeSpan GetTimeLeftOnTarget() const; diff --git a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp index 31f891f97..eb64edc0c 100644 --- a/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/pgl_remote_event_observer.hpp @@ -22,35 +22,35 @@ namespace ams::pgl { NON_COPYABLE(RemoteEventObserver); NON_MOVEABLE(RemoteEventObserver); private: - ::PglEventObserver observer; + ::PglEventObserver m_observer; public: - constexpr RemoteEventObserver(const ::PglEventObserver &o) : observer(o) { /* ... */ } + constexpr RemoteEventObserver(const ::PglEventObserver &o) : m_observer(o) { /* ... */ } ~RemoteEventObserver() { - ::pglEventObserverClose(std::addressof(this->observer)); + ::pglEventObserverClose(std::addressof(m_observer)); } Result GetProcessEventHandle(ams::sf::OutCopyHandle out) { ::Event ev; - R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev))); + R_TRY(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); out.SetValue(ev.revent, true); return ResultSuccess(); } Result GetProcessEventInfo(ams::sf::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); - return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); + return ::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); } Result GetProcessEventHandle(ams::tipc::OutCopyHandle out) { ::Event ev; - R_TRY(::pglEventObserverGetProcessEvent(std::addressof(this->observer), std::addressof(ev))); + R_TRY(::pglEventObserverGetProcessEvent(std::addressof(m_observer), std::addressof(ev))); out.SetValue(ev.revent); return ResultSuccess(); } Result GetProcessEventInfo(ams::tipc::Out out) { static_assert(sizeof(*out.GetPointer()) == sizeof(::PmProcessEventInfo)); - return ::pglEventObserverGetProcessEventInfo(std::addressof(this->observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); + return ::pglEventObserverGetProcessEventInfo(std::addressof(m_observer), reinterpret_cast<::PmProcessEventInfo *>(out.GetPointer())); } }; static_assert(pgl::sf::IsIEventObserver); diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp index 2d1558dd6..f04104783 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.cpp @@ -19,35 +19,35 @@ namespace ams::pgl::srv { - ShellEventObserverImpl::ShellEventObserverImpl() : message_queue(queue_buffer, QueueCapacity), event(os::EventClearMode_AutoClear, true) { - this->heap_handle = lmem::CreateUnitHeap(this->event_info_data, sizeof(this->event_info_data), sizeof(this->event_info_data[0]), lmem::CreateOption_ThreadSafe, 8, GetPointer(this->heap_head)); + ShellEventObserverImpl::ShellEventObserverImpl() : m_message_queue(m_queue_buffer, QueueCapacity), m_event(os::EventClearMode_AutoClear, true) { + m_heap_handle = lmem::CreateUnitHeap(m_event_info_data, sizeof(m_event_info_data), sizeof(m_event_info_data[0]), lmem::CreateOption_ThreadSafe, 8, GetPointer(m_heap_head)); - RegisterShellEventObserver(util::ConstructAt(this->holder, this)); + RegisterShellEventObserver(util::ConstructAt(m_holder, this)); } ShellEventObserverImpl::~ShellEventObserverImpl() { - UnregisterShellEventObserver(GetPointer(this->holder)); - util::DestroyAt(this->holder); + UnregisterShellEventObserver(GetPointer(m_holder)); + util::DestroyAt(m_holder); } Result ShellEventObserverImpl::PopEventInfo(pm::ProcessEventInfo *out) { /* Receive an info from the queue. */ uintptr_t info_address; - R_UNLESS(this->message_queue.TryReceive(std::addressof(info_address)), pgl::ResultNotAvailable()); + R_UNLESS(m_message_queue.TryReceive(std::addressof(info_address)), pgl::ResultNotAvailable()); pm::ProcessEventInfo *info = reinterpret_cast(info_address); /* Set the output. */ *out = *info; /* Free the received info. */ - lmem::FreeToUnitHeap(this->heap_handle, info); + lmem::FreeToUnitHeap(m_heap_handle, info); return ResultSuccess(); } void ShellEventObserverImpl::Notify(const pm::ProcessEventInfo &info) { /* Allocate a new info. */ - auto allocated = reinterpret_cast(lmem::AllocateFromUnitHeap(this->heap_handle)); + auto allocated = reinterpret_cast(lmem::AllocateFromUnitHeap(m_heap_handle)); if (!allocated) { return; } @@ -56,13 +56,13 @@ namespace ams::pgl::srv { *allocated = info; /* Try to send it. */ - if (!this->message_queue.TrySend(reinterpret_cast(allocated))) { - lmem::FreeToUnitHeap(this->heap_handle, allocated); + if (!m_message_queue.TrySend(reinterpret_cast(allocated))) { + lmem::FreeToUnitHeap(m_heap_handle, allocated); return; } /* Notify that we have a new info available. */ - this->event.Signal(); + m_event.Signal(); } Result ShellEventObserverCmif::GetProcessEventHandle(ams::sf::OutCopyHandle out) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp index 803138f09..8fc52d0ed 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_event_observer.hpp @@ -25,12 +25,12 @@ namespace ams::pgl::srv { class ShellEventObserverHolder : public util::IntrusiveListBaseNode { private: - IShellEventObserver *observer; + IShellEventObserver *m_observer; public: - explicit ShellEventObserverHolder(IShellEventObserver *observer) : observer(observer) { /* ... */ } + explicit ShellEventObserverHolder(IShellEventObserver *observer) : m_observer(observer) { /* ... */ } void Notify(const pm::ProcessEventInfo &info) { - this->observer->Notify(info); + m_observer->Notify(info); } }; @@ -38,19 +38,19 @@ namespace ams::pgl::srv { private: static constexpr size_t QueueCapacity = 0x20; private: - os::MessageQueue message_queue; - uintptr_t queue_buffer[QueueCapacity]; - os::SystemEvent event; - util::TypedStorage heap_head; - lmem::HeapHandle heap_handle; - pm::ProcessEventInfo event_info_data[QueueCapacity]; - util::TypedStorage holder; + os::MessageQueue m_message_queue; + uintptr_t m_queue_buffer[QueueCapacity]; + os::SystemEvent m_event; + util::TypedStorage m_heap_head; + lmem::HeapHandle m_heap_handle; + pm::ProcessEventInfo m_event_info_data[QueueCapacity]; + util::TypedStorage m_holder; public: ShellEventObserverImpl(); ~ShellEventObserverImpl(); os::SystemEvent &GetEvent() { - return this->event; + return m_event; } Result PopEventInfo(pm::ProcessEventInfo *out); diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp index 62f1568f0..a8e1acc62 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp @@ -75,64 +75,64 @@ namespace ams::pgl::srv { NON_COPYABLE(HostPackageReader); NON_MOVEABLE(HostPackageReader); private: - char content_path[fs::EntryNameLengthMax] = {}; - ExtensionType extension_type = ExtensionType::None; - char mount_name[fs::MountNameLengthMax] = {}; - bool is_mounted = false; - ncm::AutoBuffer content_meta_buffer; - ncm::ProgramId program_id = ncm::InvalidProgramId; - u32 program_version = 0; - ncm::ContentMetaType content_meta_type = static_cast(0); - u8 program_index = 0; + char m_content_path[fs::EntryNameLengthMax] = {}; + ExtensionType m_extension_type = ExtensionType::None; + char m_mount_name[fs::MountNameLengthMax] = {}; + bool m_is_mounted = false; + ncm::AutoBuffer m_content_meta_buffer; + ncm::ProgramId m_program_id = ncm::InvalidProgramId; + u32 m_program_version = 0; + ncm::ContentMetaType m_content_meta_type = static_cast(0); + u8 m_program_index = 0; public: - HostPackageReader() : content_meta_buffer() { /* ... */ } + HostPackageReader() : m_content_meta_buffer() { /* ... */ } ~HostPackageReader() { - if (this->is_mounted) { - fs::Unmount(this->mount_name); + if (m_is_mounted) { + fs::Unmount(m_mount_name); } } Result Initialize(const char *package, const char *mount) { /* Copy in the content path. */ - R_UNLESS(strlen(package) <= sizeof(this->content_path) - 1, pgl::ResultBufferNotEnough()); - std::strcpy(this->content_path, package); + R_UNLESS(strlen(package) <= sizeof(m_content_path) - 1, pgl::ResultBufferNotEnough()); + std::strcpy(m_content_path, package); /* Set the extension type. */ R_TRY(this->SetExtensionType()); /* Copy in mount name. */ - R_UNLESS(strlen(mount) <= sizeof(this->mount_name) - 1, pgl::ResultBufferNotEnough()); - std::strcpy(this->mount_name, mount); + R_UNLESS(strlen(mount) <= sizeof(m_mount_name) - 1, pgl::ResultBufferNotEnough()); + std::strcpy(m_mount_name, mount); /* Mount the package. */ - R_TRY(fs::MountApplicationPackage(this->mount_name, this->content_path)); - this->is_mounted = true; + R_TRY(fs::MountApplicationPackage(m_mount_name, m_content_path)); + m_is_mounted = true; /* Set the content meta buffer. */ R_TRY(this->SetContentMetaBuffer()); /* Ensure we have a content meta buffer. */ - R_UNLESS(this->content_meta_buffer.Get() != nullptr, pgl::ResultContentMetaNotFound()); + R_UNLESS(m_content_meta_buffer.Get() != nullptr, pgl::ResultContentMetaNotFound()); return ResultSuccess(); } Result ReadProgramInfo() { /* First, read the program index. */ - R_TRY(this->GetProgramIndex(std::addressof(this->program_index))); + R_TRY(this->GetProgramIndex(std::addressof(m_program_index))); /* Next, create a key for the rest of the fields. */ - const auto key = ncm::PackagedContentMetaReader(this->content_meta_buffer.Get(), this->content_meta_buffer.GetSize()).GetKey(); + const auto key = ncm::PackagedContentMetaReader(m_content_meta_buffer.Get(), m_content_meta_buffer.GetSize()).GetKey(); /* Set fields. */ - this->program_id = {key.id}; - this->program_version = key.version; - this->content_meta_type = key.type; + m_program_id = {key.id}; + m_program_version = key.version; + m_content_meta_type = key.type; return ResultSuccess(); } Result GetContentPath(lr::Path *out, ncm::ContentType type, util::optional index) const { - switch (this->extension_type) { + switch (m_extension_type) { case ExtensionType::Nsp: return this->GetContentPathInNsp(out, type, index); case ExtensionType::Nspd: return this->GetContentPathInNspd(out, type, index); AMS_UNREACHABLE_DEFAULT_CASE(); @@ -140,24 +140,24 @@ namespace ams::pgl::srv { } ncm::ProgramId GetProgramId() const { - return this->program_id; + return m_program_id; } u32 GetProgramVersion() const { - return this->program_version; + return m_program_version; } ncm::ContentMetaType GetContentMetaType() const { - return this->content_meta_type; + return m_content_meta_type; } u8 GetProgramIndex() const { - return this->program_index; + return m_program_index; } private: Result GetContentPathInNsp(lr::Path *out, ncm::ContentType type, util::optional index) const { /* Create a reader. */ - auto reader = ncm::PackagedContentMetaReader(this->content_meta_buffer.Get(), this->content_meta_buffer.GetSize()); + auto reader = ncm::PackagedContentMetaReader(m_content_meta_buffer.Get(), m_content_meta_buffer.GetSize()); /* Get the content info. */ const ncm::PackagedContentInfo *content_info = nullptr; @@ -214,13 +214,13 @@ namespace ams::pgl::srv { Result GetProgramIndex(u8 *out) { /* Nspd programs do not have indices. */ - if (this->extension_type == ExtensionType::Nspd) { + if (m_extension_type == ExtensionType::Nspd) { *out = 0; return ResultSuccess(); } /* Create a reader. */ - auto reader = ncm::PackagedContentMetaReader(this->content_meta_buffer.Get(), this->content_meta_buffer.GetSize()); + auto reader = ncm::PackagedContentMetaReader(m_content_meta_buffer.Get(), m_content_meta_buffer.GetSize()); /* Get the program content info. */ auto program_content_info = reader.GetContentInfo(ncm::ContentType::Program); @@ -233,15 +233,15 @@ namespace ams::pgl::srv { Result SetExtensionType() { /* First, clear the suffix if the path is a program ncd. */ - if (HasSuffix(this->content_path, "program0.ncd/")) { - this->content_path[strnlen(this->content_path, sizeof(this->content_path)) - std::strlen("program0.ncd/")] = 0; + if (HasSuffix(m_content_path, "program0.ncd/")) { + m_content_path[strnlen(m_content_path, sizeof(m_content_path)) - std::strlen("program0.ncd/")] = 0; } - if (HasSuffix(this->content_path, ".nsp")) { - this->extension_type = ExtensionType::Nsp; + if (HasSuffix(m_content_path, ".nsp")) { + m_extension_type = ExtensionType::Nsp; return ResultSuccess(); - } else if (HasSuffix(this->content_path, ".nspd") || HasSuffix(this->content_path, ".nspd/")) { - this->extension_type = ExtensionType::Nspd; + } else if (HasSuffix(m_content_path, ".nspd") || HasSuffix(m_content_path, ".nspd/")) { + m_extension_type = ExtensionType::Nspd; return ResultSuccess(); } else { return fs::ResultPathNotFound(); @@ -255,7 +255,7 @@ namespace ams::pgl::srv { /* Find the Content meta path. */ bool has_content = false; lr::Path meta_path; - switch (this->extension_type) { + switch (m_extension_type) { case ExtensionType::Nsp: R_TRY(this->SearchContent(std::addressof(has_content), std::addressof(meta_path), ContentMetaFileExtension, fs::OpenDirectoryMode_File)); break; case ExtensionType::Nspd: R_TRY(this->SearchContent(std::addressof(has_content), std::addressof(meta_path), ContentMetaDirectoryExtension, fs::OpenDirectoryMode_Directory)); break; AMS_UNREACHABLE_DEFAULT_CASE(); @@ -263,13 +263,13 @@ namespace ams::pgl::srv { R_UNLESS(has_content, pgl::ResultContentMetaNotFound()); /* Read the content meta buffer. */ - return ncm::ReadContentMetaPath(std::addressof(this->content_meta_buffer), meta_path.str); + return ncm::ReadContentMetaPath(std::addressof(m_content_meta_buffer), meta_path.str); } Result SearchContent(bool *out, lr::Path *out_path, const char *extension, fs::OpenDirectoryMode mode) const { /* Generate the root directory path. */ - char root_dir[sizeof(this->mount_name) + 2]; - util::SNPrintf(root_dir, sizeof(root_dir), "%s:/", this->mount_name); + char root_dir[sizeof(m_mount_name) + 2]; + util::SNPrintf(root_dir, sizeof(root_dir), "%s:/", m_mount_name); /* Open the root directory. */ fs::DirectoryHandle dir; @@ -289,7 +289,7 @@ namespace ams::pgl::srv { if (HasSuffix(entry.name, extension)) { *out = true; if (out_path) { - const size_t len = util::SNPrintf(out_path->str, sizeof(out_path->str), "%s/%s", this->content_path, entry.name); + const size_t len = util::SNPrintf(out_path->str, sizeof(out_path->str), "%s/%s", m_content_path, entry.name); R_UNLESS(len + 1 < sizeof(out_path->str), pgl::ResultBufferNotEnough()); if (entry.type == fs::DirectoryEntryType_Directory) { out_path->str[len] = '/'; diff --git a/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp b/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp index 52205c968..c7c9de2c2 100644 --- a/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp +++ b/libraries/libstratosphere/source/pinmux/driver/board/nintendo/nx/pinmux_platform_pads.cpp @@ -206,24 +206,24 @@ namespace ams::pinmux::driver::board::nintendo::nx { class PinmuxPad { private: - u32 reg_address; - u32 reg_mask; - u32 reg_value; - u8 safe_func; - const char *pad_name; + u32 m_reg_address; + u32 m_reg_mask; + u32 m_reg_value; + u8 m_safe_func; + const char *m_pad_name; private: bool IsValidRegisterAddress() const { - return this->reg_address - 0x70003000 <= 0x2C4; + return m_reg_address - 0x70003000 <= 0x2C4; } uintptr_t GetRegisterAddress() const { - return g_apb_misc_virtual_address + (this->reg_address - 0x70000000); + return g_apb_misc_virtual_address + (m_reg_address - 0x70000000); } bool UpdateBits(u32 value, u32 offset, u32 mask) { - if ((this->reg_mask & mask) != 0) { - if ((value & (mask >> offset)) != ((this->reg_value & mask) >> offset)) { - this->reg_value = (this->reg_value & ~mask) | ((value << offset) & mask); + if ((m_reg_mask & mask) != 0) { + if ((value & (mask >> offset)) != ((m_reg_value & mask) >> offset)) { + m_reg_value = (m_reg_value & ~mask) | ((value << offset) & mask); } return true; } else { @@ -241,18 +241,18 @@ namespace ams::pinmux::driver::board::nintendo::nx { void WriteReg() const { if (this->IsValidRegisterAddress()) { - reg::Write(this->GetRegisterAddress(), this->reg_value); + reg::Write(this->GetRegisterAddress(), m_reg_value); } } bool IsLocked() const { - return (this->reg_value & PinmuxPadMask_Lock) != 0; + return (m_reg_value & PinmuxPadMask_Lock) != 0; } void UpdatePm(u8 v) { if (v != 0xFF) { if (v == PinmuxPadPm_Safe) { - v = this->safe_func; + v = m_safe_func; } this->UpdateBits(v, PinmuxPadBitOffset_Pm, PinmuxPadMask_Pm); } @@ -336,11 +336,11 @@ namespace ams::pinmux::driver::board::nintendo::nx { } } public: - constexpr PinmuxPad() : reg_address(), reg_mask(), reg_value(), safe_func(), pad_name() { /* ... */ } + constexpr PinmuxPad() : m_reg_address(), m_reg_mask(), m_reg_value(), m_safe_func(), m_pad_name() { /* ... */ } void UpdatePinmuxPad(u32 config, u32 config_mask) { /* Update register value. */ - this->reg_value = this->ReadReg(); + m_reg_value = this->ReadReg(); /* Check if we're locked. */ if (this->IsLocked()) { @@ -377,19 +377,19 @@ namespace ams::pinmux::driver::board::nintendo::nx { if (opt == PinmuxOpt_Output) { this->UpdateTristate(false); this->UpdateEInput(false); - if ((this->reg_mask & PinmuxPadMask_EOd) != 0) { + if ((m_reg_mask & PinmuxPadMask_EOd) != 0) { this->UpdateEOd(false); } } else if (opt == PinmuxOpt_Input) { this->UpdateTristate(true); this->UpdateEInput(true); - if ((this->reg_mask & PinmuxPadMask_EOd) != 0) { + if ((m_reg_mask & PinmuxPadMask_EOd) != 0) { this->UpdateEOd(false); } } else if (opt == PinmuxOpt_Bidirection) { this->UpdateTristate(false); this->UpdateEInput(true); - if ((this->reg_mask & PinmuxPadMask_EOd) != 0) { + if ((m_reg_mask & PinmuxPadMask_EOd) != 0) { this->UpdateEOd(false); } } else if (opt == PinmuxOpt_OpenDrain) { @@ -458,14 +458,14 @@ namespace ams::pinmux::driver::board::nintendo::nx { } void SetCharacter(const PinmuxPadCharacter &character) { - this->reg_address = character.reg_offset + 0x70000000; - this->reg_mask = character.reg_mask; - this->safe_func = character.safe_func; - this->reg_value = this->ReadReg(); - this->pad_name = character.pad_name; + m_reg_address = character.reg_offset + 0x70000000; + m_reg_mask = character.reg_mask; + m_safe_func = character.safe_func; + m_reg_value = this->ReadReg(); + m_pad_name = character.pad_name; - if ((this->reg_mask & this->reg_value & PinmuxPadMask_Park) != 0) { - this->reg_value &= ~(PinmuxPadMask_Park); + if ((m_reg_mask & m_reg_value & PinmuxPadMask_Park) != 0) { + m_reg_value &= ~(PinmuxPadMask_Park); } this->WriteReg(); @@ -474,23 +474,23 @@ namespace ams::pinmux::driver::board::nintendo::nx { class PinmuxDrivePad { private: - u32 reg_address; - u32 reg_mask; - u32 reg_value; - const char *pad_name; + u32 m_reg_address; + u32 m_reg_mask; + u32 m_reg_value; + const char *m_pad_name; private: bool IsValidRegisterAddress() const { - return this->reg_address - 0x700008E4 <= 0x288; + return m_reg_address - 0x700008E4 <= 0x288; } uintptr_t GetRegisterAddress() const { - return g_apb_misc_virtual_address + (this->reg_address - 0x70000000); + return g_apb_misc_virtual_address + (m_reg_address - 0x70000000); } bool UpdateBits(u32 value, u32 offset, u32 mask) { - if ((this->reg_mask & mask) != 0) { - if ((value & (mask >> offset)) != ((this->reg_value & mask) >> offset)) { - this->reg_value = (this->reg_value & ~mask) | ((value << offset) & mask); + if ((m_reg_mask & mask) != 0) { + if ((value & (mask >> offset)) != ((m_reg_value & mask) >> offset)) { + m_reg_value = (m_reg_value & ~mask) | ((value << offset) & mask); } return true; } else { @@ -508,16 +508,16 @@ namespace ams::pinmux::driver::board::nintendo::nx { void WriteReg() const { if (this->IsValidRegisterAddress()) { - reg::Write(this->GetRegisterAddress(), this->reg_value); + reg::Write(this->GetRegisterAddress(), m_reg_value); } } bool IsCzDrvDn() const { - return (this->reg_mask & PinmuxDrivePadMask_CzDrvDn) == PinmuxDrivePadMask_CzDrvDn; + return (m_reg_mask & PinmuxDrivePadMask_CzDrvDn) == PinmuxDrivePadMask_CzDrvDn; } bool IsCzDrvUp() const { - return (this->reg_mask & PinmuxDrivePadMask_CzDrvUp) == PinmuxDrivePadMask_CzDrvUp; + return (m_reg_mask & PinmuxDrivePadMask_CzDrvUp) == PinmuxDrivePadMask_CzDrvUp; } void UpdateDrvDn(u8 v) { @@ -556,11 +556,11 @@ namespace ams::pinmux::driver::board::nintendo::nx { } } public: - constexpr PinmuxDrivePad() : reg_address(), reg_mask(), reg_value(), pad_name() { /* ... */ } + constexpr PinmuxDrivePad() : m_reg_address(), m_reg_mask(), m_reg_value(), m_pad_name() { /* ... */ } void UpdatePinmuxDrivePad(u32 config, u32 config_mask) { /* Update register value. */ - this->reg_value = this->ReadReg(); + m_reg_value = this->ReadReg(); /* Update drvdn. */ if ((config_mask & PinmuxDriveOptBitMask_DrvDn) != 0) { @@ -601,10 +601,10 @@ namespace ams::pinmux::driver::board::nintendo::nx { } void SetCharacter(const PinmuxDrivePadCharacter &character) { - this->reg_address = character.reg_offset + 0x70000000; - this->reg_mask = character.reg_mask; - this->reg_value = this->ReadReg(); - this->pad_name = character.pad_name; + m_reg_address = character.reg_offset + 0x70000000; + m_reg_mask = character.reg_mask; + m_reg_value = this->ReadReg(); + m_pad_name = character.pad_name; } }; diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp index 875af198f..5171c976d 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.cpp @@ -45,16 +45,16 @@ namespace ams::powctl::impl::board::nintendo::nx { } - BatteryDevice::BatteryDevice(bool ev) : use_event_handler(ev), event_handler() { - if (this->use_event_handler) { + BatteryDevice::BatteryDevice(bool ev) : m_use_event_handler(ev), m_event_handler() { + if (m_use_event_handler) { /* Create the system event. */ - os::CreateSystemEvent(std::addressof(this->system_event), os::EventClearMode_ManualClear, true); + os::CreateSystemEvent(std::addressof(m_system_event), os::EventClearMode_ManualClear, true); /* Create the handler. */ - this->event_handler.emplace(this); + m_event_handler.emplace(this); /* Register the event handler. */ - powctl::impl::RegisterInterruptHandler(std::addressof(*this->event_handler)); + powctl::impl::RegisterInterruptHandler(std::addressof(*m_event_handler)); } } diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp index cc9bf4763..a8a963f75 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_battery_driver.hpp @@ -25,17 +25,17 @@ namespace ams::powctl::impl::board::nintendo::nx { NON_MOVEABLE(BatteryDevice); AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::BatteryDevice, ::ams::powctl::impl::IDevice); private: - bool use_event_handler; - util::optional event_handler; - os::SystemEventType system_event; + bool m_use_event_handler; + util::optional m_event_handler; + os::SystemEventType m_system_event; public: BatteryDevice(bool ev); - os::SystemEventType *GetSystemEvent() { return std::addressof(this->system_event); } + os::SystemEventType *GetSystemEvent() { return std::addressof(m_system_event); } void SetInterruptEnabled(bool en) { - if (this->use_event_handler) { - this->event_handler->SetInterruptEnabled(en); + if (m_use_event_handler) { + m_event_handler->SetInterruptEnabled(en); } } }; diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp index f26544b9a..57e4fc878 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.cpp @@ -267,25 +267,25 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetPreChargeCurrentLimit(int ma) { - return ReadWriteRegister(this->i2c_session, bq24193::PreChargeTerminationCurrentControl, 0xF0, bq24193::EncodePreChargeCurrentLimit(ma)); + return ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0xF0, bq24193::EncodePreChargeCurrentLimit(ma)); } Result Bq24193Driver::SetTerminationCurrentLimit(int ma) { - return ReadWriteRegister(this->i2c_session, bq24193::PreChargeTerminationCurrentControl, 0x0F, bq24193::EncodeTerminationCurrentLimit(ma)); + return ReadWriteRegister(m_i2c_session, bq24193::PreChargeTerminationCurrentControl, 0x0F, bq24193::EncodeTerminationCurrentLimit(ma)); } Result Bq24193Driver::SetMinimumSystemVoltageLimit(int mv) { - return ReadWriteRegister(this->i2c_session, bq24193::PowerOnConfiguration, 0x0E, bq24193::EncodeMinimumSystemVoltageLimit(mv)); + return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x0E, bq24193::EncodeMinimumSystemVoltageLimit(mv)); } Result Bq24193Driver::SetChargingSafetyTimerEnabled(bool en) { - return ReadWriteRegister(this->i2c_session, bq24193::ChargeTerminationTimerControl, 0x08, en ? 0x08 : 0x00); + return ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x08, en ? 0x08 : 0x00); } Result Bq24193Driver::GetForce20PercentChargeCurrent(bool *out) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::ChargeCurrentControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::ChargeCurrentControl, std::addressof(val))); /* Extract the value. */ *out = (val & 0x01) != 0; @@ -293,13 +293,13 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetForce20PercentChargeCurrent(bool en) { - return ReadWriteRegister(this->i2c_session, bq24193::ChargeCurrentControl, 0x01, en ? 0x01 : 0x00); + return ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0x01, en ? 0x01 : 0x00); } Result Bq24193Driver::GetFastChargeCurrentLimit(int *out_ma) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::ChargeCurrentControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::ChargeCurrentControl, std::addressof(val))); /* Extract the value. */ *out_ma = bq24193::DecodeFastChargeCurrentLimit(val); @@ -307,13 +307,13 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetFastChargeCurrentLimit(int ma) { - return ReadWriteRegister(this->i2c_session, bq24193::ChargeCurrentControl, 0xFC, bq24193::EncodeFastChargeCurrentLimit(ma)); + return ReadWriteRegister(m_i2c_session, bq24193::ChargeCurrentControl, 0xFC, bq24193::EncodeFastChargeCurrentLimit(ma)); } Result Bq24193Driver::GetChargeVoltageLimit(int *out_mv) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::ChargeVoltageControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::ChargeVoltageControl, std::addressof(val))); /* Extract the value. */ *out_mv = bq24193::DecodeChargeVoltageLimit(val); @@ -321,17 +321,17 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetChargeVoltageLimit(int mv) { - return ReadWriteRegister(this->i2c_session, bq24193::ChargeVoltageControl, 0xFC, bq24193::EncodeChargeVoltageLimit(mv)); + return ReadWriteRegister(m_i2c_session, bq24193::ChargeVoltageControl, 0xFC, bq24193::EncodeChargeVoltageLimit(mv)); } Result Bq24193Driver::SetChargerConfiguration(bq24193::ChargerConfiguration cfg) { - return ReadWriteRegister(this->i2c_session, bq24193::PowerOnConfiguration, 0x30, bq24193::EncodeChargerConfiguration(cfg)); + return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x30, bq24193::EncodeChargerConfiguration(cfg)); } Result Bq24193Driver::IsHiZEnabled(bool *out) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::InputSourceControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::InputSourceControl, std::addressof(val))); /* Extract the value. */ *out = (val & 0x80) != 0; @@ -339,13 +339,13 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetHiZEnabled(bool en) { - return ReadWriteRegister(this->i2c_session, bq24193::InputSourceControl, 0x80, en ? 0x80 : 0x00); + return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x80, en ? 0x80 : 0x00); } Result Bq24193Driver::GetInputCurrentLimit(int *out_ma) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::InputSourceControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::InputSourceControl, std::addressof(val))); /* Extract the value. */ *out_ma = bq24193::DecodeInputCurrentLimit(val); @@ -353,21 +353,21 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetInputCurrentLimit(int ma) { - return ReadWriteRegister(this->i2c_session, bq24193::InputSourceControl, 0x07, bq24193::EncodeInputCurrentLimit(ma)); + return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x07, bq24193::EncodeInputCurrentLimit(ma)); } Result Bq24193Driver::SetInputVoltageLimit(int mv) { - return ReadWriteRegister(this->i2c_session, bq24193::InputSourceControl, 0x78, bq24193::EncodeInputVoltageLimit(mv)); + return ReadWriteRegister(m_i2c_session, bq24193::InputSourceControl, 0x78, bq24193::EncodeInputVoltageLimit(mv)); } Result Bq24193Driver::SetBoostModeCurrentLimit(int ma) { - return ReadWriteRegister(this->i2c_session, bq24193::PowerOnConfiguration, 0x01, bq24193::EncodeBoostModeCurrentLimit(ma)); + return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x01, bq24193::EncodeBoostModeCurrentLimit(ma)); } Result Bq24193Driver::GetChargerStatus(bq24193::ChargerStatus *out) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::SystemStatus, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::SystemStatus, std::addressof(val))); /* Extract the value. */ *out = bq24193::DecodeChargerStatus(val); @@ -375,17 +375,17 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::ResetWatchdogTimer() { - return ReadWriteRegister(this->i2c_session, bq24193::PowerOnConfiguration, 0x40, 0x40); + return ReadWriteRegister(m_i2c_session, bq24193::PowerOnConfiguration, 0x40, 0x40); } Result Bq24193Driver::SetWatchdogTimerSetting(int seconds) { - return ReadWriteRegister(this->i2c_session, bq24193::ChargeTerminationTimerControl, 0x30, bq24193::EncodeWatchdogTimerSetting(seconds)); + return ReadWriteRegister(m_i2c_session, bq24193::ChargeTerminationTimerControl, 0x30, bq24193::EncodeWatchdogTimerSetting(seconds)); } Result Bq24193Driver::GetBatteryCompensation(int *out_mo) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::IrCompensationThermalRegulationControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, std::addressof(val))); /* Extract the value. */ *out_mo = bq24193::DecodeBatteryCompensation(val); @@ -393,13 +393,13 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetBatteryCompensation(int mo) { - return ReadWriteRegister(this->i2c_session, bq24193::IrCompensationThermalRegulationControl, 0xE0, bq24193::EncodeBatteryCompensation(mo)); + return ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0xE0, bq24193::EncodeBatteryCompensation(mo)); } Result Bq24193Driver::GetVoltageClamp(int *out_mv) { /* Get the register. */ u8 val; - R_TRY(i2c::ReadSingleRegister(this->i2c_session, bq24193::IrCompensationThermalRegulationControl, std::addressof(val))); + R_TRY(i2c::ReadSingleRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, std::addressof(val))); /* Extract the value. */ *out_mv = bq24193::DecodeVoltageClamp(val); @@ -407,7 +407,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Bq24193Driver::SetVoltageClamp(int mv) { - return ReadWriteRegister(this->i2c_session, bq24193::IrCompensationThermalRegulationControl, 0x1C, bq24193::EncodeVoltageClamp(mv)); + return ReadWriteRegister(m_i2c_session, bq24193::IrCompensationThermalRegulationControl, 0x1C, bq24193::EncodeVoltageClamp(mv)); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.hpp index 886d0e7b5..6b684ef0d 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_bq24193_driver.hpp @@ -37,24 +37,24 @@ namespace ams::powctl::impl::board::nintendo::nx { class Bq24193Driver { private: - os::SdkMutex mutex; - int init_count; - i2c::I2cSession i2c_session; + os::SdkMutex m_mutex; + int m_init_count; + i2c::I2cSession m_i2c_session; private: Result InitializeSession(); public: - Bq24193Driver() : mutex(), init_count(0), i2c_session() { + Bq24193Driver() : m_mutex(), m_init_count(0), m_i2c_session() { /* ... */ } void Initialize() { - std::scoped_lock lk(this->mutex); - if ((this->init_count++) == 0) { + std::scoped_lock lk(m_mutex); + if ((m_init_count++) == 0) { /* Initialize i2c library. */ i2c::InitializeEmpty(); /* Open session. */ - R_ABORT_UNLESS(i2c::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Bq24193)); + R_ABORT_UNLESS(i2c::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Bq24193)); /* Initialize session. */ R_ABORT_UNLESS(this->InitializeSession()); @@ -62,10 +62,10 @@ namespace ams::powctl::impl::board::nintendo::nx { } void Finalize() { - std::scoped_lock lk(this->mutex); - if ((--this->init_count) == 0) { + std::scoped_lock lk(m_mutex); + if ((--m_init_count) == 0) { /* Close session. */ - i2c::CloseSession(this->i2c_session); + i2c::CloseSession(m_i2c_session); /* Finalize i2c library. */ i2c::Finalize(); diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp index ca8461447..25e25a085 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.cpp @@ -43,16 +43,16 @@ namespace ams::powctl::impl::board::nintendo::nx { } - ChargerDevice::ChargerDevice(bool ev) : gpio_pad_session(), watchdog_timer_enabled(false), watchdog_timer_timeout(0), use_event_handler(ev), event_handler() { - if (this->use_event_handler) { + ChargerDevice::ChargerDevice(bool ev) : m_gpio_pad_session(), m_watchdog_timer_enabled(false), m_watchdog_timer_timeout(0), m_use_event_handler(ev), m_event_handler() { + if (m_use_event_handler) { /* Create the system event. */ - os::CreateSystemEvent(std::addressof(this->system_event), os::EventClearMode_ManualClear, true); + os::CreateSystemEvent(std::addressof(m_system_event), os::EventClearMode_ManualClear, true); /* Create the handler. */ - this->event_handler.emplace(this); + m_event_handler.emplace(this); /* Register the event handler. */ - powctl::impl::RegisterInterruptHandler(std::addressof(*this->event_handler)); + powctl::impl::RegisterInterruptHandler(std::addressof(*m_event_handler)); } } diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp index a876a1a82..588dc28e5 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_charger_driver.hpp @@ -25,28 +25,28 @@ namespace ams::powctl::impl::board::nintendo::nx { NON_MOVEABLE(ChargerDevice); AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::board::nintendo::nx::ChargerDevice, ::ams::powctl::impl::IDevice); private: - gpio::GpioPadSession gpio_pad_session; - bool watchdog_timer_enabled; - TimeSpan watchdog_timer_timeout; - bool use_event_handler; - util::optional event_handler; - os::SystemEventType system_event; + gpio::GpioPadSession m_gpio_pad_session; + bool m_watchdog_timer_enabled; + TimeSpan m_watchdog_timer_timeout; + bool m_use_event_handler; + util::optional m_event_handler; + os::SystemEventType m_system_event; public: ChargerDevice(bool ev); - bool IsWatchdogTimerEnabled() const { return this->watchdog_timer_enabled; } - void SetWatchdogTimerEnabled(bool en) { this->watchdog_timer_enabled = en; } + bool IsWatchdogTimerEnabled() const { return m_watchdog_timer_enabled; } + void SetWatchdogTimerEnabled(bool en) { m_watchdog_timer_enabled = en; } - TimeSpan GetWatchdogTimerTimeout() const { return this->watchdog_timer_timeout; } - void SetWatchdogTimerTimeout(TimeSpan ts) { this->watchdog_timer_timeout = ts; } + TimeSpan GetWatchdogTimerTimeout() const { return m_watchdog_timer_timeout; } + void SetWatchdogTimerTimeout(TimeSpan ts) { m_watchdog_timer_timeout = ts; } - gpio::GpioPadSession *GetPadSession() { return std::addressof(this->gpio_pad_session); } + gpio::GpioPadSession *GetPadSession() { return std::addressof(m_gpio_pad_session); } - os::SystemEventType *GetSystemEvent() { return std::addressof(this->system_event); } + os::SystemEventType *GetSystemEvent() { return std::addressof(m_system_event); } void SetInterruptEnabled(bool en) { - if (this->use_event_handler) { - this->event_handler->SetInterruptEnabled(en); + if (m_use_event_handler) { + m_event_handler->SetInterruptEnabled(en); } } }; diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_interrupt_event_handler.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_interrupt_event_handler.hpp index db4e17a4b..3c6d0c438 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_interrupt_event_handler.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_interrupt_event_handler.hpp @@ -22,41 +22,41 @@ namespace ams::powctl::impl::board::nintendo::nx { template class InterruptEventHandler : public ddsf::IEventHandler { private: - IDevice *device; - gpio::GpioPadSession gpio_session; - os::SystemEventType gpio_system_event; - os::SdkMutex mutex; + IDevice *m_device; + gpio::GpioPadSession m_gpio_session; + os::SystemEventType m_gpio_system_event; + os::SdkMutex m_mutex; public: - InterruptEventHandler(IDevice *dv) : IEventHandler(), device(dv), mutex() { + InterruptEventHandler(IDevice *dv) : IEventHandler(), m_device(dv), m_mutex() { /* Initialize the gpio session. */ - Derived::Initialize(std::addressof(this->gpio_session), std::addressof(this->gpio_system_event)); + Derived::Initialize(std::addressof(m_gpio_session), std::addressof(m_gpio_system_event)); /* Initialize ourselves as an event handler. */ - IEventHandler::Initialize(std::addressof(this->gpio_system_event)); + IEventHandler::Initialize(std::addressof(m_gpio_system_event)); } os::SystemEventType *GetSystemEvent() { - return std::addressof(this->gpio_system_event); + return std::addressof(m_gpio_system_event); } void SetInterruptEnabled(bool en) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - gpio::SetInterruptEnable(std::addressof(this->gpio_session), en); + gpio::SetInterruptEnable(std::addressof(m_gpio_session), en); } virtual void HandleEvent() override final { /* Acquire exclusive access to ourselves. */ - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); /* Clear our interrupt status. */ - gpio::ClearInterruptStatus(std::addressof(this->gpio_session)); + gpio::ClearInterruptStatus(std::addressof(m_gpio_session)); /* Clear our system event. */ - os::ClearSystemEvent(std::addressof(this->gpio_system_event)); + os::ClearSystemEvent(std::addressof(m_gpio_system_event)); /* Signal the event. */ - static_cast(this)->SignalEvent(this->device); + static_cast(this)->SignalEvent(m_device); } }; diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp index 0068bb11a..24efcad04 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.cpp @@ -255,22 +255,22 @@ namespace ams::powctl::impl::board::nintendo::nx { os::SleepThread(TimeSpan::FromMilliSeconds(500)); /* Write initial config. */ - R_TRY(WriteRegister(this->i2c_session, max17050::Config, 0x7210)); + R_TRY(WriteRegister(m_i2c_session, max17050::Config, 0x7210)); /* Write initial filter config. */ - R_TRY(WriteRegister(this->i2c_session, max17050::FilterCfg, 0x8784)); + R_TRY(WriteRegister(m_i2c_session, max17050::FilterCfg, 0x8784)); /* Write relax config. */ - R_TRY(WriteRegister(this->i2c_session, max17050::RelaxCfg, params.relaxcfg)); + R_TRY(WriteRegister(m_i2c_session, max17050::RelaxCfg, params.relaxcfg)); /* Write initial learn config. */ - R_TRY(WriteRegister(this->i2c_session, max17050::LearnCfg, 0x2603)); + R_TRY(WriteRegister(m_i2c_session, max17050::LearnCfg, 0x2603)); /* Write fullsocthr. */ - R_TRY(WriteRegister(this->i2c_session, max17050::FullSocThr, params.fullsocthr)); + R_TRY(WriteRegister(m_i2c_session, max17050::FullSocThr, params.fullsocthr)); /* Write iavgempty. */ - R_TRY(WriteRegister(this->i2c_session, max17050::IAvgEmpty, params.iavgempty)); + R_TRY(WriteRegister(m_i2c_session, max17050::IAvgEmpty, params.iavgempty)); /* Unlock model table, write model table. */ do { @@ -295,33 +295,33 @@ namespace ams::powctl::impl::board::nintendo::nx { } /* Write and validate rcomp0 */ - while (!WriteValidateRegister(this->i2c_session, max17050::RComp0, params.rcomp0)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::RComp0, params.rcomp0)) { /* ... */ } /* Write and validate tempco */ - while (!WriteValidateRegister(this->i2c_session, max17050::TempCo, params.tempco)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::TempCo, params.tempco)) { /* ... */ } /* Write ichgterm. */ - R_TRY(WriteRegister(this->i2c_session, max17050::IChgTerm, params.ichgterm)); + R_TRY(WriteRegister(m_i2c_session, max17050::IChgTerm, params.ichgterm)); /* Write tgain. */ - R_TRY(WriteRegister(this->i2c_session, max17050::TGain, params.tgain)); + R_TRY(WriteRegister(m_i2c_session, max17050::TGain, params.tgain)); /* Write toff. */ - R_TRY(WriteRegister(this->i2c_session, max17050::TOff, params.toff)); + R_TRY(WriteRegister(m_i2c_session, max17050::TOff, params.toff)); /* Write and validate vempty. */ - while (!WriteValidateRegister(this->i2c_session, max17050::VEmpty, params.vempty)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::VEmpty, params.vempty)) { /* ... */ } /* Write and validate qresidual. */ - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual00, params.qresidual00)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual10, params.qresidual10)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual20, params.qresidual20)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual30, params.qresidual30)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual00, params.qresidual00)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual10, params.qresidual10)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual20, params.qresidual20)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual30, params.qresidual30)) { /* ... */ } /* Write capacity parameters. */ - while (!WriteValidateRegister(this->i2c_session, max17050::FullCap, params.fullcap)) { /* ... */ } - R_TRY(WriteRegister(this->i2c_session, max17050::DesignCap, params.vffullcap)); - while (!WriteValidateRegister(this->i2c_session, max17050::FullCapNom, params.vffullcap)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::FullCap, params.fullcap)) { /* ... */ } + R_TRY(WriteRegister(m_i2c_session, max17050::DesignCap, params.vffullcap)); + while (!WriteValidateRegister(m_i2c_session, max17050::FullCapNom, params.vffullcap)) { /* ... */ } /* Give some time for configuration to take. */ os::SleepThread(TimeSpan::FromMilliSeconds(350)); @@ -329,81 +329,81 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Write vfsoc to vfsoc0, qh, to qh0. */ u16 vfsoc, qh; { - R_TRY(ReadRegister(this->i2c_session, max17050::SocVf, std::addressof(vfsoc))); + R_TRY(ReadRegister(m_i2c_session, max17050::SocVf, std::addressof(vfsoc))); R_TRY(this->UnlockVfSoc()); - while (!WriteValidateRegister(this->i2c_session, max17050::SocVf0, vfsoc)) { /* ... */ } - R_TRY(ReadRegister(this->i2c_session, max17050::Qh, std::addressof(qh))); - R_TRY(WriteRegister(this->i2c_session, max17050::Qh0, qh)); + while (!WriteValidateRegister(m_i2c_session, max17050::SocVf0, vfsoc)) { /* ... */ } + R_TRY(ReadRegister(m_i2c_session, max17050::Qh, std::addressof(qh))); + R_TRY(WriteRegister(m_i2c_session, max17050::Qh0, qh)); R_TRY(this->LockVfSoc()); } /* Reset cycles. */ - while (!WriteValidateRegister(this->i2c_session, max17050::Cycles, 0x0060)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::Cycles, 0x0060)) { /* ... */ } /* Load new capacity parameters. */ const u16 remcap = static_cast((vfsoc * params.vffullcap) / 0x6400); const u16 repcap = static_cast(remcap * (params.fullcap / params.vffullcap)); const u16 dpacc = 0x0C80; const u16 dqacc = params.vffullcap / 0x10; - while (!WriteValidateRegister(this->i2c_session, max17050::RemCapMix, remcap)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::RemCapRep, repcap)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::DPAcc, dpacc)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::DQAcc, dqacc)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::RemCapMix, remcap)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::RemCapRep, repcap)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::DPAcc, dpacc)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::DQAcc, dqacc)) { /* ... */ } /* Write capacity parameters. */ - while (!WriteValidateRegister(this->i2c_session, max17050::FullCap, params.fullcap)) { /* ... */ } - R_TRY(WriteRegister(this->i2c_session, max17050::DesignCap, params.vffullcap)); - while (!WriteValidateRegister(this->i2c_session, max17050::FullCapNom, params.vffullcap)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::FullCap, params.fullcap)) { /* ... */ } + R_TRY(WriteRegister(m_i2c_session, max17050::DesignCap, params.vffullcap)); + while (!WriteValidateRegister(m_i2c_session, max17050::FullCapNom, params.vffullcap)) { /* ... */ } /* Write soc rep. */ - R_TRY(WriteRegister(this->i2c_session, max17050::SocRep, vfsoc)); + R_TRY(WriteRegister(m_i2c_session, max17050::SocRep, vfsoc)); /* Clear power on reset. */ - R_TRY(ReadWriteValidateRegister(this->i2c_session, max17050::Status, 0x0002, 0x0000)); + R_TRY(ReadWriteValidateRegister(m_i2c_session, max17050::Status, 0x0002, 0x0000)); /* Set cgain. */ - R_TRY(WriteRegister(this->i2c_session, max17050::CGain, 0x7FFF)); + R_TRY(WriteRegister(m_i2c_session, max17050::CGain, 0x7FFF)); return ResultSuccess(); } Result Max17050Driver::SetMaximumShutdownTimerThreshold() { - return WriteRegister(this->i2c_session, max17050::ShdnTimer, 0xE000); + return WriteRegister(m_i2c_session, max17050::ShdnTimer, 0xE000); } bool Max17050Driver::IsPowerOnReset() { /* Get the register. */ u16 val; - R_ABORT_UNLESS(ReadRegister(this->i2c_session, max17050::Status, std::addressof(val))); + R_ABORT_UNLESS(ReadRegister(m_i2c_session, max17050::Status, std::addressof(val))); /* Extract the value. */ return (val & 0x0002) != 0; } Result Max17050Driver::LockVfSoc() { - return WriteRegister(this->i2c_session, max17050::SocVfAccess, 0x0000); + return WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0000); } Result Max17050Driver::UnlockVfSoc() { - return WriteRegister(this->i2c_session, max17050::SocVfAccess, 0x0080); + return WriteRegister(m_i2c_session, max17050::SocVfAccess, 0x0080); } Result Max17050Driver::LockModelTable() { - R_TRY(WriteRegister(this->i2c_session, max17050::ModelAccess0, 0x0000)); - R_TRY(WriteRegister(this->i2c_session, max17050::ModelAccess1, 0x0000)); + R_TRY(WriteRegister(m_i2c_session, max17050::ModelAccess0, 0x0000)); + R_TRY(WriteRegister(m_i2c_session, max17050::ModelAccess1, 0x0000)); return ResultSuccess(); } Result Max17050Driver::UnlockModelTable() { - R_TRY(WriteRegister(this->i2c_session, max17050::ModelAccess0, 0x0059)); - R_TRY(WriteRegister(this->i2c_session, max17050::ModelAccess1, 0x00C4)); + R_TRY(WriteRegister(m_i2c_session, max17050::ModelAccess0, 0x0059)); + R_TRY(WriteRegister(m_i2c_session, max17050::ModelAccess1, 0x00C4)); return ResultSuccess(); } bool Max17050Driver::IsModelTableLocked() { for (size_t i = 0; i < max17050::ModelChrTblSize; ++i) { u16 val; - R_ABORT_UNLESS(ReadRegister(this->i2c_session, max17050::ModelChrTblStart + i, std::addressof(val))); + R_ABORT_UNLESS(ReadRegister(m_i2c_session, max17050::ModelChrTblStart + i, std::addressof(val))); if (val != 0) { return false; @@ -415,7 +415,7 @@ namespace ams::powctl::impl::board::nintendo::nx { Result Max17050Driver::SetModelTable(const u16 *model_table) { for (size_t i = 0; i < max17050::ModelChrTblSize; ++i) { - R_TRY(WriteRegister(this->i2c_session, max17050::ModelChrTblStart + i, model_table[i])); + R_TRY(WriteRegister(m_i2c_session, max17050::ModelChrTblStart + i, model_table[i])); } return ResultSuccess(); @@ -424,7 +424,7 @@ namespace ams::powctl::impl::board::nintendo::nx { bool Max17050Driver::IsModelTableSet(const u16 *model_table) { for (size_t i = 0; i < max17050::ModelChrTblSize; ++i) { u16 val; - R_ABORT_UNLESS(ReadRegister(this->i2c_session, max17050::ModelChrTblStart + i, std::addressof(val))); + R_ABORT_UNLESS(ReadRegister(m_i2c_session, max17050::ModelChrTblStart + i, std::addressof(val))); if (val != model_table[i]) { return false; @@ -435,45 +435,45 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::ReadInternalState() { - R_TRY(ReadRegister(this->i2c_session, max17050::RComp0, std::addressof(this->internal_state.rcomp0))); - R_TRY(ReadRegister(this->i2c_session, max17050::TempCo, std::addressof(this->internal_state.tempco))); - R_TRY(ReadRegister(this->i2c_session, max17050::FullCap, std::addressof(this->internal_state.fullcap))); - R_TRY(ReadRegister(this->i2c_session, max17050::Cycles, std::addressof(this->internal_state.cycles))); - R_TRY(ReadRegister(this->i2c_session, max17050::FullCapNom, std::addressof(this->internal_state.fullcapnom))); - R_TRY(ReadRegister(this->i2c_session, max17050::IAvgEmpty, std::addressof(this->internal_state.iavgempty))); - R_TRY(ReadRegister(this->i2c_session, max17050::QResidual00, std::addressof(this->internal_state.qresidual00))); - R_TRY(ReadRegister(this->i2c_session, max17050::QResidual10, std::addressof(this->internal_state.qresidual10))); - R_TRY(ReadRegister(this->i2c_session, max17050::QResidual20, std::addressof(this->internal_state.qresidual20))); - R_TRY(ReadRegister(this->i2c_session, max17050::QResidual30, std::addressof(this->internal_state.qresidual30))); + R_TRY(ReadRegister(m_i2c_session, max17050::RComp0, std::addressof(m_internal_state.rcomp0))); + R_TRY(ReadRegister(m_i2c_session, max17050::TempCo, std::addressof(m_internal_state.tempco))); + R_TRY(ReadRegister(m_i2c_session, max17050::FullCap, std::addressof(m_internal_state.fullcap))); + R_TRY(ReadRegister(m_i2c_session, max17050::Cycles, std::addressof(m_internal_state.cycles))); + R_TRY(ReadRegister(m_i2c_session, max17050::FullCapNom, std::addressof(m_internal_state.fullcapnom))); + R_TRY(ReadRegister(m_i2c_session, max17050::IAvgEmpty, std::addressof(m_internal_state.iavgempty))); + R_TRY(ReadRegister(m_i2c_session, max17050::QResidual00, std::addressof(m_internal_state.qresidual00))); + R_TRY(ReadRegister(m_i2c_session, max17050::QResidual10, std::addressof(m_internal_state.qresidual10))); + R_TRY(ReadRegister(m_i2c_session, max17050::QResidual20, std::addressof(m_internal_state.qresidual20))); + R_TRY(ReadRegister(m_i2c_session, max17050::QResidual30, std::addressof(m_internal_state.qresidual30))); return ResultSuccess(); } Result Max17050Driver::WriteInternalState() { - while (!WriteValidateRegister(this->i2c_session, max17050::RComp0, this->internal_state.rcomp0)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::TempCo, this->internal_state.tempco)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::FullCapNom, this->internal_state.fullcapnom)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::IAvgEmpty, this->internal_state.iavgempty)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual00, this->internal_state.qresidual00)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual10, this->internal_state.qresidual10)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual20, this->internal_state.qresidual20)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::QResidual30, this->internal_state.qresidual30)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::RComp0, m_internal_state.rcomp0)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::TempCo, m_internal_state.tempco)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::FullCapNom, m_internal_state.fullcapnom)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::IAvgEmpty, m_internal_state.iavgempty)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual00, m_internal_state.qresidual00)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual10, m_internal_state.qresidual10)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual20, m_internal_state.qresidual20)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::QResidual30, m_internal_state.qresidual30)) { /* ... */ } os::SleepThread(TimeSpan::FromMilliSeconds(350)); u16 fullcap0, socmix; - R_TRY(ReadRegister(this->i2c_session, max17050::FullCap0, std::addressof(fullcap0))); - R_TRY(ReadRegister(this->i2c_session, max17050::SocMix, std::addressof(socmix))); + R_TRY(ReadRegister(m_i2c_session, max17050::FullCap0, std::addressof(fullcap0))); + R_TRY(ReadRegister(m_i2c_session, max17050::SocMix, std::addressof(socmix))); - while (!WriteValidateRegister(this->i2c_session, max17050::RemCapMix, static_cast((fullcap0 * socmix) / 0x6400))) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::FullCap, this->internal_state.fullcap)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::DPAcc, 0x0C80)) { /* ... */ } - while (!WriteValidateRegister(this->i2c_session, max17050::DQAcc, this->internal_state.fullcapnom / 0x10)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::RemCapMix, static_cast((fullcap0 * socmix) / 0x6400))) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::FullCap, m_internal_state.fullcap)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::DPAcc, 0x0C80)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::DQAcc, m_internal_state.fullcapnom / 0x10)) { /* ... */ } os::SleepThread(TimeSpan::FromMilliSeconds(350)); - while (!WriteValidateRegister(this->i2c_session, max17050::Cycles, this->internal_state.cycles)) { /* ... */ } - if (this->internal_state.cycles >= 0x100) { - while (!WriteValidateRegister(this->i2c_session, max17050::LearnCfg, 0x2673)) { /* ... */ } + while (!WriteValidateRegister(m_i2c_session, max17050::Cycles, m_internal_state.cycles)) { /* ... */ } + if (m_internal_state.cycles >= 0x100) { + while (!WriteValidateRegister(m_i2c_session, max17050::LearnCfg, 0x2673)) { /* ... */ } } return ResultSuccess(); @@ -485,7 +485,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::SocRep, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::SocRep, std::addressof(val))); /* Set output. */ *out = static_cast(val) * 0.00390625; @@ -498,7 +498,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::SocVf, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::SocVf, std::addressof(val))); /* Set output. */ *out = static_cast(val) * 0.00390625; @@ -512,8 +512,8 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the values. */ u16 cgain, fullcap; - R_TRY(ReadRegister(this->i2c_session, max17050::CGain, std::addressof(cgain))); - R_TRY(ReadRegister(this->i2c_session, max17050::FullCap, std::addressof(fullcap))); + R_TRY(ReadRegister(m_i2c_session, max17050::CGain, std::addressof(cgain))); + R_TRY(ReadRegister(m_i2c_session, max17050::FullCap, std::addressof(fullcap))); /* Set output. */ *out = ((static_cast(fullcap) * 0.005) / sense_resistor) / (static_cast(cgain) * 0.0000610351562); @@ -527,8 +527,8 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the values. */ u16 cgain, remcap; - R_TRY(ReadRegister(this->i2c_session, max17050::CGain, std::addressof(cgain))); - R_TRY(ReadRegister(this->i2c_session, max17050::RemCapRep, std::addressof(remcap))); + R_TRY(ReadRegister(m_i2c_session, max17050::CGain, std::addressof(cgain))); + R_TRY(ReadRegister(m_i2c_session, max17050::RemCapRep, std::addressof(remcap))); /* Set output. */ *out = ((static_cast(remcap) * 0.005) / sense_resistor) / (static_cast(cgain) * 0.0000610351562); @@ -536,11 +536,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetPercentageMinimumAlertThreshold(int percentage) { - return ReadWriteRegister(this->i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage)); + return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0x00FF, static_cast(percentage)); } Result Max17050Driver::SetPercentageMaximumAlertThreshold(int percentage) { - return ReadWriteRegister(this->i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8); + return ReadWriteRegister(m_i2c_session, max17050::SocAlrtThreshold, 0xFF00, static_cast(static_cast(percentage)) << 8); } Result Max17050Driver::SetPercentageFullThreshold(double percentage) { @@ -550,7 +550,7 @@ namespace ams::powctl::impl::board::nintendo::nx { #error "Unknown architecture for floating point -> fixed point" #endif - return WriteRegister(this->i2c_session, max17050::FullSocThr, val); + return WriteRegister(m_i2c_session, max17050::FullSocThr, val); } Result Max17050Driver::GetAverageCurrent(double *out, double sense_resistor) { @@ -560,9 +560,9 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the values. */ u16 cgain, coff, avg_current; - R_TRY(ReadRegister(this->i2c_session, max17050::CGain, std::addressof(cgain))); - R_TRY(ReadRegister(this->i2c_session, max17050::COff, std::addressof(coff))); - R_TRY(ReadRegister(this->i2c_session, max17050::AverageCurrent, std::addressof(avg_current))); + R_TRY(ReadRegister(m_i2c_session, max17050::CGain, std::addressof(cgain))); + R_TRY(ReadRegister(m_i2c_session, max17050::COff, std::addressof(coff))); + R_TRY(ReadRegister(m_i2c_session, max17050::AverageCurrent, std::addressof(avg_current))); /* Set output. */ *out = (((static_cast(avg_current) - (static_cast(coff) + static_cast(coff))) / (static_cast(cgain) * 0.0000610351562)) * 1.5625) / (sense_resistor * 1000.0); @@ -576,9 +576,9 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the values. */ u16 cgain, coff, current; - R_TRY(ReadRegister(this->i2c_session, max17050::CGain, std::addressof(cgain))); - R_TRY(ReadRegister(this->i2c_session, max17050::COff, std::addressof(coff))); - R_TRY(ReadRegister(this->i2c_session, max17050::Current, std::addressof(current))); + R_TRY(ReadRegister(m_i2c_session, max17050::CGain, std::addressof(cgain))); + R_TRY(ReadRegister(m_i2c_session, max17050::COff, std::addressof(coff))); + R_TRY(ReadRegister(m_i2c_session, max17050::Current, std::addressof(current))); /* Set output. */ *out = (((static_cast(current) - (static_cast(coff) + static_cast(coff))) / (static_cast(cgain) * 0.0000610351562)) * 1.5625) / (sense_resistor * 1000.0); @@ -588,7 +588,7 @@ namespace ams::powctl::impl::board::nintendo::nx { Result Max17050Driver::GetNeedToRestoreParameters(bool *out) { /* Get the register. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::MiscCfg, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::MiscCfg, std::addressof(val))); /* Extract the value. */ *out = (val & 0x8000) != 0; @@ -596,13 +596,13 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetNeedToRestoreParameters(bool en) { - return ReadWriteRegister(this->i2c_session, max17050::MiscCfg, 0x8000, en ? 0x8000 : 0); + return ReadWriteRegister(m_i2c_session, max17050::MiscCfg, 0x8000, en ? 0x8000 : 0); } Result Max17050Driver::IsI2cShutdownEnabled(bool *out) { /* Get the register. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::Config, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::Config, std::addressof(val))); /* Extract the value. */ *out = (val & 0x0040) != 0; @@ -610,20 +610,20 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetI2cShutdownEnabled(bool en) { - return ReadWriteRegister(this->i2c_session, max17050::Config, 0x0040, en ? 0x0040 : 0); + return ReadWriteRegister(m_i2c_session, max17050::Config, 0x0040, en ? 0x0040 : 0); } Result Max17050Driver::GetStatus(u16 *out) { /* Validate parameters. */ AMS_ABORT_UNLESS(out != nullptr); - return ReadRegister(this->i2c_session, max17050::Status, out); + return ReadRegister(m_i2c_session, max17050::Status, out); } Result Max17050Driver::GetCycles(u16 *out) { /* Get the register. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::Cycles, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::Cycles, std::addressof(val))); /* Extract the value. */ *out = std::max(val, 0x60) - 0x60; @@ -631,7 +631,7 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::ResetCycles() { - return WriteRegister(this->i2c_session, max17050::Cycles, 0x0060); + return WriteRegister(m_i2c_session, max17050::Cycles, 0x0060); } Result Max17050Driver::GetAge(double *out) { @@ -640,7 +640,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::Age, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::Age, std::addressof(val))); /* Set output. */ *out = static_cast(val) * 0.00390625; @@ -653,7 +653,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::Temperature, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::Temperature, std::addressof(val))); /* Set output. */ *out = static_cast(val) * 0.00390625; @@ -666,7 +666,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::MaxMinTemp, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::MaxMinTemp, std::addressof(val))); /* Set output. */ *out = static_cast(val >> 8); @@ -674,11 +674,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetTemperatureMinimumAlertThreshold(int c) { - return ReadWriteRegister(this->i2c_session, max17050::TAlrtThreshold, 0x00FF, static_cast(c)); + return ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0x00FF, static_cast(c)); } Result Max17050Driver::SetTemperatureMaximumAlertThreshold(int c) { - return ReadWriteRegister(this->i2c_session, max17050::TAlrtThreshold, 0xFF00, static_cast(static_cast(c)) << 8); + return ReadWriteRegister(m_i2c_session, max17050::TAlrtThreshold, 0xFF00, static_cast(static_cast(c)) << 8); } Result Max17050Driver::GetVCell(int *out) { @@ -687,7 +687,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::VCell, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::VCell, std::addressof(val))); /* Set output. */ *out = (625 * (val >> 3)) / 1000; @@ -700,7 +700,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::AverageVCell, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::AverageVCell, std::addressof(val))); /* Set output. */ *out = (625 * (val >> 3)) / 1000; @@ -713,7 +713,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::FilterCfg, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::FilterCfg, std::addressof(val))); /* Set output. */ *out = 175.8 * ExponentiateTwoToPower(6 + ((val >> 4) & 7), 1.0); @@ -726,7 +726,7 @@ namespace ams::powctl::impl::board::nintendo::nx { /* Read the value. */ u16 val; - R_TRY(ReadRegister(this->i2c_session, max17050::VFocV, std::addressof(val))); + R_TRY(ReadRegister(m_i2c_session, max17050::VFocV, std::addressof(val))); /* Set output. */ *out = (1250 * (val >> 4)) / 1000; @@ -734,11 +734,11 @@ namespace ams::powctl::impl::board::nintendo::nx { } Result Max17050Driver::SetVoltageMinimumAlertThreshold(int mv) { - return ReadWriteRegister(this->i2c_session, max17050::VAlrtThreshold, 0x00FF, static_cast(util::DivideUp(mv, 20))); + return ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0x00FF, static_cast(util::DivideUp(mv, 20))); } Result Max17050Driver::SetVoltageMaximumAlertThreshold(int mv) { - return ReadWriteRegister(this->i2c_session, max17050::VAlrtThreshold, 0xFF00, static_cast(static_cast(mv / 20)) << 8); + return ReadWriteRegister(m_i2c_session, max17050::VAlrtThreshold, 0xFF00, static_cast(static_cast(mv / 20)) << 8); } } diff --git a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.hpp b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.hpp index c845ff7ed..3849439d3 100644 --- a/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/board/nintendo/nx/powctl_max17050_driver.hpp @@ -37,10 +37,10 @@ namespace ams::powctl::impl::board::nintendo::nx { class Max17050Driver { private: - os::SdkMutex mutex; - int init_count; - i2c::I2cSession i2c_session; - max17050::InternalState internal_state; + os::SdkMutex m_mutex; + int m_init_count; + i2c::I2cSession m_i2c_session; + max17050::InternalState m_internal_state; private: Result InitializeSession(const char *battery_vendor, u8 battery_version); Result SetMaximumShutdownTimerThreshold(); @@ -54,18 +54,18 @@ namespace ams::powctl::impl::board::nintendo::nx { Result SetModelTable(const u16 *model_table); bool IsModelTableSet(const u16 *model_table); public: - Max17050Driver() : mutex(), init_count(0), i2c_session(), internal_state() { + Max17050Driver() : m_mutex(), m_init_count(0), m_i2c_session(), m_internal_state() { /* ... */ } void Initialize(const char *battery_vendor, u8 battery_version) { - std::scoped_lock lk(this->mutex); - if ((this->init_count++) == 0) { + std::scoped_lock lk(m_mutex); + if ((m_init_count++) == 0) { /* Initialize i2c library. */ i2c::InitializeEmpty(); /* Open session. */ - R_ABORT_UNLESS(i2c::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Max17050)); + R_ABORT_UNLESS(i2c::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max17050)); /* Initialize session. */ R_ABORT_UNLESS(this->InitializeSession(battery_vendor, battery_version)); @@ -76,10 +76,10 @@ namespace ams::powctl::impl::board::nintendo::nx { } void Finalize() { - std::scoped_lock lk(this->mutex); - if ((--this->init_count) == 0) { + std::scoped_lock lk(m_mutex); + if ((--m_init_count) == 0) { /* Close session. */ - i2c::CloseSession(this->i2c_session); + i2c::CloseSession(m_i2c_session); /* Finalize i2c library. */ i2c::Finalize(); @@ -90,11 +90,11 @@ namespace ams::powctl::impl::board::nintendo::nx { Result WriteInternalState(); void GetInternalState(max17050::InternalState *dst) { - *dst = this->internal_state; + *dst = m_internal_state; } void SetInternalState(const max17050::InternalState &src) { - this->internal_state = src; + m_internal_state = src; } Result GetSocRep(double *out); diff --git a/libraries/libstratosphere/source/powctl/impl/powctl_i_power_control_driver.hpp b/libraries/libstratosphere/source/powctl/impl/powctl_i_power_control_driver.hpp index 6aa486c9a..346e67fd3 100644 --- a/libraries/libstratosphere/source/powctl/impl/powctl_i_power_control_driver.hpp +++ b/libraries/libstratosphere/source/powctl/impl/powctl_i_power_control_driver.hpp @@ -32,13 +32,13 @@ namespace ams::powctl::impl { NON_MOVEABLE(IPowerControlDriver); AMS_DDSF_CASTABLE_TRAITS(ams::powctl::impl::IPowerControlDriver, ::ams::ddsf::IDriver); private: - bool event_handler_enabled; + bool m_event_handler_enabled; protected: constexpr bool IsEventHandlerEnabled() const { - return this->event_handler_enabled; + return m_event_handler_enabled; } public: - IPowerControlDriver(bool ev) : IDriver(), event_handler_enabled(ev) { /* ... */ } + IPowerControlDriver(bool ev) : IDriver(), m_event_handler_enabled(ev) { /* ... */ } virtual ~IPowerControlDriver() { /* ... */ } virtual void InitializeDriver() = 0; diff --git a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp index 70b3e5d91..80594f734 100644 --- a/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp +++ b/libraries/libstratosphere/source/psc/psc_pm_module.os.horizon.cpp @@ -34,57 +34,57 @@ namespace ams::psc { } - PmModule::PmModule() : intf(nullptr), initialized(false), reserved(0) { /* ... */ } + PmModule::PmModule() : m_intf(nullptr), m_initialized(false), m_reserved(0) { /* ... */ } PmModule::~PmModule() { - if (this->initialized) { - this->intf = nullptr; - os::DestroySystemEvent(this->system_event.GetBase()); + if (m_initialized) { + m_intf = nullptr; + os::DestroySystemEvent(m_system_event.GetBase()); } } Result PmModule::Initialize(const PmModuleId mid, const PmModuleId *dependencies, u32 dependency_count, os::EventClearMode clear_mode) { - R_UNLESS(!this->initialized, psc::ResultAlreadyInitialized()); + R_UNLESS(!m_initialized, psc::ResultAlreadyInitialized()); static_assert(sizeof(*dependencies) == sizeof(u32)); ::PscPmModule module; R_TRY(::pscmGetPmModule(std::addressof(module), static_cast<::PscPmModuleId>(mid), reinterpret_cast(dependencies), dependency_count, clear_mode == os::EventClearMode_AutoClear)); - this->intf = RemoteObjectFactory::CreateSharedEmplaced(module); - this->system_event.AttachReadableHandle(module.event.revent, false, clear_mode); - this->initialized = true; + m_intf = RemoteObjectFactory::CreateSharedEmplaced(module); + m_system_event.AttachReadableHandle(module.event.revent, false, clear_mode); + m_initialized = true; return ResultSuccess(); } Result PmModule::Finalize() { - R_UNLESS(this->initialized, psc::ResultNotInitialized()); + R_UNLESS(m_initialized, psc::ResultNotInitialized()); - R_TRY(this->intf->Finalize()); - this->intf = nullptr; - os::DestroySystemEvent(this->system_event.GetBase()); - this->initialized = false; + R_TRY(m_intf->Finalize()); + m_intf = nullptr; + os::DestroySystemEvent(m_system_event.GetBase()); + m_initialized = false; return ResultSuccess(); } Result PmModule::GetRequest(PmState *out_state, PmFlagSet *out_flags) { - R_UNLESS(this->initialized, psc::ResultNotInitialized()); + R_UNLESS(m_initialized, psc::ResultNotInitialized()); - return this->intf->GetRequest(out_state, out_flags); + return m_intf->GetRequest(out_state, out_flags); } Result PmModule::Acknowledge(PmState state, Result res) { R_ABORT_UNLESS(res); - R_UNLESS(this->initialized, psc::ResultNotInitialized()); + R_UNLESS(m_initialized, psc::ResultNotInitialized()); if (hos::GetVersion() >= hos::Version_5_1_0) { - return this->intf->AcknowledgeEx(state); + return m_intf->AcknowledgeEx(state); } else { - return this->intf->Acknowledge(); + return m_intf->Acknowledge(); } } os::SystemEvent *PmModule::GetEventPointer() { - return std::addressof(this->system_event); + return std::addressof(m_system_event); } } \ No newline at end of file diff --git a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp index d202429a2..e8a205639 100644 --- a/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp +++ b/libraries/libstratosphere/source/psc/psc_remote_pm_module.hpp @@ -22,11 +22,11 @@ namespace ams::psc { NON_COPYABLE(RemotePmModule); NON_MOVEABLE(RemotePmModule); private: - ::PscPmModule module; + ::PscPmModule m_module; public: - constexpr RemotePmModule(const ::PscPmModule &m) : module(m) { /* ... */ } + constexpr RemotePmModule(const ::PscPmModule &m) : m_module(m) { /* ... */ } ~RemotePmModule() { - ::pscPmModuleClose(std::addressof(this->module)); + ::pscPmModuleClose(std::addressof(m_module)); } Result Initialize(ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list) { @@ -38,21 +38,21 @@ namespace ams::psc { Result GetRequest(ams::sf::Out out_state, ams::sf::Out out_flags) { static_assert(sizeof(PmState) == sizeof(::PscPmState)); static_assert(sizeof(PmFlagSet) == sizeof(u32)); - return ::pscPmModuleGetRequest(std::addressof(this->module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast(out_flags.GetPointer())); + return ::pscPmModuleGetRequest(std::addressof(m_module), reinterpret_cast<::PscPmState *>(out_state.GetPointer()), reinterpret_cast(out_flags.GetPointer())); } Result Acknowledge() { /* NOTE: libnx does not separate acknowledge/acknowledgeEx. */ - return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(0)); + return ::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(0)); } Result Finalize() { - return ::pscPmModuleFinalize(std::addressof(this->module)); + return ::pscPmModuleFinalize(std::addressof(m_module)); } Result AcknowledgeEx(PmState state) { static_assert(sizeof(state) == sizeof(::PscPmState)); - return ::pscPmModuleAcknowledge(std::addressof(this->module), static_cast<::PscPmState>(state)); + return ::pscPmModuleAcknowledge(std::addressof(m_module), static_cast<::PscPmState>(state)); } }; static_assert(psc::sf::IsIPmModule); diff --git a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp index 41d08ae6d..32d377c86 100644 --- a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp +++ b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.cpp @@ -33,7 +33,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { } - PwmDriverImpl::PwmDriverImpl(dd::PhysicalAddress paddr, size_t sz, const ChannelDefinition *c, size_t nc) : registers_phys_addr(paddr), registers_size(sz), channels(c), num_channels(nc), registers(0) { + PwmDriverImpl::PwmDriverImpl(dd::PhysicalAddress paddr, size_t sz, const ChannelDefinition *c, size_t nc) : m_registers_phys_addr(paddr), m_registers_size(sz), m_channels(c), m_num_channels(nc), m_registers(0) { /* ... */ } @@ -60,8 +60,8 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { void PwmDriverImpl::InitializeDriver() { /* Get the registers virtual address. */ - this->registers = dd::QueryIoMapping(this->registers_phys_addr, this->registers_size); - AMS_ABORT_UNLESS(this->registers != 0); + m_registers = dd::QueryIoMapping(m_registers_phys_addr, m_registers_size); + AMS_ABORT_UNLESS(m_registers != 0); /* Setup power to pwm. */ this->PowerOn(); diff --git a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.hpp b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.hpp index 7376f7df1..e98e17562 100644 --- a/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.hpp +++ b/libraries/libstratosphere/source/pwm/driver/board/nintendo/nx/impl/pwm_pwm_driver_impl.hpp @@ -24,16 +24,16 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { NON_MOVEABLE(PwmDeviceImpl); AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::board::nintendo::nx::impl::PwmDeviceImpl, ::ams::pwm::driver::IPwmDevice); private: - os::SdkMutex suspend_mutex; - u32 suspend_value; + os::SdkMutex m_suspend_mutex; + u32 m_suspend_value; public: - PwmDeviceImpl(int channel) : IPwmDevice(channel), suspend_mutex(), suspend_value() { /* ... */ } + PwmDeviceImpl(int channel) : IPwmDevice(channel), m_suspend_mutex(), m_suspend_value() { /* ... */ } - void SetSuspendValue(u32 v) { this->suspend_value = v; } - u32 GetSuspendValue() const { return this->suspend_value; } + void SetSuspendValue(u32 v) { m_suspend_value = v; } + u32 GetSuspendValue() const { return m_suspend_value; } - void lock() { return this->suspend_mutex.lock(); } - void unlock() { return this->suspend_mutex.unlock(); } + void lock() { return m_suspend_mutex.lock(); } + void unlock() { return m_suspend_mutex.unlock(); } }; class PwmDriverImpl : public ::ams::pwm::driver::IPwmDriver { @@ -41,14 +41,14 @@ namespace ams::pwm::driver::board::nintendo::nx::impl { NON_MOVEABLE(PwmDriverImpl); AMS_DDSF_CASTABLE_TRAITS(ams::pwm::driver::board::nintendo::nx::impl::PwmDriverImpl, ::ams::pwm::driver::IPwmDriver); private: - dd::PhysicalAddress registers_phys_addr; - size_t registers_size; - const ChannelDefinition *channels; - size_t num_channels; - uintptr_t registers; + dd::PhysicalAddress m_registers_phys_addr; + size_t m_registers_size; + const ChannelDefinition *m_channels; + size_t m_num_channels; + uintptr_t m_registers; private: ALWAYS_INLINE uintptr_t GetRegistersFor(IPwmDevice &device) { - return registers + PWM_CONTROLLER_PWM_CHANNEL_OFFSET(device.GetChannelIndex()); + return m_registers + PWM_CONTROLLER_PWM_CHANNEL_OFFSET(device.GetChannelIndex()); } ALWAYS_INLINE uintptr_t GetRegistersFor(IPwmDevice *device) { diff --git a/libraries/libstratosphere/source/pwm/server/pwm_server_channel_session_impl.hpp b/libraries/libstratosphere/source/pwm/server/pwm_server_channel_session_impl.hpp index 157e64126..d797f558c 100644 --- a/libraries/libstratosphere/source/pwm/server/pwm_server_channel_session_impl.hpp +++ b/libraries/libstratosphere/source/pwm/server/pwm_server_channel_session_impl.hpp @@ -22,64 +22,64 @@ namespace ams::pwm::server { class ChannelSessionImpl { private: - ManagerImpl *parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ - pwm::driver::ChannelSession internal_session; - bool has_session; + ManagerImpl *m_parent; /* NOTE: this is an sf::SharedPointer<> in Nintendo's code. */ + pwm::driver::ChannelSession m_internal_session; + bool m_has_session; public: - explicit ChannelSessionImpl(ManagerImpl *p) : parent(p), has_session(false) { /* ... */ } + explicit ChannelSessionImpl(ManagerImpl *p) : m_parent(p), m_has_session(false) { /* ... */ } ~ChannelSessionImpl() { - if (this->has_session) { - pwm::driver::CloseSession(this->internal_session); + if (m_has_session) { + pwm::driver::CloseSession(m_internal_session); } } Result OpenSession(DeviceCode device_code) { - AMS_ABORT_UNLESS(!this->has_session); + AMS_ABORT_UNLESS(!m_has_session); - R_TRY(pwm::driver::OpenSession(std::addressof(this->internal_session), device_code)); - this->has_session = true; + R_TRY(pwm::driver::OpenSession(std::addressof(m_internal_session), device_code)); + m_has_session = true; return ResultSuccess(); } public: /* Actual commands. */ Result SetPeriod(TimeSpanType period) { - pwm::driver::SetPeriod(this->internal_session, period); + pwm::driver::SetPeriod(m_internal_session, period); return ResultSuccess(); } Result GetPeriod(ams::sf::Out out) { - out.SetValue(pwm::driver::GetPeriod(this->internal_session)); + out.SetValue(pwm::driver::GetPeriod(m_internal_session)); return ResultSuccess(); } Result SetDuty(int duty) { - pwm::driver::SetDuty(this->internal_session, duty); + pwm::driver::SetDuty(m_internal_session, duty); return ResultSuccess(); } Result GetDuty(ams::sf::Out out) { - out.SetValue(pwm::driver::GetDuty(this->internal_session)); + out.SetValue(pwm::driver::GetDuty(m_internal_session)); return ResultSuccess(); } Result SetEnabled(bool enabled) { - pwm::driver::SetEnabled(this->internal_session, enabled); + pwm::driver::SetEnabled(m_internal_session, enabled); return ResultSuccess(); } Result GetEnabled(ams::sf::Out out) { - out.SetValue(pwm::driver::GetEnabled(this->internal_session)); + out.SetValue(pwm::driver::GetEnabled(m_internal_session)); return ResultSuccess(); } Result SetScale(double scale) { - pwm::driver::SetScale(this->internal_session, scale); + pwm::driver::SetScale(m_internal_session, scale); return ResultSuccess(); } Result GetScale(ams::sf::Out out) { - out.SetValue(pwm::driver::GetScale(this->internal_session)); + out.SetValue(pwm::driver::GetScale(m_internal_session)); return ResultSuccess(); } }; diff --git a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp index 8b24d1964..744dd017b 100644 --- a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp +++ b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.cpp @@ -19,12 +19,12 @@ namespace ams::pwm::server { ManagerImpl::ManagerImpl() { - this->heap_handle = lmem::CreateExpHeap(this->heap_buffer, sizeof(this->heap_buffer), lmem::CreateOption_None); - this->allocator.Attach(this->heap_handle); + m_heap_handle = lmem::CreateExpHeap(m_heap_buffer, sizeof(m_heap_buffer), lmem::CreateOption_None); + m_allocator.Attach(m_heap_handle); } ManagerImpl::~ManagerImpl() { - lmem::DestroyExpHeap(this->heap_handle); + lmem::DestroyExpHeap(m_heap_handle); } Result ManagerImpl::OpenSessionForDev(ams::sf::Out> out, int channel) { @@ -39,7 +39,7 @@ namespace ams::pwm::server { Result ManagerImpl::OpenSession2(ams::sf::Out> out, DeviceCode device_code) { /* Allocate a session. */ - auto session = Factory::CreateSharedEmplaced(std::addressof(this->allocator), this); + auto session = Factory::CreateSharedEmplaced(std::addressof(m_allocator), this); /* Open the session. */ R_TRY(session.GetImpl().OpenSession(device_code)); diff --git a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.hpp b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.hpp index 3557cae0d..4ad116944 100644 --- a/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.hpp +++ b/libraries/libstratosphere/source/pwm/server/pwm_server_manager_impl.hpp @@ -24,9 +24,9 @@ namespace ams::pwm::server { using Allocator = ams::sf::ExpHeapAllocator; using Factory = ams::sf::ObjectFactory; private: - lmem::HeapHandle heap_handle; - Allocator allocator; - u8 heap_buffer[4_KB]; + lmem::HeapHandle m_heap_handle; + Allocator m_allocator; + u8 m_heap_buffer[4_KB]; public: ManagerImpl(); diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp index b882ea080..cc17bc007 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp @@ -18,87 +18,87 @@ namespace ams::sf::cmif { ServerDomainManager::Domain::~Domain() { - while (!this->entries.empty()) { - Entry *entry = std::addressof(this->entries.front()); + while (!m_entries.empty()) { + Entry *entry = std::addressof(m_entries.front()); { - std::scoped_lock lk(this->manager->entry_owner_lock); + std::scoped_lock lk(m_manager->m_entry_owner_lock); AMS_ABORT_UNLESS(entry->owner == this); entry->owner = nullptr; } entry->object.Reset(); - this->entries.pop_front(); - this->manager->entry_manager.FreeEntry(entry); + m_entries.pop_front(); + m_manager->m_entry_manager.FreeEntry(entry); } } void ServerDomainManager::Domain::DisposeImpl() { - ServerDomainManager *manager = this->manager; + ServerDomainManager *manager = m_manager; std::destroy_at(this); manager->FreeDomain(this); } Result ServerDomainManager::Domain::ReserveIds(DomainObjectId *out_ids, size_t count) { for (size_t i = 0; i < count; i++) { - Entry *entry = this->manager->entry_manager.AllocateEntry(); + Entry *entry = m_manager->m_entry_manager.AllocateEntry(); R_UNLESS(entry != nullptr, sf::cmif::ResultOutOfDomainEntries()); AMS_ABORT_UNLESS(entry->owner == nullptr); - out_ids[i] = this->manager->entry_manager.GetId(entry); + out_ids[i] = m_manager->m_entry_manager.GetId(entry); } return ResultSuccess(); } void ServerDomainManager::Domain::ReserveSpecificIds(const DomainObjectId *ids, size_t count) { - this->manager->entry_manager.AllocateSpecificEntries(ids, count); + m_manager->m_entry_manager.AllocateSpecificEntries(ids, count); } void ServerDomainManager::Domain::UnreserveIds(const DomainObjectId *ids, size_t count) { for (size_t i = 0; i < count; i++) { - Entry *entry = this->manager->entry_manager.GetEntry(ids[i]); + Entry *entry = m_manager->m_entry_manager.GetEntry(ids[i]); AMS_ABORT_UNLESS(entry != nullptr); AMS_ABORT_UNLESS(entry->owner == nullptr); - this->manager->entry_manager.FreeEntry(entry); + m_manager->m_entry_manager.FreeEntry(entry); } } void ServerDomainManager::Domain::RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) { - Entry *entry = this->manager->entry_manager.GetEntry(id); + Entry *entry = m_manager->m_entry_manager.GetEntry(id); AMS_ABORT_UNLESS(entry != nullptr); { - std::scoped_lock lk(this->manager->entry_owner_lock); + std::scoped_lock lk(m_manager->m_entry_owner_lock); AMS_ABORT_UNLESS(entry->owner == nullptr); entry->owner = this; - this->entries.push_back(*entry); + m_entries.push_back(*entry); } entry->object = std::move(obj); } ServiceObjectHolder ServerDomainManager::Domain::UnregisterObject(DomainObjectId id) { ServiceObjectHolder obj; - Entry *entry = this->manager->entry_manager.GetEntry(id); + Entry *entry = m_manager->m_entry_manager.GetEntry(id); if (entry == nullptr) { return ServiceObjectHolder(); } { - std::scoped_lock lk(this->manager->entry_owner_lock); + std::scoped_lock lk(m_manager->m_entry_owner_lock); if (entry->owner != this) { return ServiceObjectHolder(); } entry->owner = nullptr; obj = std::move(entry->object); - this->entries.erase(this->entries.iterator_to(*entry)); + m_entries.erase(m_entries.iterator_to(*entry)); } - this->manager->entry_manager.FreeEntry(entry); + m_manager->m_entry_manager.FreeEntry(entry); return obj; } ServiceObjectHolder ServerDomainManager::Domain::GetObject(DomainObjectId id) { - Entry *entry = this->manager->entry_manager.GetEntry(id); + Entry *entry = m_manager->m_entry_manager.GetEntry(id); if (entry == nullptr) { return ServiceObjectHolder(); } { - std::scoped_lock lk(this->manager->entry_owner_lock); + std::scoped_lock lk(m_manager->m_entry_owner_lock); if (entry->owner != this) { return ServiceObjectHolder(); } @@ -106,41 +106,41 @@ namespace ams::sf::cmif { return entry->object.Clone(); } - ServerDomainManager::EntryManager::EntryManager(DomainEntryStorage *entry_storage, size_t entry_count) : lock() { - this->entries = reinterpret_cast(entry_storage); - this->num_entries = entry_count; - for (size_t i = 0; i < this->num_entries; i++) { - this->free_list.push_back(*std::construct_at(this->entries + i)); + ServerDomainManager::EntryManager::EntryManager(DomainEntryStorage *entry_storage, size_t entry_count) : m_lock() { + m_entries = reinterpret_cast(entry_storage); + m_num_entries = entry_count; + for (size_t i = 0; i < m_num_entries; i++) { + m_free_list.push_back(*std::construct_at(m_entries + i)); } } ServerDomainManager::EntryManager::~EntryManager() { - for (size_t i = 0; i < this->num_entries; i++) { - std::destroy_at(this->entries + i); + for (size_t i = 0; i < m_num_entries; i++) { + std::destroy_at(m_entries + i); } } ServerDomainManager::Entry *ServerDomainManager::EntryManager::AllocateEntry() { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - if (this->free_list.empty()) { + if (m_free_list.empty()) { return nullptr; } - Entry *e = std::addressof(this->free_list.front()); - this->free_list.pop_front(); + Entry *e = std::addressof(m_free_list.front()); + m_free_list.pop_front(); return e; } void ServerDomainManager::EntryManager::FreeEntry(Entry *entry) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); AMS_ABORT_UNLESS(entry->owner == nullptr); AMS_ABORT_UNLESS(!entry->object); - this->free_list.push_front(*entry); + m_free_list.push_front(*entry); } void ServerDomainManager::EntryManager::AllocateSpecificEntries(const DomainObjectId *ids, size_t count) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); /* Allocate new IDs. */ for (size_t i = 0; i < count; i++) { @@ -149,7 +149,7 @@ namespace ams::sf::cmif { if (id != InvalidDomainObjectId) { AMS_ABORT_UNLESS(entry != nullptr); AMS_ABORT_UNLESS(entry->owner == nullptr); - this->free_list.erase(this->free_list.iterator_to(*entry)); + m_free_list.erase(m_free_list.iterator_to(*entry)); } } } diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp index ae4c81a47..f94a321a7 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp @@ -109,17 +109,17 @@ namespace ams::sf::cmif { Result DomainServiceObjectProcessor::PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const { /* Validate in object count. */ - R_UNLESS(this->impl_metadata.GetInObjectCount() == this->GetInObjectCount(), sf::cmif::ResultInvalidNumInObjects()); + R_UNLESS(m_impl_metadata.GetInObjectCount() == this->GetInObjectCount(), sf::cmif::ResultInvalidNumInObjects()); /* Nintendo reserves domain object IDs here. We do this later, to support mitm semantics. */ /* Pass onwards. */ - return this->impl_processor->PrepareForProcess(ctx, runtime_metadata); + return m_impl_processor->PrepareForProcess(ctx, runtime_metadata); } Result DomainServiceObjectProcessor::GetInObjects(ServiceObjectHolder *in_objects) const { for (size_t i = 0; i < this->GetInObjectCount(); i++) { - in_objects[i] = this->domain->GetObject(this->in_object_ids[i]); + in_objects[i] = m_domain->GetObject(m_in_object_ids[i]); } return ResultSuccess(); } @@ -127,7 +127,7 @@ namespace ams::sf::cmif { HipcRequest DomainServiceObjectProcessor::PrepareForReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) { /* Call into impl processor, get request. */ PointerAndSize raw_data; - HipcRequest request = this->impl_processor->PrepareForReply(ctx, raw_data, runtime_metadata); + HipcRequest request = m_impl_processor->PrepareForReply(ctx, raw_data, runtime_metadata); /* Write out header. */ constexpr size_t out_header_size = sizeof(CmifDomainOutHeader); @@ -137,7 +137,7 @@ namespace ams::sf::cmif { /* Set output raw data. */ out_raw_data = cmif::PointerAndSize(raw_data.GetAddress() + out_header_size, raw_data.GetSize() - out_header_size); - this->out_object_ids = reinterpret_cast(out_raw_data.GetAddress() + impl_out_data_total_size); + m_out_object_ids = reinterpret_cast(out_raw_data.GetAddress() + impl_out_data_total_size); return request; } @@ -145,7 +145,7 @@ namespace ams::sf::cmif { void DomainServiceObjectProcessor::PrepareForErrorReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) { /* Call into impl processor, get request. */ PointerAndSize raw_data; - this->impl_processor->PrepareForErrorReply(ctx, raw_data, runtime_metadata); + m_impl_processor->PrepareForErrorReply(ctx, raw_data, runtime_metadata); /* Write out header. */ constexpr size_t out_header_size = sizeof(CmifDomainOutHeader); @@ -188,8 +188,8 @@ namespace ams::sf::cmif { } } /* TODO: Can we make this error non-fatal? It isn't for N, since they can reserve IDs earlier due to not having to worry about mitm. */ - R_ABORT_UNLESS(this->domain->ReserveIds(reservations, num_unreserved_ids)); - this->domain->ReserveSpecificIds(specific_ids, num_specific_ids); + R_ABORT_UNLESS(m_domain->ReserveIds(reservations, num_unreserved_ids)); + m_domain->ReserveSpecificIds(specific_ids, num_specific_ids); } size_t reservation_index = 0; @@ -205,17 +205,17 @@ namespace ams::sf::cmif { for (size_t i = 0; i < num_out_objects; i++) { if (!out_objects[i]) { if (is_reserved[i]) { - this->domain->UnreserveIds(object_ids + i, 1); + m_domain->UnreserveIds(object_ids + i, 1); } object_ids[i] = InvalidDomainObjectId; continue; } - this->domain->RegisterObject(object_ids[i], std::move(out_objects[i])); + m_domain->RegisterObject(object_ids[i], std::move(out_objects[i])); } /* Set out object IDs in message. */ for (size_t i = 0; i < num_out_objects; i++) { - this->out_object_ids[i] = object_ids[i]; + m_out_object_ids[i] = object_ids[i]; } } diff --git a/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_object_holder.cpp b/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_object_holder.cpp index de5ff1472..9da12f8d4 100644 --- a/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_object_holder.cpp +++ b/libraries/libstratosphere/source/sf/cmif/sf_cmif_service_object_holder.cpp @@ -18,8 +18,8 @@ namespace ams::sf::cmif { Result ServiceObjectHolder::ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - const auto ProcessHandler = this->dispatch_meta->ProcessHandler; - const auto *DispatchTable = this->dispatch_meta->DispatchTable; + const auto ProcessHandler = m_dispatch_meta->ProcessHandler; + const auto *DispatchTable = m_dispatch_meta->DispatchTable; return (DispatchTable->*ProcessHandler)(ctx, in_raw_data); } diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp index d5a829cb1..832b9ffce 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp @@ -27,12 +27,12 @@ namespace ams::sf::hipc::impl { class MitmQueryService { private: - ServerManagerBase::MitmQueryFunction query_function; + ServerManagerBase::MitmQueryFunction m_query_function; public: - MitmQueryService(ServerManagerBase::MitmQueryFunction qf) : query_function(qf) { /* ... */ } + MitmQueryService(ServerManagerBase::MitmQueryFunction qf) : m_query_function(qf) { /* ... */ } void ShouldMitm(sf::Out out, const sm::MitmProcessInfo &client_info) { - *out = this->query_function(client_info); + *out = m_query_function(client_info); } }; static_assert(IsIMitmQueryService); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp index 038de40dd..795e67d74 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp @@ -30,13 +30,13 @@ namespace ams::sf::hipc { class HipcManagerImpl { private: - ServerDomainSessionManager *manager; - ServerSession *session; - bool is_mitm_session; + ServerDomainSessionManager *m_manager; + ServerSession *m_session; + bool m_is_mitm_session; private: Result CloneCurrentObjectImpl(sf::OutMoveHandle &out_client_handle, ServerSessionManager *tagged_manager) { /* Clone the object. */ - cmif::ServiceObjectHolder &&clone = this->session->srv_obj_holder.Clone(); + cmif::ServiceObjectHolder &&clone = m_session->m_srv_obj_holder.Clone(); R_UNLESS(clone, sf::hipc::ResultDomainObjectNotFound()); /* Create new session handles. */ @@ -44,12 +44,12 @@ namespace ams::sf::hipc { R_ABORT_UNLESS(hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); /* Register with manager. */ - if (!is_mitm_session) { + if (!m_is_mitm_session) { R_ABORT_UNLESS(tagged_manager->RegisterSession(server_handle, std::move(clone))); } else { /* Clone the forward service. */ std::shared_ptr<::Service> new_forward_service = std::move(ServerSession::CreateForwardService()); - R_ABORT_UNLESS(serviceClone(this->session->forward_service.get(), new_forward_service.get())); + R_ABORT_UNLESS(serviceClone(m_session->m_forward_service.get(), new_forward_service.get())); R_ABORT_UNLESS(tagged_manager->RegisterMitmSession(server_handle, std::move(clone), std::move(new_forward_service))); } @@ -58,34 +58,34 @@ namespace ams::sf::hipc { return ResultSuccess(); } public: - explicit HipcManagerImpl(ServerDomainSessionManager *m, ServerSession *s) : manager(m), session(s), is_mitm_session(s->forward_service != nullptr) { + explicit HipcManagerImpl(ServerDomainSessionManager *m, ServerSession *s) : m_manager(m), m_session(s), m_is_mitm_session(s->m_forward_service != nullptr) { /* ... */ } Result ConvertCurrentObjectToDomain(sf::Out out) { /* Allocate a domain. */ - auto domain = this->manager->AllocateDomainServiceObject(); + auto domain = m_manager->AllocateDomainServiceObject(); R_UNLESS(domain, sf::hipc::ResultOutOfDomains()); /* Set up the new domain object. */ cmif::DomainObjectId object_id = cmif::InvalidDomainObjectId; - if (this->is_mitm_session) { + if (m_is_mitm_session) { /* Make a new shared pointer to manage the allocated domain. */ SharedPointer cmif_domain(static_cast(domain), false); /* Convert the remote session to domain. */ - AMS_ABORT_UNLESS(session->forward_service->own_handle); - R_TRY(serviceConvertToDomain(session->forward_service.get())); + AMS_ABORT_UNLESS(m_session->m_forward_service->own_handle); + R_TRY(serviceConvertToDomain(m_session->m_forward_service.get())); /* The object ID reservation cannot fail here, as that would cause desynchronization from target domain. */ - object_id = cmif::DomainObjectId{session->forward_service->object_id}; + object_id = cmif::DomainObjectId{m_session->m_forward_service->object_id}; domain->ReserveSpecificIds(std::addressof(object_id), 1); /* Register the object. */ - domain->RegisterObject(object_id, std::move(session->srv_obj_holder)); + domain->RegisterObject(object_id, std::move(m_session->m_srv_obj_holder)); /* Set the new object holder. */ - session->srv_obj_holder = cmif::ServiceObjectHolder(std::move(cmif_domain)); + m_session->m_srv_obj_holder = cmif::ServiceObjectHolder(std::move(cmif_domain)); } else { /* Make a new shared pointer to manage the allocated domain. */ SharedPointer cmif_domain(domain, false); @@ -94,10 +94,10 @@ namespace ams::sf::hipc { R_TRY(domain->ReserveIds(std::addressof(object_id), 1)); /* Register the object. */ - domain->RegisterObject(object_id, std::move(session->srv_obj_holder)); + domain->RegisterObject(object_id, std::move(m_session->m_srv_obj_holder)); /* Set the new object holder. */ - session->srv_obj_holder = cmif::ServiceObjectHolder(std::move(cmif_domain)); + m_session->m_srv_obj_holder = cmif::ServiceObjectHolder(std::move(cmif_domain)); } /* Return the allocated id. */ @@ -108,35 +108,35 @@ namespace ams::sf::hipc { Result CopyFromCurrentDomain(sf::OutMoveHandle out, cmif::DomainObjectId object_id) { /* Get domain. */ - auto domain = this->session->srv_obj_holder.GetServiceObject(); + auto domain = m_session->m_srv_obj_holder.GetServiceObject(); R_UNLESS(domain != nullptr, sf::hipc::ResultTargetNotDomain()); /* Get domain object. */ auto &&object = domain->GetObject(object_id); if (!object) { - R_UNLESS(this->is_mitm_session, sf::hipc::ResultDomainObjectNotFound()); + R_UNLESS(m_is_mitm_session, sf::hipc::ResultDomainObjectNotFound()); os::NativeHandle handle; - R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(handle))); + R_TRY(cmifCopyFromCurrentDomain(m_session->m_forward_service->session, object_id.value, std::addressof(handle))); out.SetValue(handle, false); return ResultSuccess(); } - if (!this->is_mitm_session || object_id.value != serviceGetObjectId(this->session->forward_service.get())) { + if (!m_is_mitm_session || object_id.value != serviceGetObjectId(m_session->m_forward_service.get())) { /* Create new session handles. */ os::NativeHandle server_handle, client_handle; R_ABORT_UNLESS(hipc::CreateSession(std::addressof(server_handle), std::addressof(client_handle))); /* Register. */ - R_ABORT_UNLESS(this->manager->RegisterSession(server_handle, std::move(object))); + R_ABORT_UNLESS(m_manager->RegisterSession(server_handle, std::move(object))); /* Set output client handle. */ out.SetValue(client_handle, false); } else { /* Copy from the target domain. */ os::NativeHandle new_forward_target; - R_TRY(cmifCopyFromCurrentDomain(this->session->forward_service->session, object_id.value, std::addressof(new_forward_target))); + R_TRY(cmifCopyFromCurrentDomain(m_session->m_forward_service->session, object_id.value, std::addressof(new_forward_target))); /* Create new session handles. */ os::NativeHandle server_handle, client_handle; @@ -145,7 +145,7 @@ namespace ams::sf::hipc { /* Register. */ std::shared_ptr<::Service> new_forward_service = std::move(ServerSession::CreateForwardService()); serviceCreate(new_forward_service.get(), new_forward_target); - R_ABORT_UNLESS(this->manager->RegisterMitmSession(server_handle, std::move(object), std::move(new_forward_service))); + R_ABORT_UNLESS(m_manager->RegisterMitmSession(server_handle, std::move(object), std::move(new_forward_service))); /* Set output client handle. */ out.SetValue(client_handle, false); @@ -155,15 +155,15 @@ namespace ams::sf::hipc { } Result CloneCurrentObject(sf::OutMoveHandle out) { - return this->CloneCurrentObjectImpl(out, this->manager); + return this->CloneCurrentObjectImpl(out, m_manager); } void QueryPointerBufferSize(sf::Out out) { - out.SetValue(this->session->pointer_buffer.GetSize()); + out.SetValue(m_session->m_pointer_buffer.GetSize()); } Result CloneCurrentObjectEx(sf::OutMoveHandle out, u32 tag) { - return this->CloneCurrentObjectImpl(out, this->manager->GetSessionManagerByTag(tag)); + return this->CloneCurrentObjectImpl(out, m_manager->GetSessionManagerByTag(tag)); } }; static_assert(IsIHipcManager); diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp index 7b5ecb0b0..ee3521efa 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp @@ -33,7 +33,7 @@ namespace ams::sf::hipc { } void ServerManagerBase::RegisterServerSessionToWait(ServerSession *session) { - session->has_received = false; + session->m_has_received = false; /* Set user data tag. */ os::SetMultiWaitHolderUserData(session, static_cast(UserDataTag::Session)); @@ -42,25 +42,25 @@ namespace ams::sf::hipc { } void ServerManagerBase::LinkToDeferredList(os::MultiWaitHolderType *holder) { - std::scoped_lock lk(this->deferred_list_mutex); - os::LinkMultiWaitHolder(std::addressof(this->deferred_list), holder); - this->notify_event.Signal(); + std::scoped_lock lk(m_deferred_list_mutex); + os::LinkMultiWaitHolder(std::addressof(m_deferred_list), holder); + m_notify_event.Signal(); } void ServerManagerBase::LinkDeferred() { - std::scoped_lock lk(this->deferred_list_mutex); - os::MoveAllMultiWaitHolder(std::addressof(this->multi_wait), std::addressof(this->deferred_list)); + std::scoped_lock lk(m_deferred_list_mutex); + os::MoveAllMultiWaitHolder(std::addressof(m_multi_wait), std::addressof(m_deferred_list)); } os::MultiWaitHolderType *ServerManagerBase::WaitSignaled() { - std::scoped_lock lk(this->selection_mutex); + std::scoped_lock lk(m_selection_mutex); while (true) { this->LinkDeferred(); - auto selected = os::WaitAny(std::addressof(this->multi_wait)); - if (selected == std::addressof(this->request_stop_event_holder)) { + auto selected = os::WaitAny(std::addressof(m_multi_wait)); + if (selected == std::addressof(m_request_stop_event_holder)) { return nullptr; - } else if (selected == std::addressof(this->notify_event_holder)) { - this->notify_event.Clear(); + } else if (selected == std::addressof(m_notify_event_holder)) { + m_notify_event.Clear(); } else { os::UnlinkMultiWaitHolder(selected); return selected; @@ -69,11 +69,11 @@ namespace ams::sf::hipc { } void ServerManagerBase::ResumeProcessing() { - this->request_stop_event.Clear(); + m_request_stop_event.Clear(); } void ServerManagerBase::RequestStopProcessing() { - this->request_stop_event.Signal(); + m_request_stop_event.Signal(); } void ServerManagerBase::AddUserMultiWaitHolder(os::MultiWaitHolderType *holder) { @@ -91,10 +91,10 @@ namespace ams::sf::hipc { ON_SCOPE_EXIT { this->LinkToDeferredList(server); }; /* Create new session. */ - if (server->static_object) { - return this->AcceptSession(server->port_handle, server->static_object.Clone()); + if (server->m_static_object) { + return this->AcceptSession(server->m_port_handle, server->m_static_object.Clone()); } else { - return this->OnNeedsToAccept(server->index, server); + return this->OnNeedsToAccept(server->m_index, server); } } @@ -105,7 +105,7 @@ namespace ams::sf::hipc { ON_SCOPE_EXIT { this->LinkToDeferredList(server); }; /* Create resources for new session. */ - return this->OnNeedsToAccept(server->index, server); + return this->OnNeedsToAccept(server->m_index, server); } Result ServerManagerBase::ProcessForSession(os::MultiWaitHolderType *holder) { @@ -114,11 +114,11 @@ namespace ams::sf::hipc { ServerSession *session = static_cast(holder); cmif::PointerAndSize tls_message(svc::GetThreadLocalRegion()->message_buffer, hipc::TlsMessageBufferSize); - const cmif::PointerAndSize &saved_message = session->saved_message; + const cmif::PointerAndSize &saved_message = session->m_saved_message; AMS_ABORT_UNLESS(tls_message.GetSize() == saved_message.GetSize()); - if (!session->has_received) { + if (!session->m_has_received) { R_TRY(this->ReceiveRequest(session, tls_message)); - session->has_received = true; + session->m_has_received = true; std::memcpy(saved_message.GetPointer(), tls_message.GetPointer(), tls_message.GetSize()); } else { /* We were deferred and are re-receiving, so just memcpy. */ diff --git a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp index 9802621d1..a57a34a41 100644 --- a/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp +++ b/libraries/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp @@ -42,20 +42,20 @@ namespace ams::sf::hipc { Result ServerSession::ForwardRequest(const cmif::ServiceDispatchContext &ctx) const { AMS_ABORT_UNLESS(this->IsMitmSession()); /* TODO: Support non-TLS messages? */ - AMS_ABORT_UNLESS(this->saved_message.GetPointer() != nullptr); - AMS_ABORT_UNLESS(this->saved_message.GetSize() == TlsMessageBufferSize); + AMS_ABORT_UNLESS(m_saved_message.GetPointer() != nullptr); + AMS_ABORT_UNLESS(m_saved_message.GetSize() == TlsMessageBufferSize); /* Get TLS message buffer. */ u32 * const message_buffer = svc::GetThreadLocalRegion()->message_buffer; /* Copy saved TLS in. */ - std::memcpy(message_buffer, this->saved_message.GetPointer(), this->saved_message.GetSize()); + std::memcpy(message_buffer, m_saved_message.GetPointer(), m_saved_message.GetSize()); /* Prepare buffer. */ - PreProcessCommandBufferForMitm(ctx, this->pointer_buffer, reinterpret_cast(message_buffer)); + PreProcessCommandBufferForMitm(ctx, m_pointer_buffer, reinterpret_cast(message_buffer)); /* Dispatch forwards. */ - R_TRY(svc::SendSyncRequest(this->forward_service->session)); + R_TRY(svc::SendSyncRequest(m_forward_service->session)); /* Parse, to ensure we catch any copy handles and close them. */ { @@ -80,7 +80,7 @@ namespace ams::sf::hipc { } void ServerSessionManager::CloseSessionImpl(ServerSession *session) { - const auto session_handle = session->session_handle; + const auto session_handle = session->m_session_handle; os::FinalizeMultiWaitHolder(session); this->DestroySession(session); os::CloseNativeHandle(session_handle); @@ -91,8 +91,8 @@ namespace ams::sf::hipc { std::construct_at(session_memory, session_handle, std::forward(obj)); /* Assign session resources. */ - session_memory->pointer_buffer = this->GetSessionPointerBuffer(session_memory); - session_memory->saved_message = this->GetSessionSavedMessageBuffer(session_memory); + session_memory->m_pointer_buffer = this->GetSessionPointerBuffer(session_memory); + session_memory->m_saved_message = this->GetSessionSavedMessageBuffer(session_memory); /* Register to wait list. */ this->RegisterServerSessionToWait(session_memory); @@ -118,12 +118,12 @@ namespace ams::sf::hipc { std::construct_at(session_memory, mitm_session_handle, std::forward(obj), std::forward>(fsrv)); /* Assign session resources. */ - session_memory->pointer_buffer = this->GetSessionPointerBuffer(session_memory); - session_memory->saved_message = this->GetSessionSavedMessageBuffer(session_memory); + session_memory->m_pointer_buffer = this->GetSessionPointerBuffer(session_memory); + session_memory->m_saved_message = this->GetSessionSavedMessageBuffer(session_memory); /* Validate session pointer buffer. */ - AMS_ABORT_UNLESS(session_memory->pointer_buffer.GetSize() >= session_memory->forward_service->pointer_buffer_size); - session_memory->pointer_buffer = cmif::PointerAndSize(session_memory->pointer_buffer.GetAddress(), session_memory->forward_service->pointer_buffer_size); + AMS_ABORT_UNLESS(session_memory->m_pointer_buffer.GetSize() >= session_memory->m_forward_service->pointer_buffer_size); + session_memory->m_pointer_buffer = cmif::PointerAndSize(session_memory->m_pointer_buffer.GetAddress(), session_memory->m_forward_service->pointer_buffer_size); /* Register to wait list. */ this->RegisterServerSessionToWait(session_memory); @@ -169,7 +169,7 @@ namespace ams::sf::hipc { } Result ServerSessionManager::ReceiveRequestImpl(ServerSession *session, const cmif::PointerAndSize &message) { - const cmif::PointerAndSize &pointer_buffer = session->pointer_buffer; + const cmif::PointerAndSize &pointer_buffer = session->m_pointer_buffer; /* If the receive list is odd, we may need to receive repeatedly. */ while (true) { @@ -184,13 +184,13 @@ namespace ams::sf::hipc { ); } hipc::ReceiveResult recv_result; - R_TRY(hipc::Receive(std::addressof(recv_result), session->session_handle, message)); + R_TRY(hipc::Receive(std::addressof(recv_result), session->m_session_handle, message)); switch (recv_result) { case hipc::ReceiveResult::Success: - session->is_closed = false; + session->m_is_closed = false; return ResultSuccess(); case hipc::ReceiveResult::Closed: - session->is_closed = true; + session->m_is_closed = true; return ResultSuccess(); case hipc::ReceiveResult::NeedsRetry: continue; @@ -210,7 +210,7 @@ namespace ams::sf::hipc { } Result ServerSessionManager::ProcessRequest(ServerSession *session, const cmif::PointerAndSize &message) { - if (session->is_closed) { + if (session->m_is_closed) { this->CloseSessionImpl(session); return ResultSuccess(); } @@ -266,7 +266,7 @@ namespace ams::sf::hipc { switch (cmif_command_type) { case CmifCommandType_Request: case CmifCommandType_RequestWithContext: - return this->DispatchRequest(session->srv_obj_holder.Clone(), session, in_message, out_message); + return this->DispatchRequest(session->m_srv_obj_holder.Clone(), session, in_message, out_message); case CmifCommandType_Control: case CmifCommandType_ControlWithContext: return this->DispatchManagerRequest(session, in_message, out_message); @@ -290,7 +290,7 @@ namespace ams::sf::hipc { .session = session, .processor = nullptr, /* Filled in by template implementations. */ .handles_to_close = std::addressof(handles_to_close), - .pointer_buffer = session->pointer_buffer, + .pointer_buffer = session->m_pointer_buffer, .in_message_buffer = in_message, .out_message_buffer = out_message, .request = hipcParseRequest(in_message.GetPointer()), @@ -320,7 +320,7 @@ namespace ams::sf::hipc { os::CloseNativeHandle(handles_to_close.handles[i]); } }; - R_TRY(hipc::Reply(session->session_handle, out_message)); + R_TRY(hipc::Reply(session->m_session_handle, out_message)); } return ResultSuccess(); diff --git a/libraries/libstratosphere/source/spl/smc/spl_smc.cpp b/libraries/libstratosphere/source/spl/smc/spl_smc.cpp index b6416eed0..3233074a6 100644 --- a/libraries/libstratosphere/source/spl/smc/spl_smc.cpp +++ b/libraries/libstratosphere/source/spl/smc/spl_smc.cpp @@ -23,7 +23,7 @@ namespace ams::spl::smc { args.r[0] = static_cast(FunctionId::SetConfig); args.r[1] = static_cast(which); args.r[2] = reinterpret_cast(address); - for (size_t i = 0; i < std::min(size_t(4), num_qwords); i++) { + for (size_t i = 0; i < std::min(static_cast(4), num_qwords); i++) { args.r[3 + i] = value[i]; } svc::CallSecureMonitor(std::addressof(args)); @@ -38,7 +38,7 @@ namespace ams::spl::smc { args.r[1] = static_cast(which); svc::CallSecureMonitor(std::addressof(args)); - for (size_t i = 0; i < std::min(size_t(4), num_qwords); i++) { + for (size_t i = 0; i < std::min(static_cast(4), num_qwords); i++) { out[i] = args.r[1 + i]; } return static_cast(args.r[0]); @@ -221,7 +221,7 @@ namespace ams::spl::smc { args.r[1] = reinterpret_cast(base); args.r[2] = reinterpret_cast(mod); std::memset(std::addressof(args.r[3]), 0, 4 * sizeof(args.r[3])); - std::memcpy(std::addressof(args.r[3]), label_digest, std::min(size_t(4 * sizeof(args.r[3])), label_digest_size)); + std::memcpy(std::addressof(args.r[3]), label_digest, std::min(static_cast(4 * sizeof(args.r[3])), label_digest_size)); args.r[7] = option; svc::CallSecureMonitor(std::addressof(args)); diff --git a/libraries/libstratosphere/source/updater/updater_bis_management.cpp b/libraries/libstratosphere/source/updater/updater_bis_management.cpp index 5dc96ee79..1cfe0f639 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_management.cpp +++ b/libraries/libstratosphere/source/updater/updater_bis_management.cpp @@ -49,7 +49,7 @@ namespace ams::updater { } Result BisAccessor::Initialize() { - return fs::OpenBisPartition(std::addressof(this->storage), this->partition_id); + return fs::OpenBisPartition(std::addressof(m_storage), m_partition_id); } void BisAccessor::Finalize() { @@ -58,12 +58,12 @@ namespace ams::updater { Result BisAccessor::Read(void *dst, size_t size, u64 offset) { AMS_ABORT_UNLESS((offset % SectorAlignment) == 0); - return this->storage->Read(static_cast(offset), dst, size); + return m_storage->Read(static_cast(offset), dst, size); } Result BisAccessor::Write(u64 offset, const void *src, size_t size) { AMS_ABORT_UNLESS((offset % SectorAlignment) == 0); - return this->storage->Write(static_cast(offset), src, size); + return m_storage->Write(static_cast(offset), src, size); } Result BisAccessor::Write(u64 offset, size_t size, const char *bip_path, void *work_buffer, size_t work_buffer_size) { diff --git a/libraries/libstratosphere/source/updater/updater_bis_management.hpp b/libraries/libstratosphere/source/updater/updater_bis_management.hpp index 674259cfb..7e9bcb169 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_management.hpp +++ b/libraries/libstratosphere/source/updater/updater_bis_management.hpp @@ -24,10 +24,10 @@ namespace ams::updater { public: static constexpr size_t SectorAlignment = 0x200; private: - std::unique_ptr storage; - const fs::BisPartitionId partition_id; + std::unique_ptr m_storage; + const fs::BisPartitionId m_partition_id; public: - explicit BisAccessor(fs::BisPartitionId id) : partition_id(id) { /* ... */ } + explicit BisAccessor(fs::BisPartitionId id) : m_partition_id(id) { /* ... */ } public: Result Initialize(); diff --git a/libraries/libstratosphere/source/updater/updater_bis_save.cpp b/libraries/libstratosphere/source/updater/updater_bis_save.cpp index 20387e062..5515ba3bd 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_save.cpp +++ b/libraries/libstratosphere/source/updater/updater_bis_save.cpp @@ -34,30 +34,30 @@ namespace ams::updater { AMS_ABORT_UNLESS(util::IsAligned(reinterpret_cast(work_buffer), os::MemoryPageSize)); AMS_ABORT_UNLESS(util::IsAligned(work_buffer_size, 0x200)); - R_TRY(this->accessor.Initialize()); - this->save_buffer = work_buffer; + R_TRY(m_accessor.Initialize()); + m_save_buffer = work_buffer; return ResultSuccess(); } void BisSave::Finalize() { - this->accessor.Finalize(); + m_accessor.Finalize(); } Result BisSave::Load() { size_t read_size; - return this->accessor.Read(&read_size, this->save_buffer, SaveSize, Boot0Partition::BctSave); + return m_accessor.Read(std::addressof(read_size), m_save_buffer, SaveSize, Boot0Partition::BctSave); } Result BisSave::Save() { - return this->accessor.Write(this->save_buffer, SaveSize, Boot0Partition::BctSave); + return m_accessor.Write(m_save_buffer, SaveSize, Boot0Partition::BctSave); } bool BisSave::GetNeedsVerification(BootModeType mode) { - return reinterpret_cast(this->save_buffer)[GetVerificationFlagOffset(mode)] != 0; + return reinterpret_cast(m_save_buffer)[GetVerificationFlagOffset(mode)] != 0; } void BisSave::SetNeedsVerification(BootModeType mode, bool needs_verification) { - reinterpret_cast(this->save_buffer)[GetVerificationFlagOffset(mode)] = needs_verification ? 1 : 0; + reinterpret_cast(m_save_buffer)[GetVerificationFlagOffset(mode)] = needs_verification ? 1 : 0; } } diff --git a/libraries/libstratosphere/source/updater/updater_bis_save.hpp b/libraries/libstratosphere/source/updater/updater_bis_save.hpp index 86423fe1e..301c3b149 100644 --- a/libraries/libstratosphere/source/updater/updater_bis_save.hpp +++ b/libraries/libstratosphere/source/updater/updater_bis_save.hpp @@ -23,10 +23,10 @@ namespace ams::updater { public: static constexpr size_t SaveSize = BctSize; private: - Boot0Accessor accessor; - void *save_buffer; + Boot0Accessor m_accessor; + void *m_save_buffer; public: - BisSave() : save_buffer(nullptr) { } + BisSave() : m_accessor(), m_save_buffer(nullptr) { } private: static size_t GetVerificationFlagOffset(BootModeType mode); public: diff --git a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp index 6e2af5fb2..a56efd711 100644 --- a/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp +++ b/stratosphere/ams_mitm/source/dns_mitm/dnsmitm_resolver_impl.cpp @@ -91,14 +91,14 @@ namespace ams::mitm::socket::resolver { const char *hostname = reinterpret_cast(name.GetPointer()); - LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname); + LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", m_client_info.program_id.value, hostname); R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession()); ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession()); - LogDebug("[%016lx]: Redirecting %s to %u.%u.%u.%u\n", this->client_info.program_id.value, hostname, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); + LogDebug("[%016lx]: Redirecting %s to %u.%u.%u.%u\n", m_client_info.program_id.value, hostname, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); const auto size = SerializeRedirectedHostEnt(out_hostent.GetPointer(), out_hostent.GetSize(), hostname, redirect_addr); *out_host_error = 0; @@ -113,7 +113,7 @@ namespace ams::mitm::socket::resolver { const char *hostname = reinterpret_cast(node.GetPointer()); - LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", this->client_info.program_id.value, reinterpret_cast(node.GetPointer()), reinterpret_cast(srv.GetPointer())); + LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", m_client_info.program_id.value, reinterpret_cast(node.GetPointer()), reinterpret_cast(srv.GetPointer())); R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession()); @@ -129,7 +129,7 @@ namespace ams::mitm::socket::resolver { } } - LogDebug("[%016lx]: Redirecting %s:%u to %u.%u.%u.%u\n", this->client_info.program_id.value, hostname, port, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); + LogDebug("[%016lx]: Redirecting %s:%u to %u.%u.%u.%u\n", m_client_info.program_id.value, hostname, port, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); const bool use_hint = serialized_hint.GetPointer() != nullptr; struct addrinfo hint = {}; @@ -152,14 +152,14 @@ namespace ams::mitm::socket::resolver { const char *hostname = reinterpret_cast(name.GetPointer()); - LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname); + LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", m_client_info.program_id.value, hostname); R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession()); ams::socket::InAddrT redirect_addr = {}; R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession()); - LogDebug("[%016lx]: Redirecting %s to %u.%u.%u.%u\n", this->client_info.program_id.value, hostname, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); + LogDebug("[%016lx]: Redirecting %s to %u.%u.%u.%u\n", m_client_info.program_id.value, hostname, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); const auto size = SerializeRedirectedHostEnt(out_hostent.GetPointer(), out_hostent.GetSize(), hostname, redirect_addr); *out_host_error = 0; @@ -174,7 +174,7 @@ namespace ams::mitm::socket::resolver { const char *hostname = reinterpret_cast(node.GetPointer()); - LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", this->client_info.program_id.value, hostname, reinterpret_cast(srv.GetPointer())); + LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", m_client_info.program_id.value, hostname, reinterpret_cast(srv.GetPointer())); R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession()); @@ -190,7 +190,7 @@ namespace ams::mitm::socket::resolver { } } - LogDebug("[%016lx]: Redirecting %s:%u to %u.%u.%u.%u\n", this->client_info.program_id.value, hostname, port, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); + LogDebug("[%016lx]: Redirecting %s:%u to %u.%u.%u.%u\n", m_client_info.program_id.value, hostname, port, (redirect_addr >> 0) & 0xFF, (redirect_addr >> 8) & 0xFF, (redirect_addr >> 16) & 0xFF, (redirect_addr >> 24) & 0xFF); const bool use_hint = serialized_hint.GetPointer() != nullptr; struct addrinfo hint = {}; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp index 39d2819b0..84a3bfa5f 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fs_mitm_service.cpp @@ -217,21 +217,21 @@ namespace ams::mitm::fs { } Result FsMitmService::OpenFileSystemWithPatch(sf::Out> out, ncm::ProgramId program_id, u32 _filesystem_type) { - return OpenWebContentFileSystem(out, this->client_info.program_id, program_id, static_cast(_filesystem_type), this->forward_service.get(), nullptr, false, this->client_info.override_status.IsProgramSpecific()); + return OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), nullptr, false, m_client_info.override_status.IsProgramSpecific()); } Result FsMitmService::OpenFileSystemWithId(sf::Out> out, const fssrv::sf::Path &path, ncm::ProgramId program_id, u32 _filesystem_type) { - return OpenWebContentFileSystem(out, this->client_info.program_id, program_id, static_cast(_filesystem_type), this->forward_service.get(), std::addressof(path), true, this->client_info.override_status.IsProgramSpecific()); + return OpenWebContentFileSystem(out, m_client_info.program_id, program_id, static_cast(_filesystem_type), m_forward_service.get(), std::addressof(path), true, m_client_info.override_status.IsProgramSpecific()); } Result FsMitmService::OpenSdCardFileSystem(sf::Out> out) { /* We only care about redirecting this for NS/emummc. */ - R_UNLESS(this->client_info.program_id == ncm::SystemProgramId::Ns, sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(m_client_info.program_id == ncm::SystemProgramId::Ns, sm::mitm::ResultShouldForwardToSession()); R_UNLESS(emummc::IsActive(), sm::mitm::ResultShouldForwardToSession()); /* Create a new SD card filesystem. */ FsFileSystem sd_fs; - R_TRY(fsOpenSdCardFileSystemFwd(this->forward_service.get(), std::addressof(sd_fs))); + R_TRY(fsOpenSdCardFileSystemFwd(m_forward_service.get(), std::addressof(sd_fs))); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(sd_fs.s))}; /* Return output filesystem. */ @@ -242,14 +242,14 @@ namespace ams::mitm::fs { Result FsMitmService::OpenSaveDataFileSystem(sf::Out> out, u8 _space_id, const fs::SaveDataAttribute &attribute) { /* We only want to intercept saves for games, right now. */ - const bool is_game_or_hbl = this->client_info.override_status.IsHbl() || ncm::IsApplicationId(this->client_info.program_id); + const bool is_game_or_hbl = m_client_info.override_status.IsHbl() || ncm::IsApplicationId(m_client_info.program_id); R_UNLESS(is_game_or_hbl, sm::mitm::ResultShouldForwardToSession()); /* Only redirect if the appropriate system setting is set. */ R_UNLESS(GetSettingsItemBooleanValue("atmosphere", "fsmitm_redirect_saves_to_sd"), sm::mitm::ResultShouldForwardToSession()); /* Only redirect if the specific title being accessed has a redirect save flag. */ - R_UNLESS(cfg::HasContentSpecificFlag(this->client_info.program_id, "redirect_save"), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(cfg::HasContentSpecificFlag(m_client_info.program_id, "redirect_save"), sm::mitm::ResultShouldForwardToSession()); /* Only redirect account savedata. */ R_UNLESS(attribute.type == fs::SaveDataType::Account, sm::mitm::ResultShouldForwardToSession()); @@ -260,7 +260,7 @@ namespace ams::mitm::fs { /* Verify we can open the save. */ static_assert(sizeof(fs::SaveDataAttribute) == sizeof(::FsSaveDataAttribute)); FsFileSystem save_fs; - R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(this->forward_service.get(), std::addressof(save_fs), space_id, reinterpret_cast(std::addressof(attribute)))), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(R_SUCCEEDED(fsOpenSaveDataFileSystemFwd(m_forward_service.get(), std::addressof(save_fs), space_id, reinterpret_cast(std::addressof(attribute)))), sm::mitm::ResultShouldForwardToSession()); std::unique_ptr save_ifs = std::make_unique(save_fs); /* Mount the SD card using fs.mitm's session. */ @@ -270,7 +270,7 @@ namespace ams::mitm::fs { std::shared_ptr sd_ifs = std::make_shared(sd_fs); /* Verify that we can open the save directory, and that it exists. */ - const ncm::ProgramId application_id = attribute.program_id == ncm::InvalidProgramId ? this->client_info.program_id : attribute.program_id; + const ncm::ProgramId application_id = attribute.program_id == ncm::InvalidProgramId ? m_client_info.program_id : attribute.program_id; char save_dir_path[fs::EntryNameLengthMax + 1]; R_TRY(mitm::fs::SaveUtil::GetDirectorySaveDataPath(save_dir_path, sizeof(save_dir_path), application_id, space_id, attribute)); @@ -310,11 +310,11 @@ namespace ams::mitm::fs { /* Try to open a storage for the partition. */ FsStorage bis_storage; - R_TRY(fsOpenBisStorageFwd(this->forward_service.get(), std::addressof(bis_storage), bis_partition_id)); + R_TRY(fsOpenBisStorageFwd(m_forward_service.get(), std::addressof(bis_storage), bis_partition_id)); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(bis_storage.s))}; - const bool is_sysmodule = ncm::IsSystemProgramId(this->client_info.program_id); - const bool is_hbl = this->client_info.override_status.IsHbl(); + const bool is_sysmodule = ncm::IsSystemProgramId(m_client_info.program_id); + const bool is_hbl = m_client_info.override_status.IsHbl(); const bool can_write_bis = is_sysmodule || (is_hbl && GetSettingsItemBooleanValue("atmosphere", "enable_hbl_bis_write")); /* Allow HBL to write to boot1 (safe firm) + package2. */ @@ -327,12 +327,12 @@ namespace ams::mitm::fs { /* Set output storage. */ if (bis_partition_id == FsBisPartitionId_BootPartition1Root) { if (IsBoot0CustomPublicKey(bis_storage)) { - out.SetValue(MakeSharedStorage(new CustomPublicKeyBoot0Storage(bis_storage, this->client_info, spl::GetSocType())), target_object_id); + out.SetValue(MakeSharedStorage(new CustomPublicKeyBoot0Storage(bis_storage, m_client_info, spl::GetSocType())), target_object_id); } else { - out.SetValue(MakeSharedStorage(new Boot0Storage(bis_storage, this->client_info)), target_object_id); + out.SetValue(MakeSharedStorage(new Boot0Storage(bis_storage, m_client_info)), target_object_id); } } else if (bis_partition_id == FsBisPartitionId_CalibrationBinary) { - out.SetValue(MakeSharedStorage(new CalibrationBinaryStorage(bis_storage, this->client_info)), target_object_id); + out.SetValue(MakeSharedStorage(new CalibrationBinaryStorage(bis_storage, m_client_info)), target_object_id); } else { if (can_write_bis || can_write_bis_for_choi_support) { /* We can write, so create a writable storage. */ @@ -348,14 +348,14 @@ namespace ams::mitm::fs { Result FsMitmService::OpenDataStorageByCurrentProcess(sf::Out> out) { /* Only mitm if we should override contents for the current process. */ - R_UNLESS(this->client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(m_client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); /* Only mitm if there is actually an override romfs. */ - R_UNLESS(mitm::fs::HasSdRomfsContent(this->client_info.program_id), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(mitm::fs::HasSdRomfsContent(m_client_info.program_id), sm::mitm::ResultShouldForwardToSession()); /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageByCurrentProcessFwd(this->forward_service.get(), std::addressof(data_storage))); + R_TRY(fsOpenDataStorageByCurrentProcessFwd(m_forward_service.get(), std::addressof(data_storage))); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ @@ -363,7 +363,7 @@ namespace ams::mitm::fs { /* Try to get a storage from the cache. */ { - std::shared_ptr cached_storage = GetStorageCacheEntry(this->client_info.program_id); + std::shared_ptr cached_storage = GetStorageCacheEntry(m_client_info.program_id); if (cached_storage != nullptr) { out.SetValue(MakeSharedStorage(cached_storage), target_object_id); return ResultSuccess(); @@ -376,17 +376,17 @@ namespace ams::mitm::fs { /* Create the layered storage. */ FsFile data_file; - if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), this->client_info.program_id, "romfs.bin", OpenMode_Read))) { - auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), std::make_unique(new FileStorage(new RemoteFile(data_file))), this->client_info.program_id); + if (R_SUCCEEDED(OpenAtmosphereSdFile(std::addressof(data_file), m_client_info.program_id, "romfs.bin", OpenMode_Read))) { + auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), std::make_unique(new FileStorage(new RemoteFile(data_file))), m_client_info.program_id); layered_storage->BeginInitialize(); new_storage = std::move(layered_storage); } else { - auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), nullptr, this->client_info.program_id); + auto layered_storage = std::make_shared(std::make_unique(new RemoteStorage(data_storage)), nullptr, m_client_info.program_id); layered_storage->BeginInitialize(); new_storage = std::move(layered_storage); } - SetStorageCacheEntry(this->client_info.program_id, std::addressof(new_storage)); + SetStorageCacheEntry(m_client_info.program_id, std::addressof(new_storage)); out.SetValue(MakeSharedStorage(new_storage), target_object_id); } @@ -395,7 +395,7 @@ namespace ams::mitm::fs { Result FsMitmService::OpenDataStorageByDataId(sf::Out> out, ncm::DataId _data_id, u8 storage_id) { /* Only mitm if we should override contents for the current process. */ - R_UNLESS(this->client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(m_client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); /* TODO: Decide how to handle DataId vs ProgramId for this API. */ const ncm::ProgramId data_id = {_data_id.value}; @@ -405,7 +405,7 @@ namespace ams::mitm::fs { /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageByDataIdFwd(this->forward_service.get(), std::addressof(data_storage), static_cast(data_id), static_cast(storage_id))); + R_TRY(fsOpenDataStorageByDataIdFwd(m_forward_service.get(), std::addressof(data_storage), static_cast(data_id), static_cast(storage_id))); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ @@ -445,10 +445,10 @@ namespace ams::mitm::fs { Result FsMitmService::OpenDataStorageWithProgramIndex(sf::Out> out, u8 program_index) { /* Only mitm if we should override contents for the current process. */ - R_UNLESS(this->client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(m_client_info.override_status.IsProgramSpecific(), sm::mitm::ResultShouldForwardToSession()); /* Get the relevant program id. */ - const ncm::ProgramId program_id = g_program_index_map_info_manager.GetProgramId(this->client_info.program_id, program_index); + const ncm::ProgramId program_id = g_program_index_map_info_manager.GetProgramId(m_client_info.program_id, program_index); /* If we don't know about the program or don't have content, forward. */ R_UNLESS(program_id != ncm::InvalidProgramId, sm::mitm::ResultShouldForwardToSession()); @@ -456,7 +456,7 @@ namespace ams::mitm::fs { /* Try to open the process romfs. */ FsStorage data_storage; - R_TRY(fsOpenDataStorageWithProgramIndexFwd(this->forward_service.get(), std::addressof(data_storage), program_index)); + R_TRY(fsOpenDataStorageWithProgramIndexFwd(m_forward_service.get(), std::addressof(data_storage), program_index)); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(data_storage.s))}; /* Get a scoped lock. */ @@ -496,7 +496,7 @@ namespace ams::mitm::fs { Result FsMitmService::RegisterProgramIndexMapInfo(const sf::InBuffer &info_buffer, s32 info_count) { /* Try to register with FS. */ - R_TRY(fsRegisterProgramIndexMapInfoFwd(this->forward_service.get(), info_buffer.GetPointer(), info_buffer.GetSize(), info_count)); + R_TRY(fsRegisterProgramIndexMapInfoFwd(m_forward_service.get(), info_buffer.GetPointer(), info_buffer.GetSize(), info_count)); /* Register with ourselves. */ R_ABORT_UNLESS(g_program_index_map_info_manager.Reset(reinterpret_cast(info_buffer.GetPointer()), info_count)); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp index eb5542ba4..f3fa77d6e 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.cpp @@ -22,9 +22,9 @@ namespace ams::mitm::fs { namespace { - os::SdkMutex g_boot0_access_mutex; + constinit os::SdkMutex g_boot0_access_mutex; constinit bool g_custom_public_key = false; - u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset]; + constinit u8 g_boot0_bct_buffer[Boot0Storage::BctEndOffset]; /* Recognize special public key (https://gist.github.com/SciresM/16b63ac1d80494522bdba2c57995257c). */ /* P = 19 */ @@ -59,11 +59,11 @@ namespace ams::mitm::fs { /* RCM bug patched. */ /* Only allow NS to update the BCT pubks. */ /* AutoRCM on a patched unit will cause a brick, so homebrew should NOT be allowed to write. */ - return this->client_info.program_id == ncm::SystemProgramId::Ns; + return m_client_info.program_id == ncm::SystemProgramId::Ns; } else { /* RCM bug unpatched. */ /* Allow homebrew but not NS to update the BCT pubks. */ - return this->client_info.override_status.IsHbl(); + return m_client_info.override_status.IsHbl(); } } @@ -139,7 +139,7 @@ namespace ams::mitm::fs { return Base::Write(0, g_boot0_bct_buffer, BctEndOffset); } - CustomPublicKeyBoot0Storage::CustomPublicKeyBoot0Storage(FsStorage &s, const sm::MitmProcessInfo &c, spl::SocType soc) : Base(s), client_info(c), soc_type(soc) { + CustomPublicKeyBoot0Storage::CustomPublicKeyBoot0Storage(FsStorage &s, const sm::MitmProcessInfo &c, spl::SocType soc) : Base(s), m_client_info(c), m_soc_type(soc) { std::scoped_lock lk{g_boot0_access_mutex}; /* We're custom public key. */ @@ -157,7 +157,7 @@ namespace ams::mitm::fs { /* Check if we're reading the first BCTs for NS. */ /* If we are, we want to lie about the contents of BCT0/1 so that they validate. */ - if (offset < 0x8000 && this->client_info.program_id == ncm::SystemProgramId::Ns) { + if (offset < 0x8000 && m_client_info.program_id == ncm::SystemProgramId::Ns) { R_TRY(Base::Read(0, g_boot0_bct_buffer, Boot0Storage::BctEndOffset)); /* Determine the readable size. */ @@ -207,7 +207,7 @@ namespace ams::mitm::fs { } /* On erista, we want to protect the EKS region. */ - if (this->soc_type == spl::SocType_Erista) { + if (m_soc_type == spl::SocType_Erista) { if (offset <= Boot0Storage::EksStart) { if (offset + size < Boot0Storage::EksStart) { /* Fall through, no need to do anything here. */ diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp index 533bd0e0b..f60439f97 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_boot0storage.hpp @@ -23,7 +23,7 @@ namespace ams::mitm::fs { class SectoredStorageAdapter : public Base { static_assert(std::is_base_of::value); private: - u8 sector_buf[SectorSize]; + u8 m_sector_buf[SectorSize]; public: /* Inherit constructors. */ using Base::Base; @@ -44,15 +44,15 @@ namespace ams::mitm::fs { return Base::Read(offset, buffer, size); } - R_TRY(Base::Read(seek, this->sector_buf, SectorSize)); + R_TRY(Base::Read(seek, m_sector_buf, SectorSize)); if (size + sector_ofs <= SectorSize) { /* Staying within the sector. */ - std::memcpy(buffer, this->sector_buf + sector_ofs, size); + std::memcpy(buffer, m_sector_buf + sector_ofs, size); } else { /* Leaving the sector. */ const size_t size_in_sector = SectorSize - sector_ofs; - std::memcpy(buffer, this->sector_buf + sector_ofs, size_in_sector); + std::memcpy(buffer, m_sector_buf + sector_ofs, size_in_sector); size -= size_in_sector; /* Read as many guaranteed aligned sectors as we can. */ @@ -64,8 +64,8 @@ namespace ams::mitm::fs { /* Read any leftover data. */ if (size) { - R_TRY(Base::Read(offset + size_in_sector + aligned_remaining_size, this->sector_buf, SectorSize)); - std::memcpy(buffer + size_in_sector + aligned_remaining_size, this->sector_buf, size); + R_TRY(Base::Read(offset + size_in_sector + aligned_remaining_size, m_sector_buf, SectorSize)); + std::memcpy(buffer + size_in_sector + aligned_remaining_size, m_sector_buf, size); } } @@ -89,17 +89,17 @@ namespace ams::mitm::fs { } /* Load existing sector data. */ - R_TRY(Base::Read(seek, this->sector_buf, SectorSize)); + R_TRY(Base::Read(seek, m_sector_buf, SectorSize)); if (size + sector_ofs <= SectorSize) { /* Staying within the sector. */ - std::memcpy(this->sector_buf + sector_ofs, buffer, size); - R_TRY(Base::Write(seek, this->sector_buf, SectorSize)); + std::memcpy(m_sector_buf + sector_ofs, buffer, size); + R_TRY(Base::Write(seek, m_sector_buf, SectorSize)); } else { /* Leaving the sector. */ const size_t size_in_sector = SectorSize - sector_ofs; - std::memcpy(this->sector_buf + sector_ofs, buffer, size_in_sector); - R_TRY(Base::Write(seek, this->sector_buf, SectorSize)); + std::memcpy(m_sector_buf + sector_ofs, buffer, size_in_sector); + R_TRY(Base::Write(seek, m_sector_buf, SectorSize)); size -= size_in_sector; /* Write as many guaranteed aligned sectors as we can. */ @@ -111,9 +111,9 @@ namespace ams::mitm::fs { /* Write any leftover data. */ if (size) { - R_TRY(Base::Read(offset + size_in_sector + aligned_remaining_size, this->sector_buf, SectorSize)); - std::memcpy(this->sector_buf, buffer + size_in_sector + aligned_remaining_size, size); - R_TRY(Base::Write(offset + size_in_sector + aligned_remaining_size, this->sector_buf, SectorSize)); + R_TRY(Base::Read(offset + size_in_sector + aligned_remaining_size, m_sector_buf, SectorSize)); + std::memcpy(m_sector_buf, buffer + size_in_sector + aligned_remaining_size, size); + R_TRY(Base::Write(offset + size_in_sector + aligned_remaining_size, m_sector_buf, SectorSize)); } } @@ -136,11 +136,11 @@ namespace ams::mitm::fs { static constexpr s64 EksSize = static_cast(ams::updater::EksSize); static constexpr s64 EksEnd = EksStart + EksSize; private: - sm::MitmProcessInfo client_info; + sm::MitmProcessInfo m_client_info; private: bool CanModifyBctPublicKey(); public: - Boot0Storage(FsStorage &s, const sm::MitmProcessInfo &c) : Base(s), client_info(c) { /* ... */ } + Boot0Storage(FsStorage &s, const sm::MitmProcessInfo &c) : Base(s), m_client_info(c) { /* ... */ } public: virtual Result Read(s64 offset, void *_buffer, size_t size) override; virtual Result Write(s64 offset, const void *_buffer, size_t size) override; @@ -150,8 +150,8 @@ namespace ams::mitm::fs { public: using Base = SectoredStorageAdapter; private: - sm::MitmProcessInfo client_info; - spl::SocType soc_type; + sm::MitmProcessInfo m_client_info; + spl::SocType m_soc_type; public: CustomPublicKeyBoot0Storage(FsStorage &s, const sm::MitmProcessInfo &c, spl::SocType soc); public: diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp index c97f77230..3e57bf9fe 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.cpp @@ -36,7 +36,7 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Handle the blank region. */ - if (this->read_blank) { + if (m_read_blank) { if (BlankStartOffset <= offset && offset < BlankEndOffset) { const size_t blank_size = std::min(size, static_cast(BlankEndOffset - offset)); mitm::ReadFromBlankCalibrationBinary(offset, buffer, blank_size); @@ -88,10 +88,10 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Only allow writes if we should. */ - R_UNLESS(this->allow_writes, fs::ResultUnsupportedOperation()); + R_UNLESS(m_allow_writes, fs::ResultUnsupportedOperation()); /* Handle the blank region. */ - if (this->read_blank) { + if (m_read_blank) { if (BlankStartOffset <= offset && offset < BlankEndOffset) { const size_t blank_size = std::min(size, static_cast(BlankEndOffset - offset)); mitm::WriteToBlankCalibrationBinary(offset, buffer, blank_size); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.hpp index 331e4e325..9d666547c 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_calibration_binary_storage.hpp @@ -34,14 +34,14 @@ namespace ams::mitm::fs { static constexpr s64 FakeSecureSize = static_cast(SecureCalibrationBinaryBackupSize); static constexpr s64 FakeSecureEndOffset = FakeSecureStartOffset + FakeSecureSize; private: - sm::MitmProcessInfo client_info; - bool read_blank; - bool allow_writes; + sm::MitmProcessInfo m_client_info; + bool m_read_blank; + bool m_allow_writes; public: CalibrationBinaryStorage(FsStorage &s, const sm::MitmProcessInfo &c) - : Base(s), client_info(c), - read_blank(mitm::ShouldReadBlankCalibrationBinary()), - allow_writes(mitm::IsWriteToCalibrationBinaryAllowed()) + : Base(s), m_client_info(c), + m_read_blank(mitm::ShouldReadBlankCalibrationBinary()), + m_allow_writes(mitm::IsWriteToCalibrationBinaryAllowed()) { /* ... */ } diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp index 290c9cbf1..984192168 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.cpp @@ -62,40 +62,40 @@ namespace ams::mitm::fs { using namespace ams::fs; - LayeredRomfsStorage::LayeredRomfsStorage(std::unique_ptr s_r, std::unique_ptr 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) { + LayeredRomfsStorage::LayeredRomfsStorage(std::unique_ptr s_r, std::unique_ptr f_r, ncm::ProgramId pr_id) : m_storage_romfs(std::move(s_r)), m_file_romfs(std::move(f_r)), m_initialize_event(os::EventClearMode_ManualClear), m_program_id(std::move(pr_id)), m_is_initialized(false), m_started_initialize(false) { /* ... */ } LayeredRomfsStorage::~LayeredRomfsStorage() { - for (size_t i = 0; i < this->source_infos.size(); i++) { - this->source_infos[i].Cleanup(); + for (size_t i = 0; i < m_source_infos.size(); i++) { + m_source_infos[i].Cleanup(); } } void LayeredRomfsStorage::BeginInitialize() { - AMS_ABORT_UNLESS(!this->started_initialize); + AMS_ABORT_UNLESS(!m_started_initialize); RequestInitializeStorage(reinterpret_cast(this)); - this->started_initialize = true; + m_started_initialize = true; } void LayeredRomfsStorage::InitializeImpl() { /* Build new virtual romfs. */ - romfs::Builder builder(this->program_id); + romfs::Builder builder(m_program_id); if (mitm::IsInitialized()) { builder.AddSdFiles(); } - if (this->file_romfs) { - builder.AddStorageFiles(this->file_romfs.get(), romfs::DataSourceType::File); + if (m_file_romfs) { + builder.AddStorageFiles(m_file_romfs.get(), romfs::DataSourceType::File); } - if (this->storage_romfs) { - builder.AddStorageFiles(this->storage_romfs.get(), romfs::DataSourceType::Storage); + if (m_storage_romfs) { + builder.AddStorageFiles(m_storage_romfs.get(), romfs::DataSourceType::Storage); } - builder.Build(std::addressof(this->source_infos)); + builder.Build(std::addressof(m_source_infos)); - this->is_initialized = true; - this->initialize_event.Signal(); + m_is_initialized = true; + m_initialize_event.Signal(); } Result LayeredRomfsStorage::Read(s64 offset, void *buffer, size_t size) { @@ -103,8 +103,8 @@ namespace ams::mitm::fs { R_SUCCEED_IF(size == 0); /* Ensure we're initialized. */ - if (!this->is_initialized) { - this->initialize_event.Wait(); + if (!m_is_initialized) { + m_initialize_event.Wait(); } /* Validate offset/size. */ @@ -116,7 +116,7 @@ namespace ams::mitm::fs { } /* Find first source info via binary search. */ - auto it = std::lower_bound(this->source_infos.begin(), this->source_infos.end(), offset); + auto it = std::lower_bound(m_source_infos.begin(), m_source_infos.end(), offset); u8 *cur_dst = static_cast(buffer); /* Our operator < compares against start of info instead of end, so we need to subtract one from lower bound. */ @@ -132,15 +132,15 @@ namespace ams::mitm::fs { const size_t cur_read_size = std::min(size - read_so_far, static_cast(cur_source.size - offset_within_source)); switch (cur_source.source_type) { case romfs::DataSourceType::Storage: - R_ABORT_UNLESS(this->storage_romfs->Read(cur_source.storage_source_info.offset + offset_within_source, cur_dst, cur_read_size)); + R_ABORT_UNLESS(m_storage_romfs->Read(cur_source.storage_source_info.offset + offset_within_source, cur_dst, cur_read_size)); break; case romfs::DataSourceType::File: - R_ABORT_UNLESS(this->file_romfs->Read(cur_source.file_source_info.offset + offset_within_source, cur_dst, cur_read_size)); + R_ABORT_UNLESS(m_file_romfs->Read(cur_source.file_source_info.offset + offset_within_source, cur_dst, cur_read_size)); break; case romfs::DataSourceType::LooseSdFile: { FsFile file; - R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(std::addressof(file), this->program_id, cur_source.loose_source_info.path, OpenMode_Read)); + R_ABORT_UNLESS(mitm::fs::OpenAtmosphereSdRomfsFile(std::addressof(file), m_program_id, cur_source.loose_source_info.path, OpenMode_Read)); ON_SCOPE_EXIT { fsFileClose(std::addressof(file)); }; u64 out_read = 0; @@ -180,8 +180,8 @@ namespace ams::mitm::fs { Result LayeredRomfsStorage::GetSize(s64 *out_size) { /* Ensure we're initialized. */ - if (!this->is_initialized) { - this->initialize_event.Wait(); + if (!m_is_initialized) { + m_initialize_event.Wait(); } *out_size = this->GetSize(); diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp index b4d73b36f..3b4bece74 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_layered_romfs_storage.hpp @@ -22,16 +22,16 @@ namespace ams::mitm::fs { class LayeredRomfsStorage : public std::enable_shared_from_this, public ams::fs::IStorage { private: - std::vector source_infos; - std::unique_ptr storage_romfs; - std::unique_ptr file_romfs; - os::Event initialize_event; - ncm::ProgramId program_id; - bool is_initialized; - bool started_initialize; + std::vector m_source_infos; + std::unique_ptr m_storage_romfs; + std::unique_ptr m_file_romfs; + os::Event m_initialize_event; + ncm::ProgramId m_program_id; + bool m_is_initialized; + bool m_started_initialize; protected: inline s64 GetSize() const { - const auto &back = this->source_infos.back(); + const auto &back = m_source_infos.back(); return back.virtual_offset + back.size; } public: diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp index 27c52ef9e..2ba41ad76 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_readonly_layered_filesystem.hpp @@ -20,10 +20,10 @@ namespace ams::mitm::fs { class ReadOnlyLayeredFileSystem : public ams::fs::fsa::IFileSystem { private: - ams::fs::ReadOnlyFileSystem fs_1; - ams::fs::ReadOnlyFileSystem fs_2; + ams::fs::ReadOnlyFileSystem m_fs_1; + ams::fs::ReadOnlyFileSystem m_fs_2; public: - explicit ReadOnlyLayeredFileSystem(std::unique_ptr a, std::unique_ptr b) : fs_1(std::move(a)), fs_2(std::move(b)) { /* ... */ } + explicit ReadOnlyLayeredFileSystem(std::unique_ptr a, std::unique_ptr b) : m_fs_1(std::move(a)), m_fs_2(std::move(b)) { /* ... */ } virtual ~ReadOnlyLayeredFileSystem() { /* ... */ } private: @@ -63,18 +63,18 @@ namespace ams::mitm::fs { } virtual Result DoGetEntryType(ams::fs::DirectoryEntryType *out, const char *path) override final { - R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetEntryType(out, path))); - return this->fs_2.GetEntryType(out, path); + R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.GetEntryType(out, path))); + return m_fs_2.GetEntryType(out, path); } virtual Result DoOpenFile(std::unique_ptr *out_file, const char *path, ams::fs::OpenMode mode) override final { - R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenFile(out_file, path, mode))); - return this->fs_2.OpenFile(out_file, path, mode); + R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.OpenFile(out_file, path, mode))); + return m_fs_2.OpenFile(out_file, path, mode); } virtual Result DoOpenDirectory(std::unique_ptr *out_dir, const char *path, ams::fs::OpenDirectoryMode mode) override final { - R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.OpenDirectory(out_dir, path, mode))); - return this->fs_2.OpenDirectory(out_dir, path, mode); + R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.OpenDirectory(out_dir, path, mode))); + return m_fs_2.OpenDirectory(out_dir, path, mode); } virtual Result DoCommit() override final { @@ -97,8 +97,8 @@ namespace ams::mitm::fs { } virtual Result DoGetFileTimeStampRaw(ams::fs::FileTimeStampRaw *out, const char *path) { - R_SUCCEED_IF(R_SUCCEEDED(this->fs_1.GetFileTimeStampRaw(out, path))); - return this->fs_2.GetFileTimeStampRaw(out, path); + R_SUCCEED_IF(R_SUCCEEDED(m_fs_1.GetFileTimeStampRaw(out, path))); + return m_fs_2.GetFileTimeStampRaw(out, path); } }; diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp index 60aa8a4a3..2ab144e55 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.cpp @@ -72,26 +72,26 @@ namespace ams::mitm::fs { static constexpr size_t MaxCachedSize = (1_MB / 4); static constexpr size_t FallbackCacheSize = 1_KB; private: - ams::fs::IStorage *storage; - size_t offset; - size_t size; - size_t cache_idx; - void *cache; - u8 fallback_cache[FallbackCacheSize]; + ams::fs::IStorage *m_storage; + size_t m_offset; + size_t m_size; + size_t m_cache_idx; + void *m_cache; + u8 m_fallback_cache[FallbackCacheSize]; private: ALWAYS_INLINE void Read(size_t ofs, void *dst, size_t size) { - R_ABORT_UNLESS(this->storage->Read(this->offset + ofs, dst, size)); + R_ABORT_UNLESS(m_storage->Read(m_offset + ofs, dst, size)); } ALWAYS_INLINE void ReloadCacheImpl(size_t idx) { const size_t rel_ofs = idx * MaxCachedSize; - AMS_ABORT_UNLESS(rel_ofs < this->size); - const size_t new_cache_size = std::min(this->size - rel_ofs, MaxCachedSize); - this->Read(rel_ofs, this->cache, new_cache_size); - this->cache_idx = idx; + AMS_ABORT_UNLESS(rel_ofs < m_size); + const size_t new_cache_size = std::min(m_size - rel_ofs, MaxCachedSize); + this->Read(rel_ofs, m_cache, new_cache_size); + m_cache_idx = idx; } ALWAYS_INLINE void ReloadCache(size_t idx) { - if (this->cache_idx != idx) { + if (m_cache_idx != idx) { this->ReloadCacheImpl(idx); } } @@ -100,14 +100,14 @@ namespace ams::mitm::fs { return ofs / MaxCachedSize; } public: - TableReader(ams::fs::IStorage *s, size_t ofs, size_t sz) : storage(s), offset(ofs), size(sz), cache_idx(0) { - this->cache = std::malloc(std::min(sz, MaxCachedSize)); - AMS_ABORT_UNLESS(this->cache != nullptr); + TableReader(ams::fs::IStorage *s, size_t ofs, size_t sz) : m_storage(s), m_offset(ofs), m_size(sz), m_cache_idx(0) { + m_cache = std::malloc(std::min(sz, MaxCachedSize)); + AMS_ABORT_UNLESS(m_cache != nullptr); this->ReloadCacheImpl(0); } ~TableReader() { - std::free(this->cache); + std::free(m_cache); } const Entry *GetEntry(u32 entry_offset) { @@ -115,10 +115,10 @@ namespace ams::mitm::fs { const size_t ofs = entry_offset % MaxCachedSize; - const Entry *entry = reinterpret_cast(reinterpret_cast(this->cache) + ofs); + const Entry *entry = reinterpret_cast(reinterpret_cast(m_cache) + ofs); if (AMS_UNLIKELY(this->GetCacheIndex(entry_offset) != this->GetCacheIndex(entry_offset + sizeof(Entry) + entry->name_size + sizeof(u32)))) { - this->Read(entry_offset, this->fallback_cache, std::min(this->size - entry_offset, FallbackCacheSize)); - entry = reinterpret_cast(this->fallback_cache); + this->Read(entry_offset, m_fallback_cache, std::min(m_size - entry_offset, FallbackCacheSize)); + entry = reinterpret_cast(m_fallback_cache); } return entry; } @@ -132,38 +132,38 @@ namespace ams::mitm::fs { static constexpr size_t MaxCachedSize = (1_MB / 4); static constexpr size_t FallbackCacheSize = 1_KB; private: - ::FsFile *file; - size_t offset; - size_t size; - size_t cache_idx; - void *cache; - u8 fallback_cache[FallbackCacheSize]; - size_t fallback_cache_entry_offset; - size_t fallback_cache_entry_size; - bool cache_dirty; - bool fallback_cache_dirty; + ::FsFile *m_file; + size_t m_offset; + size_t m_size; + size_t m_cache_idx; + void *m_cache; + u8 m_fallback_cache[FallbackCacheSize]; + size_t m_fallback_cache_entry_offset; + size_t m_fallback_cache_entry_size; + bool m_cache_dirty; + bool m_fallback_cache_dirty; private: ALWAYS_INLINE void Read(size_t ofs, void *dst, size_t sz) { u64 read_size; - R_ABORT_UNLESS(fsFileRead(this->file, this->offset + ofs, dst, sz, 0, std::addressof(read_size))); + R_ABORT_UNLESS(fsFileRead(m_file, m_offset + ofs, dst, sz, 0, std::addressof(read_size))); AMS_ABORT_UNLESS(read_size == sz); } ALWAYS_INLINE void Write(size_t ofs, const void *src, size_t sz) { - R_ABORT_UNLESS(fsFileWrite(this->file, this->offset + ofs, src, sz, FsWriteOption_None)); + R_ABORT_UNLESS(fsFileWrite(m_file, m_offset + ofs, src, sz, FsWriteOption_None)); } ALWAYS_INLINE void Flush() { - AMS_ABORT_UNLESS(!(this->cache_dirty && this->fallback_cache_dirty)); + AMS_ABORT_UNLESS(!(m_cache_dirty && m_fallback_cache_dirty)); - if (this->cache_dirty) { - const size_t ofs = this->cache_idx * MaxCachedSize; - this->Write(ofs, this->cache, std::min(this->size - ofs, MaxCachedSize)); - this->cache_dirty = false; + if (m_cache_dirty) { + const size_t ofs = m_cache_idx * MaxCachedSize; + this->Write(ofs, m_cache, std::min(m_size - ofs, MaxCachedSize)); + m_cache_dirty = false; } - if (this->fallback_cache_dirty) { - this->Write(this->fallback_cache_entry_offset, this->fallback_cache, this->fallback_cache_entry_size); - this->fallback_cache_dirty = false; + if (m_fallback_cache_dirty) { + this->Write(m_fallback_cache_entry_offset, m_fallback_cache, m_fallback_cache_entry_size); + m_fallback_cache_dirty = false; } } @@ -172,32 +172,32 @@ namespace ams::mitm::fs { } ALWAYS_INLINE void RefreshCacheImpl() { - const size_t cur_cache = this->cache_idx * MaxCachedSize; - this->Read(cur_cache, this->cache, std::min(this->size - cur_cache, MaxCachedSize)); + const size_t cur_cache = m_cache_idx * MaxCachedSize; + this->Read(cur_cache, m_cache, std::min(m_size - cur_cache, MaxCachedSize)); } ALWAYS_INLINE void RefreshCache(u32 entry_offset) { - if (size_t idx = this->GetCacheIndex(entry_offset); idx != this->cache_idx || this->fallback_cache_dirty) { + if (size_t idx = this->GetCacheIndex(entry_offset); idx != m_cache_idx || m_fallback_cache_dirty) { this->Flush(); - this->cache_idx = idx; + m_cache_idx = idx; this->RefreshCacheImpl(); } } public: - TableWriter(::FsFile *f, size_t ofs, size_t sz) : file(f), offset(ofs), size(sz), cache_idx(0), fallback_cache_entry_offset(), fallback_cache_entry_size(), cache_dirty(), fallback_cache_dirty() { + TableWriter(::FsFile *f, size_t ofs, size_t sz) : m_file(f), m_offset(ofs), m_size(sz), m_cache_idx(0), m_fallback_cache_entry_offset(), m_fallback_cache_entry_size(), m_cache_dirty(), m_fallback_cache_dirty() { const size_t cache_size = std::min(sz, MaxCachedSize); - this->cache = std::malloc(cache_size); - AMS_ABORT_UNLESS(this->cache != nullptr); - std::memset(this->cache, 0, cache_size); - std::memset(this->fallback_cache, 0, sizeof(this->fallback_cache)); - for (size_t cur = 0; cur < this->size; cur += MaxCachedSize) { - this->Write(cur, this->cache, std::min(this->size - cur, MaxCachedSize)); + m_cache = std::malloc(cache_size); + AMS_ABORT_UNLESS(m_cache != nullptr); + std::memset(m_cache, 0, cache_size); + std::memset(m_fallback_cache, 0, sizeof(m_fallback_cache)); + for (size_t cur = 0; cur < m_size; cur += MaxCachedSize) { + this->Write(cur, m_cache, std::min(m_size - cur, MaxCachedSize)); } } ~TableWriter() { this->Flush(); - std::free(this->cache); + std::free(m_cache); } Entry *GetEntry(u32 entry_offset, u32 name_len) { @@ -205,18 +205,18 @@ namespace ams::mitm::fs { const size_t ofs = entry_offset % MaxCachedSize; - Entry *entry = reinterpret_cast(reinterpret_cast(this->cache) + ofs); + Entry *entry = reinterpret_cast(reinterpret_cast(m_cache) + ofs); if (ofs + sizeof(Entry) + util::AlignUp(name_len, sizeof(u32)) > MaxCachedSize) { this->Flush(); - this->fallback_cache_entry_offset = entry_offset; - this->fallback_cache_entry_size = sizeof(Entry) + util::AlignUp(name_len, sizeof(u32)); - this->Read(this->fallback_cache_entry_offset, this->fallback_cache, this->fallback_cache_entry_size); + m_fallback_cache_entry_offset = entry_offset; + m_fallback_cache_entry_size = sizeof(Entry) + util::AlignUp(name_len, sizeof(u32)); + this->Read(m_fallback_cache_entry_offset, m_fallback_cache, m_fallback_cache_entry_size); - entry = reinterpret_cast(this->fallback_cache); - this->fallback_cache_dirty = true; + entry = reinterpret_cast(m_fallback_cache); + m_fallback_cache_dirty = true; } else { - this->cache_dirty = true; + m_cache_dirty = true; } return entry; @@ -269,12 +269,12 @@ namespace ams::mitm::fs { } - Builder::Builder(ncm::ProgramId pr_id) : program_id(pr_id), num_dirs(0), num_files(0), dir_table_size(0), file_table_size(0), dir_hash_table_size(0), file_hash_table_size(0), file_partition_size(0) { - auto res = this->directories.emplace(std::make_unique(BuildDirectoryContext::RootTag{})); + Builder::Builder(ncm::ProgramId pr_id) : m_program_id(pr_id), m_num_dirs(0), m_num_files(0), m_dir_table_size(0), m_file_table_size(0), m_dir_hash_table_size(0), m_file_hash_table_size(0), m_file_partition_size(0) { + auto res = m_directories.emplace(std::make_unique(BuildDirectoryContext::RootTag{})); AMS_ABORT_UNLESS(res.second); - this->root = res.first->get(); - this->num_dirs = 1; - this->dir_table_size = 0x18; + m_root = res.first->get(); + m_num_dirs = 1; + m_dir_table_size = 0x18; } void Builder::AddDirectory(BuildDirectoryContext **out, BuildDirectoryContext *parent_ctx, std::unique_ptr child_ctx) { @@ -282,18 +282,18 @@ namespace ams::mitm::fs { child_ctx->parent = parent_ctx; /* Check if the directory already exists. */ - auto existing = this->directories.find(child_ctx); - if (existing != this->directories.end()) { + auto existing = m_directories.find(child_ctx); + if (existing != m_directories.end()) { *out = existing->get(); return; } /* Add a new directory. */ - this->num_dirs++; - this->dir_table_size += sizeof(DirectoryEntry) + util::AlignUp(child_ctx->path_len, 4); + m_num_dirs++; + m_dir_table_size += sizeof(DirectoryEntry) + util::AlignUp(child_ctx->path_len, 4); *out = child_ctx.get(); - this->directories.emplace(std::move(child_ctx)); + m_directories.emplace(std::move(child_ctx)); } void Builder::AddFile(BuildDirectoryContext *parent_ctx, std::unique_ptr file_ctx) { @@ -301,14 +301,14 @@ namespace ams::mitm::fs { file_ctx->parent = parent_ctx; /* Check if the file already exists. */ - if (this->files.find(file_ctx) != this->files.end()) { + if (m_files.find(file_ctx) != m_files.end()) { return; } /* Add a new file. */ - this->num_files++; - this->file_table_size += sizeof(FileEntry) + util::AlignUp(file_ctx->path_len, 4); - this->files.emplace(std::move(file_ctx)); + m_num_files++; + m_file_table_size += sizeof(FileEntry) + util::AlignUp(file_ctx->path_len, 4); + m_files.emplace(std::move(file_ctx)); } void Builder::VisitDirectory(FsFileSystem *fs, BuildDirectoryContext *parent) { @@ -317,7 +317,7 @@ namespace ams::mitm::fs { /* Get number of child directories. */ s64 num_child_dirs = 0; { - OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_Directory, fs); + OpenFileSystemRomfsDirectory(std::addressof(dir), m_program_id, parent, OpenDirectoryMode_Directory, fs); ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); }; R_ABORT_UNLESS(fsDirGetEntryCount(std::addressof(dir), std::addressof(num_child_dirs))); } @@ -330,27 +330,27 @@ namespace ams::mitm::fs { s64 cur_child_dir_ind = 0; { - OpenFileSystemRomfsDirectory(std::addressof(dir), this->program_id, parent, OpenDirectoryMode_All, fs); + OpenFileSystemRomfsDirectory(std::addressof(dir), m_program_id, parent, OpenDirectoryMode_All, fs); ON_SCOPE_EXIT { fsDirClose(std::addressof(dir)); }; s64 read_entries = 0; while (true) { - R_ABORT_UNLESS(fsDirRead(std::addressof(dir), std::addressof(read_entries), 1, std::addressof(this->dir_entry))); + R_ABORT_UNLESS(fsDirRead(std::addressof(dir), std::addressof(read_entries), 1, std::addressof(m_dir_entry))); if (read_entries != 1) { break; } - AMS_ABORT_UNLESS(this->dir_entry.type == FsDirEntryType_Dir || this->dir_entry.type == FsDirEntryType_File); - if (this->dir_entry.type == FsDirEntryType_Dir) { + AMS_ABORT_UNLESS(m_dir_entry.type == FsDirEntryType_Dir || m_dir_entry.type == FsDirEntryType_File); + if (m_dir_entry.type == FsDirEntryType_Dir) { AMS_ABORT_UNLESS(child_dirs != nullptr); BuildDirectoryContext *real_child = nullptr; - this->AddDirectory(std::addressof(real_child), parent, std::make_unique(this->dir_entry.name, strlen(this->dir_entry.name))); + this->AddDirectory(std::addressof(real_child), parent, std::make_unique(m_dir_entry.name, strlen(m_dir_entry.name))); AMS_ABORT_UNLESS(real_child != nullptr); child_dirs[cur_child_dir_ind++] = real_child; AMS_ABORT_UNLESS(cur_child_dir_ind <= num_child_dirs); - } else /* if (this->dir_entry.type == FsDirEntryType_File) */ { - this->AddFile(parent, std::make_unique(this->dir_entry.name, strlen(this->dir_entry.name), this->dir_entry.file_size, 0, this->cur_source_type)); + } else /* if (m_dir_entry.type == FsDirEntryType_File) */ { + this->AddFile(parent, std::make_unique(m_dir_entry.name, strlen(m_dir_entry.name), m_dir_entry.file_size, 0, m_cur_source_type)); } } } @@ -380,7 +380,7 @@ namespace ams::mitm::fs { while (cur_file_offset != EmptyEntry) { const FileEntry *cur_file = file_table.GetEntry(cur_file_offset); - this->AddFile(parent, std::make_unique(cur_file->name, cur_file->name_size, cur_file->size, cur_file->offset, this->cur_source_type)); + this->AddFile(parent, std::make_unique(cur_file->name, cur_file->name_size, cur_file->size, cur_file->offset, m_cur_source_type)); cur_file_offset = cur_file->sibling; } @@ -415,14 +415,14 @@ namespace ams::mitm::fs { /* If there is no romfs folder on the SD, don't bother continuing. */ { FsDir dir; - if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(std::addressof(dir), this->program_id, this->root->path.get(), OpenDirectoryMode_Directory, std::addressof(sd_filesystem)))) { + if (R_FAILED(mitm::fs::OpenAtmosphereRomfsDirectory(std::addressof(dir), m_program_id, m_root->path.get(), OpenDirectoryMode_Directory, std::addressof(sd_filesystem)))) { return; } fsDirClose(std::addressof(dir)); } - this->cur_source_type = DataSourceType::LooseSdFile; - this->VisitDirectory(std::addressof(sd_filesystem), this->root); + m_cur_source_type = DataSourceType::LooseSdFile; + this->VisitDirectory(std::addressof(sd_filesystem), m_root); } void Builder::AddStorageFiles(ams::fs::IStorage *storage, DataSourceType source_type) { @@ -434,8 +434,8 @@ namespace ams::mitm::fs { DirectoryTableReader dir_table(storage, header.dir_table_ofs, header.dir_table_size); FileTableReader file_table(storage, header.file_table_ofs, header.file_table_size); - this->cur_source_type = source_type; - this->VisitDirectory(this->root, 0x0, dir_table, file_table); + m_cur_source_type = source_type; + this->VisitDirectory(m_root, 0x0, dir_table, file_table); } void Builder::Build(std::vector *out_infos) { @@ -448,19 +448,19 @@ namespace ams::mitm::fs { ON_SCOPE_EXIT { fsFsClose(std::addressof(sd_filesystem)); }; /* Calculate hash table sizes. */ - const size_t num_dir_hash_table_entries = GetHashTableSize(this->num_dirs); - const size_t num_file_hash_table_entries = GetHashTableSize(this->num_files); - this->dir_hash_table_size = sizeof(u32) * num_dir_hash_table_entries; - this->file_hash_table_size = sizeof(u32) * num_file_hash_table_entries; + const size_t num_dir_hash_table_entries = GetHashTableSize(m_num_dirs); + const size_t num_file_hash_table_entries = GetHashTableSize(m_num_files); + m_dir_hash_table_size = sizeof(u32) * num_dir_hash_table_entries; + m_file_hash_table_size = sizeof(u32) * num_file_hash_table_entries; /* Allocate metadata, make pointers. */ Header *header = reinterpret_cast
(std::malloc(sizeof(Header))); std::memset(header, 0x00, sizeof(*header)); /* Open metadata file. */ - const size_t metadata_size = this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size + this->file_table_size; + const size_t metadata_size = m_dir_hash_table_size + m_dir_table_size + m_file_hash_table_size + m_file_table_size; FsFile metadata_file; - R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(std::addressof(metadata_file), this->program_id, "romfs_metadata.bin", metadata_size)); + R_ABORT_UNLESS(mitm::fs::CreateAndOpenAtmosphereSdFile(std::addressof(metadata_file), m_program_id, "romfs_metadata.bin", metadata_size)); /* Ensure later hash tables will have correct defaults. */ static_assert(EmptyEntry == 0xFFFFFFFF); @@ -473,25 +473,25 @@ namespace ams::mitm::fs { u32 entry_offset = 0; BuildFileContext *cur_file = nullptr; BuildFileContext *prev_file = nullptr; - for (const auto &it : this->files) { + for (const auto &it : m_files) { cur_file = it.get(); /* By default, pad to 0x10 alignment. */ - this->file_partition_size = util::AlignUp(this->file_partition_size, 0x10); + m_file_partition_size = util::AlignUp(m_file_partition_size, 0x10); /* Check if extra padding is present in original source, preserve it to make our life easier. */ const bool is_storage_or_file = cur_file->source_type == DataSourceType::Storage || cur_file->source_type == DataSourceType::File; if (prev_file != nullptr && prev_file->source_type == cur_file->source_type && is_storage_or_file) { - const s64 expected = this->file_partition_size - prev_file->offset + prev_file->orig_offset; + const s64 expected = m_file_partition_size - prev_file->offset + prev_file->orig_offset; if (expected != cur_file->orig_offset) { AMS_ABORT_UNLESS(expected <= cur_file->orig_offset); - this->file_partition_size += cur_file->orig_offset - expected; + m_file_partition_size += cur_file->orig_offset - expected; } } /* Calculate offsets. */ - cur_file->offset = this->file_partition_size; - this->file_partition_size += cur_file->size; + cur_file->offset = m_file_partition_size; + m_file_partition_size += cur_file->size; cur_file->entry_offset = entry_offset; entry_offset += sizeof(FileEntry) + util::AlignUp(cur_file->path_len, 4); @@ -499,7 +499,7 @@ namespace ams::mitm::fs { prev_file = cur_file; } /* Assign deferred parent/sibling ownership. */ - for (auto it = this->files.rbegin(); it != this->files.rend(); it++) { + for (auto it = m_files.rbegin(); it != m_files.rend(); it++) { cur_file = it->get(); cur_file->sibling = cur_file->parent->file; cur_file->parent->file = cur_file; @@ -510,15 +510,15 @@ namespace ams::mitm::fs { { u32 entry_offset = 0; BuildDirectoryContext *cur_dir = nullptr; - for (const auto &it : this->directories) { + for (const auto &it : m_directories) { cur_dir = it.get(); cur_dir->entry_offset = entry_offset; entry_offset += sizeof(DirectoryEntry) + util::AlignUp(cur_dir->path_len, 4); } /* Assign deferred parent/sibling ownership. */ - for (auto it = this->directories.rbegin(); it != this->directories.rend(); it++) { + for (auto it = m_directories.rbegin(); it != m_directories.rend(); it++) { cur_dir = it->get(); - if (cur_dir == this->root) { + if (cur_dir == m_root) { continue; } cur_dir->sibling = cur_dir->parent->child; @@ -529,20 +529,20 @@ namespace ams::mitm::fs { /* Populate file tables. */ { /* Allocate the hash table. */ - void *fht_buf = std::malloc(this->file_hash_table_size); + void *fht_buf = std::malloc(m_file_hash_table_size); AMS_ABORT_UNLESS(fht_buf != nullptr); u32 *file_hash_table = reinterpret_cast(fht_buf); - std::memset(file_hash_table, 0xFF, this->file_hash_table_size); + std::memset(file_hash_table, 0xFF, m_file_hash_table_size); ON_SCOPE_EXIT { - R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size, file_hash_table, this->file_hash_table_size, FsWriteOption_None)); + R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), m_dir_hash_table_size + m_dir_table_size, file_hash_table, m_file_hash_table_size, FsWriteOption_None)); std::free(fht_buf); }; /* Write the file table. */ { - FileTableWriter file_table(std::addressof(metadata_file), this->dir_hash_table_size + this->dir_table_size + this->file_hash_table_size, this->file_table_size); + FileTableWriter file_table(std::addressof(metadata_file), m_dir_hash_table_size + m_dir_table_size + m_file_hash_table_size, m_file_table_size); - for (const auto &it : this->files) { + for (const auto &it : m_files) { BuildFileContext *cur_file = it.get(); FileEntry *cur_entry = file_table.GetEntry(cur_file->entry_offset, cur_file->path_len); @@ -597,25 +597,25 @@ namespace ams::mitm::fs { /* Populate directory tables. */ { /* Allocate the hash table. */ - void *dht_buf = std::malloc(this->dir_hash_table_size); + void *dht_buf = std::malloc(m_dir_hash_table_size); AMS_ABORT_UNLESS(dht_buf != nullptr); u32 *dir_hash_table = reinterpret_cast(dht_buf); - std::memset(dir_hash_table, 0xFF, this->dir_hash_table_size); + std::memset(dir_hash_table, 0xFF, m_dir_hash_table_size); ON_SCOPE_EXIT { - R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), 0, dir_hash_table, this->dir_hash_table_size, FsWriteOption_None)); + R_ABORT_UNLESS(fsFileWrite(std::addressof(metadata_file), 0, dir_hash_table, m_dir_hash_table_size, FsWriteOption_None)); std::free(dht_buf); }; /* Write the file table. */ { - DirectoryTableWriter dir_table(std::addressof(metadata_file), this->dir_hash_table_size, this->dir_table_size); + DirectoryTableWriter dir_table(std::addressof(metadata_file), m_dir_hash_table_size, m_dir_table_size); - for (const auto &it : this->directories) { + for (const auto &it : m_directories) { BuildDirectoryContext *cur_dir = it.get(); DirectoryEntry *cur_entry = dir_table.GetEntry(cur_dir->entry_offset, cur_dir->path_len); /* Set entry fields. */ - cur_entry->parent = cur_dir == this->root ? 0 : cur_dir->parent->entry_offset; + cur_entry->parent = cur_dir == m_root ? 0 : cur_dir->parent->entry_offset; cur_entry->sibling = (cur_dir->sibling == nullptr) ? EmptyEntry : cur_dir->sibling->entry_offset; cur_entry->child = (cur_dir->child == nullptr) ? EmptyEntry : cur_dir->child->entry_offset; cur_entry->file = (cur_dir->file == nullptr) ? EmptyEntry : cur_dir->file->entry_offset; @@ -639,21 +639,21 @@ namespace ams::mitm::fs { } /* Delete maps. */ - this->root = nullptr; - this->directories.clear(); - this->files.clear(); + m_root = nullptr; + m_directories.clear(); + m_files.clear(); /* Set header fields. */ - header->header_size = sizeof(*header); - header->file_hash_table_size = this->file_hash_table_size; - header->file_table_size = this->file_table_size; - header->dir_hash_table_size = this->dir_hash_table_size; - header->dir_table_size = this->dir_table_size; - header->file_partition_ofs = FilePartitionOffset; - header->dir_hash_table_ofs = util::AlignUp(FilePartitionOffset + this->file_partition_size, 4); - header->dir_table_ofs = header->dir_hash_table_ofs + header->dir_hash_table_size; - header->file_hash_table_ofs = header->dir_table_ofs + header->dir_table_size; - header->file_table_ofs = header->file_hash_table_ofs + header->file_hash_table_size; + header->header_size = sizeof(*header); + header->file_hash_table_size = m_file_hash_table_size; + header->file_table_size = m_file_table_size; + header->dir_hash_table_size = m_dir_hash_table_size; + header->dir_table_size = m_dir_table_size; + header->file_partition_ofs = FilePartitionOffset; + header->dir_hash_table_ofs = util::AlignUp(FilePartitionOffset + m_file_partition_size, 4); + header->dir_table_ofs = header->dir_hash_table_ofs + header->dir_hash_table_size; + header->file_hash_table_ofs = header->dir_table_ofs + header->dir_table_size; + header->file_table_ofs = header->file_hash_table_ofs + header->file_hash_table_size; /* Save metadata to the SD card, to save on memory space. */ { diff --git a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.hpp b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.hpp index 7177cf161..c12b21670 100644 --- a/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.hpp +++ b/stratosphere/ams_mitm/source/fs_mitm/fsmitm_romfs.hpp @@ -202,7 +202,7 @@ namespace ams::mitm::fs::romfs { class DirectoryTableReader; class FileTableReader; - struct Builder { + class Builder { NON_COPYABLE(Builder); NON_MOVEABLE(Builder); private: @@ -230,20 +230,20 @@ namespace ams::mitm::fs::romfs { template using ContextSet = std::set, Comparator>; private: - ncm::ProgramId program_id; - BuildDirectoryContext *root; - ContextSet directories; - ContextSet files; - size_t num_dirs; - size_t num_files; - size_t dir_table_size; - size_t file_table_size; - size_t dir_hash_table_size; - size_t file_hash_table_size; - size_t file_partition_size; + ncm::ProgramId m_program_id; + BuildDirectoryContext *m_root; + ContextSet m_directories; + ContextSet m_files; + size_t m_num_dirs; + size_t m_num_files; + size_t m_dir_table_size; + size_t m_file_table_size; + size_t m_dir_hash_table_size; + size_t m_file_hash_table_size; + size_t m_file_partition_size; - ams::fs::DirectoryEntry dir_entry; - DataSourceType cur_source_type; + ams::fs::DirectoryEntry m_dir_entry; + DataSourceType m_cur_source_type; private: void VisitDirectory(FsFileSystem *fs, BuildDirectoryContext *parent); void VisitDirectory(BuildDirectoryContext *parent, u32 parent_offset, DirectoryTableReader &dir_table, FileTableReader &file_table); diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp index 549cc4fbf..c0f9daa68 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_am_mitm_service.cpp @@ -20,7 +20,7 @@ namespace ams::mitm::ns { Result NsAmMitmService::GetApplicationContentPath(const sf::OutBuffer &out_path, ncm::ProgramId application_id, u8 content_type) { - return nsamGetApplicationContentPathFwd(this->forward_service.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); + return nsamGetApplicationContentPathFwd(m_forward_service.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); } Result NsAmMitmService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) { @@ -28,14 +28,14 @@ namespace ams::mitm::ns { /* This enables hbl html. */ bool is_hbl; if (R_SUCCEEDED(pm::info::IsHblProgramId(&is_hbl, application_id)) && is_hbl) { - nsamResolveApplicationContentPathFwd(this->forward_service.get(), static_cast(application_id), static_cast(content_type)); + nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast(application_id), static_cast(content_type)); return ResultSuccess(); } - return nsamResolveApplicationContentPathFwd(this->forward_service.get(), static_cast(application_id), static_cast(content_type)); + return nsamResolveApplicationContentPathFwd(m_forward_service.get(), static_cast(application_id), static_cast(content_type)); } Result NsAmMitmService::GetRunningApplicationProgramId(sf::Out out, ncm::ProgramId application_id) { - return nsamGetRunningApplicationProgramIdFwd(this->forward_service.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); + return nsamGetRunningApplicationProgramIdFwd(m_forward_service.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); } } diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp index 538af7932..d7f10e36b 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.cpp @@ -19,7 +19,7 @@ namespace ams::mitm::ns { Result NsDocumentService::GetApplicationContentPath(const sf::OutBuffer &out_path, ncm::ProgramId application_id, u8 content_type) { - return nswebGetApplicationContentPath(this->srv.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); + return nswebGetApplicationContentPath(m_srv.get(), out_path.GetPointer(), out_path.GetSize(), static_cast(application_id), static_cast(content_type)); } Result NsDocumentService::ResolveApplicationContentPath(ncm::ProgramId application_id, u8 content_type) { @@ -27,23 +27,23 @@ namespace ams::mitm::ns { /* This enables hbl html. */ bool is_hbl; if (R_SUCCEEDED(pm::info::IsHblProgramId(std::addressof(is_hbl), application_id)) && is_hbl) { - nswebResolveApplicationContentPath(this->srv.get(), static_cast(application_id), static_cast(content_type)); + nswebResolveApplicationContentPath(m_srv.get(), static_cast(application_id), static_cast(content_type)); return ResultSuccess(); } - return nswebResolveApplicationContentPath(this->srv.get(), static_cast(application_id), static_cast(content_type)); + return nswebResolveApplicationContentPath(m_srv.get(), static_cast(application_id), static_cast(content_type)); } Result NsDocumentService::GetRunningApplicationProgramId(sf::Out out, ncm::ProgramId application_id) { - return nswebGetRunningApplicationProgramId(this->srv.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); + return nswebGetRunningApplicationProgramId(m_srv.get(), reinterpret_cast(out.GetPointer()), static_cast(application_id)); } Result NsWebMitmService::GetDocumentInterface(sf::Out> out) { /* Open a document interface. */ NsDocumentInterface doc; - R_TRY(nsGetDocumentInterfaceFwd(this->forward_service.get(), std::addressof(doc))); + R_TRY(nsGetDocumentInterfaceFwd(m_forward_service.get(), std::addressof(doc))); const sf::cmif::DomainObjectId target_object_id{serviceGetObjectId(std::addressof(doc.s))}; - out.SetValue(sf::CreateSharedObjectEmplaced(this->client_info, std::make_unique(doc)), target_object_id); + out.SetValue(sf::CreateSharedObjectEmplaced(m_client_info, std::make_unique(doc)), target_object_id); return ResultSuccess(); } diff --git a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp index 76e9b36c8..ced65e0b5 100644 --- a/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/ns_mitm/ns_web_mitm_service.hpp @@ -34,13 +34,13 @@ namespace ams::mitm::ns { class NsDocumentService { private: - sm::MitmProcessInfo client_info; - std::unique_ptr<::NsDocumentInterface> srv; + sm::MitmProcessInfo m_client_info; + std::unique_ptr<::NsDocumentInterface> m_srv; public: - NsDocumentService(const sm::MitmProcessInfo &cl, std::unique_ptr<::NsDocumentInterface> s) : client_info(cl), srv(std::move(s)) { /* .. */ } + NsDocumentService(const sm::MitmProcessInfo &cl, std::unique_ptr<::NsDocumentInterface> s) : m_client_info(cl), m_srv(std::move(s)) { /* .. */ } virtual ~NsDocumentService() { - nsDocumentInterfaceClose(this->srv.get()); + nsDocumentInterfaceClose(m_srv.get()); } public: /* Actual command API. */ diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp index 1130da0da..79b977cd1 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.cpp @@ -30,13 +30,13 @@ namespace ams::mitm::settings { } SetMitmService::SetMitmService(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c) : sf::MitmServiceImplBase(std::forward>(s), c) { - if (this->client_info.program_id == ncm::SystemProgramId::Ns) { + if (m_client_info.program_id == ncm::SystemProgramId::Ns) { os::ProcessId application_process_id; if (R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id))) && g_application_process_id == application_process_id) { - this->locale = g_application_locale; - this->is_valid_language = g_valid_language; - this->is_valid_region = g_valid_region; - this->got_locale = true; + m_locale = g_application_locale; + m_is_valid_language = g_valid_language; + m_is_valid_region = g_valid_region; + m_got_locale = true; } else { this->InvalidateLocale(); } @@ -47,16 +47,16 @@ namespace ams::mitm::settings { Result SetMitmService::EnsureLocale() { /* Optimization: if locale has already been gotten, we can stop. */ - if (AMS_LIKELY(this->got_locale)) { + if (AMS_LIKELY(m_got_locale)) { return ResultSuccess(); } - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - const bool is_ns = this->client_info.program_id == ncm::SystemProgramId::Ns; + const bool is_ns = m_client_info.program_id == ncm::SystemProgramId::Ns; - if (!this->got_locale) { - ncm::ProgramId program_id = this->client_info.program_id; + if (!m_got_locale) { + ncm::ProgramId program_id = m_client_info.program_id; os::ProcessId application_process_id = os::InvalidProcessId; if (is_ns) { @@ -64,15 +64,15 @@ namespace ams::mitm::settings { R_TRY(pm::dmnt::GetApplicationProcessId(std::addressof(application_process_id))); R_TRY(pm::info::GetProgramId(std::addressof(program_id), application_process_id)); } - this->locale = cfg::GetOverrideLocale(program_id); - this->is_valid_language = settings::IsValidLanguageCode(this->locale.language_code); - this->is_valid_region = settings::IsValidRegionCode(this->locale.region_code); - this->got_locale = true; + m_locale = cfg::GetOverrideLocale(program_id); + m_is_valid_language = settings::IsValidLanguageCode(m_locale.language_code); + m_is_valid_region = settings::IsValidRegionCode(m_locale.region_code); + m_got_locale = true; if (is_ns) { - g_application_locale = this->locale; - g_valid_language = this->is_valid_language; - g_valid_region = this->is_valid_region; + g_application_locale = m_locale; + g_valid_language = m_is_valid_language; + g_valid_region = m_is_valid_region; g_application_process_id = application_process_id; } } @@ -81,30 +81,30 @@ namespace ams::mitm::settings { } void SetMitmService::InvalidateLocale() { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); - std::memset(std::addressof(this->locale), 0xCC, sizeof(this->locale)); - this->is_valid_language = false; - this->is_valid_region = false; - this->got_locale = false; + std::memset(std::addressof(m_locale), 0xCC, sizeof(m_locale)); + m_is_valid_language = false; + m_is_valid_region = false; + m_got_locale = false; } Result SetMitmService::GetLanguageCode(sf::Out out) { this->EnsureLocale(); /* If there's no override locale, just use the actual one. */ - if (AMS_UNLIKELY(!this->is_valid_language)) { + if (AMS_UNLIKELY(!m_is_valid_language)) { static_assert(sizeof(u64) == sizeof(settings::LanguageCode)); - R_TRY(setGetLanguageCodeFwd(this->forward_service.get(), reinterpret_cast(std::addressof(this->locale.language_code)))); + R_TRY(setGetLanguageCodeFwd(m_forward_service.get(), reinterpret_cast(std::addressof(m_locale.language_code)))); - this->is_valid_language = true; - if (this->client_info.program_id == ncm::SystemProgramId::Ns) { - g_application_locale.language_code = this->locale.language_code; + m_is_valid_language = true; + if (m_client_info.program_id == ncm::SystemProgramId::Ns) { + g_application_locale.language_code = m_locale.language_code; g_valid_language = true; } } - out.SetValue(this->locale.language_code); + out.SetValue(m_locale.language_code); return ResultSuccess(); } @@ -112,18 +112,18 @@ namespace ams::mitm::settings { this->EnsureLocale(); /* If there's no override locale, just use the actual one. */ - if (AMS_UNLIKELY(!this->is_valid_region)) { + if (AMS_UNLIKELY(!m_is_valid_region)) { static_assert(sizeof(::SetRegion) == sizeof(settings::RegionCode)); - R_TRY(setGetRegionCodeFwd(this->forward_service.get(), reinterpret_cast<::SetRegion *>(std::addressof(this->locale.region_code)))); + R_TRY(setGetRegionCodeFwd(m_forward_service.get(), reinterpret_cast<::SetRegion *>(std::addressof(m_locale.region_code)))); - this->is_valid_region = true; - if (this->client_info.program_id == ncm::SystemProgramId::Ns) { - g_application_locale.region_code = this->locale.region_code; + m_is_valid_region = true; + if (m_client_info.program_id == ncm::SystemProgramId::Ns) { + g_application_locale.region_code = m_locale.region_code; g_valid_region = true; } } - out.SetValue(this->locale.region_code); + out.SetValue(m_locale.region_code); return ResultSuccess(); } diff --git a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp index 1260ff7d4..f65e919ed 100644 --- a/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp +++ b/stratosphere/ams_mitm/source/set_mitm/set_mitm_service.hpp @@ -26,11 +26,11 @@ namespace ams::mitm::settings { class SetMitmService : public sf::MitmServiceImplBase { private: - os::SdkMutex lock{}; - cfg::OverrideLocale locale; - bool got_locale = false; - bool is_valid_language = false; - bool is_valid_region = false; + os::SdkMutex m_lock{}; + cfg::OverrideLocale m_locale; + bool m_got_locale = false; + bool m_is_valid_language = false; + bool m_is_valid_region = false; public: SetMitmService(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &c); public: diff --git a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp index 7885286a2..6dd4d37cc 100644 --- a/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp +++ b/stratosphere/ams_mitm/source/set_mitm/setsys_mitm_service.cpp @@ -90,7 +90,7 @@ namespace ams::mitm::settings { } Result SetSysMitmService::GetFirmwareVersion(sf::Out out) { - R_TRY(GetFirmwareVersionImpl(out.GetPointer(), this->client_info)); + R_TRY(GetFirmwareVersionImpl(out.GetPointer(), m_client_info)); /* GetFirmwareVersion sanitizes the revision fields. */ out.GetPointer()->revision_major = 0; @@ -99,7 +99,7 @@ namespace ams::mitm::settings { } Result SetSysMitmService::GetFirmwareVersion2(sf::Out out) { - return GetFirmwareVersionImpl(out.GetPointer(), this->client_info); + return GetFirmwareVersionImpl(out.GetPointer(), m_client_info); } Result SetSysMitmService::GetSettingsItemValueSize(sf::Out out_size, const settings::SettingsName &name, const settings::SettingsItemKey &key) { @@ -122,7 +122,7 @@ namespace ams::mitm::settings { Result SetSysMitmService::GetDebugModeFlag(sf::Out out) { /* If we're not processing for am, just return the real flag value. */ - R_UNLESS(this->client_info.program_id == ncm::SystemProgramId::Am, sm::mitm::ResultShouldForwardToSession()); + R_UNLESS(m_client_info.program_id == ncm::SystemProgramId::Am, sm::mitm::ResultShouldForwardToSession()); /* Retrieve the user configuration. */ u8 en = 0; diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.cpp index eb6775a46..91770958d 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.cpp @@ -79,7 +79,7 @@ namespace ams::mitm::sysupdater { Result SystemUpdateApplyManager::ApplyPackageTask(ncm::PackageSystemDowngradeTask *task) { /* Lock the apply mutex. */ - std::scoped_lock lk(this->apply_mutex); + std::scoped_lock lk(m_apply_mutex); /* NOTE: Here, Nintendo creates a system report for the update. */ diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.hpp index ddd5615bf..9a71c9487 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_apply_manager.hpp @@ -20,9 +20,9 @@ namespace ams::mitm::sysupdater { class SystemUpdateApplyManager { private: - os::SdkMutex apply_mutex; + os::SdkMutex m_apply_mutex; public: - constexpr SystemUpdateApplyManager() : apply_mutex() { /* ... */ } + constexpr SystemUpdateApplyManager() : m_apply_mutex() { /* ... */ } Result ApplyPackageTask(ncm::PackageSystemDowngradeTask *task); }; diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp index e24b4a4ef..de94f205a 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.cpp @@ -29,10 +29,10 @@ namespace ams::mitm::sysupdater { } AsyncPrepareSdCardUpdateImpl::~AsyncPrepareSdCardUpdateImpl() { - if (this->thread_info) { - os::WaitThread(this->thread_info->thread); - os::DestroyThread(this->thread_info->thread); - GetAsyncThreadAllocator()->Free(*this->thread_info); + if (m_thread_info) { + os::WaitThread(m_thread_info->thread); + os::DestroyThread(m_thread_info->thread); + GetAsyncThreadAllocator()->Free(*m_thread_info); } } @@ -46,16 +46,16 @@ namespace ams::mitm::sysupdater { /* Ensure that we clean up appropriately. */ ON_SCOPE_EXIT { - if (!this->thread_info) { + if (!m_thread_info) { GetAsyncThreadAllocator()->Free(info); } }; /* Create a thread for the task. */ R_TRY(os::CreateThread(info.thread, [](void *arg) { - auto *_this = reinterpret_cast(arg); - _this->result = _this->Execute(); - _this->event.Signal(); + auto *async = reinterpret_cast(arg); + async->m_result = async->Execute(); + async->m_event.Signal(); }, this, info.stack, info.stack_size, info.priority)); /* Set the thread name. */ @@ -65,16 +65,16 @@ namespace ams::mitm::sysupdater { os::StartThread(info.thread); /* Set our thread info. */ - this->thread_info = info; + m_thread_info = info; return ResultSuccess(); } Result AsyncPrepareSdCardUpdateImpl::Execute() { - return this->task->PrepareAndExecute(); + return m_task->PrepareAndExecute(); } void AsyncPrepareSdCardUpdateImpl::CancelImpl() { - this->task->Cancel(); + m_task->Cancel(); } } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp index 071d4150e..81c0e9620 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_async_impl.hpp @@ -21,16 +21,16 @@ namespace ams::mitm::sysupdater { class ErrorContextHolder { private: - err::ErrorContext error_context; + err::ErrorContext m_error_context; public: - constexpr ErrorContextHolder() : error_context{} { /* ... */ } + constexpr ErrorContextHolder() : m_error_context{} { /* ... */ } virtual ~ErrorContextHolder() { /* ... */ } template Result SaveErrorContextIfFailed(T &async, Result result) { if (R_FAILED(result)) { - async.GetErrorContext(std::addressof(this->error_context)); + async.GetErrorContext(std::addressof(m_error_context)); return result; } @@ -46,7 +46,7 @@ namespace ams::mitm::sysupdater { template Result SaveInternalTaskErrorContextIfFailed(T &async, Result result) { if (R_FAILED(result)) { - async.CreateErrorContext(std::addressof(this->error_context)); + async.CreateErrorContext(std::addressof(m_error_context)); return result; } @@ -54,7 +54,7 @@ namespace ams::mitm::sysupdater { } const err::ErrorContext &GetErrorContextImpl() { - return this->error_context; + return m_error_context; } }; @@ -93,15 +93,15 @@ namespace ams::mitm::sysupdater { /* We don't implement the RequestServer::ManagedStop details, as we don't implement stoppable request list. */ class AsyncPrepareSdCardUpdateImpl : public AsyncResultBase, private ErrorContextHolder { private: - Result result; - os::SystemEvent event; - util::optional thread_info; - ncm::InstallTaskBase *task; + Result m_result; + os::SystemEvent m_event; + util::optional m_thread_info; + ncm::InstallTaskBase *m_task; public: - AsyncPrepareSdCardUpdateImpl(ncm::InstallTaskBase *task) : result(ResultSuccess()), event(os::EventClearMode_ManualClear, true), thread_info(), task(task) { /* ... */ } + AsyncPrepareSdCardUpdateImpl(ncm::InstallTaskBase *task) : m_result(ResultSuccess()), m_event(os::EventClearMode_ManualClear, true), m_thread_info(), m_task(task) { /* ... */ } virtual ~AsyncPrepareSdCardUpdateImpl(); - os::SystemEvent &GetEvent() { return this->event; } + os::SystemEvent &GetEvent() { return m_event; } virtual Result GetErrorContext(sf::Out out) override { *out = ErrorContextHolder::GetErrorContextImpl(); @@ -113,7 +113,7 @@ namespace ams::mitm::sysupdater { Result Execute(); virtual void CancelImpl() override; - virtual Result GetImpl() override { return this->result; } + virtual Result GetImpl() override { return m_result; } }; } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp index 5d2ff57af..18ae3bd89 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.cpp @@ -211,16 +211,16 @@ namespace ams::mitm::sysupdater { } bool PathView::HasPrefix(util::string_view prefix) const { - return this->path.compare(0, prefix.length(), prefix) == 0; + return m_path.compare(0, prefix.length(), prefix) == 0; } bool PathView::HasSuffix(util::string_view suffix) const { - return this->path.compare(this->path.length() - suffix.length(), suffix.length(), suffix) == 0; + return m_path.compare(m_path.length() - suffix.length(), suffix.length(), suffix) == 0; } util::string_view PathView::GetFileName() const { - auto pos = this->path.find_last_of("/"); - return pos != util::string_view::npos ? this->path.substr(pos + 1) : this->path; + auto pos = m_path.find_last_of("/"); + return pos != util::string_view::npos ? m_path.substr(pos + 1) : m_path; } Result MountSdCardContentMeta(const char *mount_name, const char *path) { diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.hpp index 6858aaa81..b645201ee 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_fs_utils.hpp @@ -20,9 +20,9 @@ namespace ams::mitm::sysupdater { class PathView { private: - util::string_view path; + util::string_view m_path; public: - PathView(util::string_view p) : path(p) { /* ...*/ } + PathView(util::string_view p) : m_path(p) { /* ...*/ } bool HasPrefix(util::string_view prefix) const; bool HasSuffix(util::string_view suffix) const; util::string_view GetFileName() const; diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp index 8a89c5c76..df02be9bf 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp @@ -420,18 +420,18 @@ namespace ams::mitm::sysupdater { Result SystemUpdateService::RequestPrepareUpdate(sf::OutCopyHandle out_event_handle, sf::Out> out_async) { /* Ensure the update is setup but not prepared. */ - R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup()); - R_UNLESS(!this->requested_update, ns::ResultPrepareCardUpdateAlreadyRequested()); + R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup()); + R_UNLESS(!m_requested_update, ns::ResultPrepareCardUpdateAlreadyRequested()); /* Create the async result. */ - auto async_result = sf::CreateSharedObjectEmplaced(std::addressof(*this->update_task)); + auto async_result = sf::CreateSharedObjectEmplaced(std::addressof(*m_update_task)); R_UNLESS(async_result != nullptr, ns::ResultOutOfMaxRunningTask()); /* Run the task. */ R_TRY(async_result.GetImpl().Run()); /* We prepared the task! */ - this->requested_update = true; + m_requested_update = true; out_event_handle.SetValue(async_result.GetImpl().GetEvent().GetReadableHandle(), false); *out_async = std::move(async_result); @@ -440,38 +440,38 @@ namespace ams::mitm::sysupdater { Result SystemUpdateService::GetPrepareUpdateProgress(sf::Out out) { /* Ensure the update is setup. */ - R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup()); + R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup()); /* Get the progress. */ - auto install_progress = this->update_task->GetProgress(); + auto install_progress = m_update_task->GetProgress(); out.SetValue({ .current_size = install_progress.installed_size, .total_size = install_progress.total_size }); return ResultSuccess(); } Result SystemUpdateService::HasPreparedUpdate(sf::Out out) { /* Ensure the update is setup. */ - R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup()); + R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup()); - out.SetValue(this->update_task->GetProgress().state == ncm::InstallProgressState::Downloaded); + out.SetValue(m_update_task->GetProgress().state == ncm::InstallProgressState::Downloaded); return ResultSuccess(); } Result SystemUpdateService::ApplyPreparedUpdate() { /* Ensure the update is setup. */ - R_UNLESS(this->setup_update, ns::ResultCardUpdateNotSetup()); + R_UNLESS(m_setup_update, ns::ResultCardUpdateNotSetup()); /* Ensure the update is prepared. */ - R_UNLESS(this->update_task->GetProgress().state == ncm::InstallProgressState::Downloaded, ns::ResultCardUpdateNotPrepared()); + R_UNLESS(m_update_task->GetProgress().state == ncm::InstallProgressState::Downloaded, ns::ResultCardUpdateNotPrepared()); /* Apply the task. */ - R_TRY(this->apply_manager.ApplyPackageTask(std::addressof(*this->update_task))); + R_TRY(m_apply_manager.ApplyPackageTask(std::addressof(*m_update_task))); return ResultSuccess(); } Result SystemUpdateService::SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { /* Ensure we don't already have an update set up. */ - R_UNLESS(!this->setup_update, ns::ResultCardUpdateAlreadySetup()); + R_UNLESS(!m_setup_update, ns::ResultCardUpdateAlreadySetup()); /* Destroy any existing update tasks. */ nim::SystemUpdateTaskId id; @@ -484,21 +484,21 @@ namespace ams::mitm::sysupdater { R_TRY(InitializeUpdateTask(std::move(transfer_memory), transfer_memory_size, path, exfat, firmware_variation_id)); /* The update is now set up. */ - this->setup_update = true; + m_setup_update = true; return ResultSuccess(); } Result SystemUpdateService::InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id) { /* Map the transfer memory. */ const size_t tmem_buffer_size = static_cast(transfer_memory_size); - this->update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged()); + m_update_transfer_memory.emplace(tmem_buffer_size, transfer_memory.GetOsHandle(), transfer_memory.IsManaged()); transfer_memory.Detach(); void *tmem_buffer; - R_TRY(this->update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None)); + R_TRY(m_update_transfer_memory->Map(std::addressof(tmem_buffer), os::MemoryPermission_None)); auto tmem_guard = SCOPE_GUARD { - this->update_transfer_memory->Unmap(); - this->update_transfer_memory = util::nullopt; + m_update_transfer_memory->Unmap(); + m_update_transfer_memory = util::nullopt; }; /* Adjust the package root. */ @@ -510,8 +510,8 @@ namespace ams::mitm::sysupdater { const char *context_path = "@Sdcard:/atmosphere/update/cup.ctx"; /* Create and initialize the update task. */ - this->update_task.emplace(); - R_TRY(this->update_task->Initialize(package_root.str, context_path, tmem_buffer, tmem_buffer_size, exfat, firmware_variation_id)); + m_update_task.emplace(); + R_TRY(m_update_task->Initialize(package_root.str, context_path, tmem_buffer, tmem_buffer_size, exfat, firmware_variation_id)); /* We successfully setup the update. */ tmem_guard.Cancel(); diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp index 7952b4e61..7901bbebb 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.hpp @@ -56,13 +56,13 @@ namespace ams::mitm::sysupdater { class SystemUpdateService { private: - SystemUpdateApplyManager apply_manager; - util::optional update_task; - util::optional update_transfer_memory; - bool setup_update; - bool requested_update; + SystemUpdateApplyManager m_apply_manager; + util::optional m_update_task; + util::optional m_update_transfer_memory; + bool m_setup_update; + bool m_requested_update; public: - constexpr SystemUpdateService() : apply_manager(), update_task(), update_transfer_memory(), setup_update(false), requested_update(false) { /* ... */ } + constexpr SystemUpdateService() : m_apply_manager(), m_update_task(), m_update_transfer_memory(), m_setup_update(false), m_requested_update(false) { /* ... */ } private: Result SetupUpdateImpl(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); Result InitializeUpdateTask(sf::NativeHandle &&transfer_memory, u64 transfer_memory_size, const ncm::Path &path, bool exfat, ncm::FirmwareVariationId firmware_variation_id); diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.cpp index e3270f41a..1add28bd8 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.cpp @@ -19,18 +19,18 @@ namespace ams::mitm::sysupdater { Result ThreadAllocator::Allocate(ThreadInfo *out) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - for (int i = 0; i < this->thread_count; ++i) { + for (int i = 0; i < m_thread_count; ++i) { const u64 mask = (static_cast(1) << i); - if ((this->bitmap & mask) == 0) { + if ((m_bitmap & mask) == 0) { *out = { - .thread = this->thread_list + i, - .priority = this->thread_priority, - .stack = this->stack_heap + (this->stack_size * i), - .stack_size = this->stack_size, + .thread = m_thread_list + i, + .priority = m_thread_priority, + .stack = m_stack_heap + (m_stack_size * i), + .stack_size = m_stack_size, }; - this->bitmap |= mask; + m_bitmap |= mask; return ResultSuccess(); } } @@ -39,12 +39,12 @@ namespace ams::mitm::sysupdater { } void ThreadAllocator::Free(const ThreadInfo &info) { - std::scoped_lock lk(this->mutex); + std::scoped_lock lk(m_mutex); - for (int i = 0; i < this->thread_count; ++i) { - if (info.thread == std::addressof(this->thread_list[i])) { + for (int i = 0; i < m_thread_count; ++i) { + if (info.thread == std::addressof(m_thread_list[i])) { const u64 mask = (static_cast(1) << i); - this->bitmap &= ~mask; + m_bitmap &= ~mask; return; } } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.hpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.hpp index 6d792426c..2dce16be3 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.hpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_thread_allocator.hpp @@ -28,20 +28,20 @@ namespace ams::mitm::sysupdater { /* NOTE: Nintendo uses a util::BitArray, but this seems excessive. */ class ThreadAllocator { private: - os::ThreadType *thread_list; - const int thread_priority; - const int thread_count; - u8 *stack_heap; - const size_t stack_heap_size; - const size_t stack_size; - u64 bitmap; - os::SdkMutex mutex; + os::ThreadType *m_thread_list; + const int m_thread_priority; + const int m_thread_count; + u8 *m_stack_heap; + const size_t m_stack_heap_size; + const size_t m_stack_size; + u64 m_bitmap; + os::SdkMutex m_mutex; public: constexpr ThreadAllocator(os::ThreadType *thread_list, int count, int priority, u8 *stack_heap, size_t stack_heap_size, size_t stack_size) - : thread_list(thread_list), thread_priority(priority), thread_count(count), stack_heap(stack_heap), stack_heap_size(stack_heap_size), stack_size(stack_size), bitmap() + : m_thread_list(thread_list), m_thread_priority(priority), m_thread_count(count), m_stack_heap(stack_heap), m_stack_heap_size(stack_heap_size), m_stack_size(stack_size), m_bitmap() { AMS_ASSERT(count <= static_cast(stack_heap_size / stack_size)); - AMS_ASSERT(count <= static_cast(BITSIZEOF(this->bitmap))); + AMS_ASSERT(count <= static_cast(BITSIZEOF(m_bitmap))); } Result Allocate(ThreadInfo *out); diff --git a/stratosphere/boot/source/boot_battery_driver.hpp b/stratosphere/boot/source/boot_battery_driver.hpp index 171f28c94..59664cc5b 100644 --- a/stratosphere/boot/source/boot_battery_driver.hpp +++ b/stratosphere/boot/source/boot_battery_driver.hpp @@ -20,54 +20,54 @@ namespace ams::boot { class BatteryDriver { private: - powctl::Session battery_session; + powctl::Session m_battery_session; public: - BatteryDriver() : battery_session() { - R_ABORT_UNLESS(powctl::OpenSession(std::addressof(this->battery_session), powctl::DeviceCode_Max17050, ddsf::AccessMode_ReadWrite)); + BatteryDriver() : m_battery_session() { + R_ABORT_UNLESS(powctl::OpenSession(std::addressof(m_battery_session), powctl::DeviceCode_Max17050, ddsf::AccessMode_ReadWrite)); } ~BatteryDriver() { - powctl::CloseSession(this->battery_session); + powctl::CloseSession(m_battery_session); } public: Result IsBatteryRemoved(bool *out) { bool present; - R_TRY(powctl::IsBatteryPresent(std::addressof(present), this->battery_session)); + R_TRY(powctl::IsBatteryPresent(std::addressof(present), m_battery_session)); *out = !present; return ResultSuccess(); } Result GetSocRep(float *out) { - return powctl::GetBatterySocRep(out, this->battery_session); + return powctl::GetBatterySocRep(out, m_battery_session); } Result GetAverageVCell(int *out) { - return powctl::GetBatteryAverageVCell(out, this->battery_session); + return powctl::GetBatteryAverageVCell(out, m_battery_session); } Result GetOpenCircuitVoltage(int *out) { - return powctl::GetBatteryOpenCircuitVoltage(out, this->battery_session); + return powctl::GetBatteryOpenCircuitVoltage(out, m_battery_session); } Result GetAverageCurrent(int *out) { - return powctl::GetBatteryAverageCurrent(out, this->battery_session); + return powctl::GetBatteryAverageCurrent(out, m_battery_session); } Result GetCurrent(int *out) { - return powctl::GetBatteryCurrent(out, this->battery_session); + return powctl::GetBatteryCurrent(out, m_battery_session); } Result GetTemperature(float *out) { - return powctl::GetBatteryTemperature(out, this->battery_session); + return powctl::GetBatteryTemperature(out, m_battery_session); } Result IsI2cShutdownEnabled(bool *out) { - return powctl::IsBatteryI2cShutdownEnabled(out, this->battery_session); + return powctl::IsBatteryI2cShutdownEnabled(out, m_battery_session); } Result SetI2cShutdownEnabled(bool en) { - return powctl::SetBatteryI2cShutdownEnabled(this->battery_session, en); + return powctl::SetBatteryI2cShutdownEnabled(m_battery_session, en); } }; diff --git a/stratosphere/boot/source/boot_charger_driver.hpp b/stratosphere/boot/source/boot_charger_driver.hpp index 6e71e3cf0..5d9da2feb 100644 --- a/stratosphere/boot/source/boot_charger_driver.hpp +++ b/stratosphere/boot/source/boot_charger_driver.hpp @@ -27,14 +27,14 @@ namespace ams::boot { class ChargerDriver { private: - powctl::Session charger_session; + powctl::Session m_charger_session; public: - ChargerDriver() : charger_session() { - R_ABORT_UNLESS(powctl::OpenSession(std::addressof(this->charger_session), powctl::DeviceCode_Bq24193, ddsf::AccessMode_ReadWrite)); + ChargerDriver() : m_charger_session() { + R_ABORT_UNLESS(powctl::OpenSession(std::addressof(m_charger_session), powctl::DeviceCode_Bq24193, ddsf::AccessMode_ReadWrite)); } ~ChargerDriver() { - powctl::CloseSession(this->charger_session); + powctl::CloseSession(m_charger_session); } Result Initialize(bool set_input_current_limit) { @@ -46,51 +46,51 @@ namespace ams::boot { /* Set input current limit to 500 ma. */ if (set_input_current_limit) { - R_TRY(powctl::SetChargerInputCurrentLimit(this->charger_session, 500)); + R_TRY(powctl::SetChargerInputCurrentLimit(m_charger_session, 500)); } /* Set input voltage limit to 500 mv. */ - R_TRY(powctl::SetChargerInputVoltageLimit(this->charger_session, 500)); + R_TRY(powctl::SetChargerInputVoltageLimit(m_charger_session, 500)); /* Disable hi-z mode. */ - R_TRY(powctl::SetChargerHiZEnabled(this->charger_session, false)); + R_TRY(powctl::SetChargerHiZEnabled(m_charger_session, false)); /* Set configuration to charge battery. */ - R_TRY(powctl::SetChargerChargerConfiguration(this->charger_session, powctl::ChargerConfiguration_ChargeBattery)); + R_TRY(powctl::SetChargerChargerConfiguration(m_charger_session, powctl::ChargerConfiguration_ChargeBattery)); return ResultSuccess(); } Result GetChargeCurrentState(powctl::ChargeCurrentState *out) { - return powctl::GetChargerChargeCurrentState(out, this->charger_session); + return powctl::GetChargerChargeCurrentState(out, m_charger_session); } Result SetChargeCurrentState(powctl::ChargeCurrentState state) { - return powctl::SetChargerChargeCurrentState(this->charger_session, state); + return powctl::SetChargerChargeCurrentState(m_charger_session, state); } Result GetInputCurrentLimit(int *out) { - return powctl::GetChargerInputCurrentLimit(out, this->charger_session); + return powctl::GetChargerInputCurrentLimit(out, m_charger_session); } Result SetChargerConfiguration(powctl::ChargerConfiguration cfg) { - return powctl::SetChargerChargerConfiguration(this->charger_session, cfg); + return powctl::SetChargerChargerConfiguration(m_charger_session, cfg); } Result GetFastChargeCurrentLimit(int *out) { - return powctl::GetChargerFastChargeCurrentLimit(out, this->charger_session); + return powctl::GetChargerFastChargeCurrentLimit(out, m_charger_session); } Result SetFastChargeCurrentLimit(int limit) { - return powctl::SetChargerFastChargeCurrentLimit(this->charger_session, limit); + return powctl::SetChargerFastChargeCurrentLimit(m_charger_session, limit); } Result GetChargeVoltageLimit(int *out) { - return powctl::GetChargerChargeVoltageLimit(out, this->charger_session); + return powctl::GetChargerChargeVoltageLimit(out, m_charger_session); } Result SetChargeVoltageLimit(int limit) { - return powctl::SetChargerChargeVoltageLimit(this->charger_session, limit); + return powctl::SetChargerChargeVoltageLimit(m_charger_session, limit); } Result GetChargerStatus(boot::ChargerStatus *out) { @@ -99,7 +99,7 @@ namespace ams::boot { /* Get the powctl status. */ powctl::ChargerStatus powctl_status; - R_TRY(powctl::GetChargerChargerStatus(std::addressof(powctl_status), this->charger_session)); + R_TRY(powctl::GetChargerChargerStatus(std::addressof(powctl_status), m_charger_session)); switch (powctl_status) { case powctl::ChargerStatus_Charging: *out = boot::ChargerStatus_Charging; break; @@ -111,19 +111,19 @@ namespace ams::boot { } Result GetBatteryCompensation(int *out) { - return powctl::GetChargerBatteryCompensation(out, this->charger_session); + return powctl::GetChargerBatteryCompensation(out, m_charger_session); } Result SetBatteryCompensation(int v) { - return powctl::SetChargerBatteryCompensation(this->charger_session, v); + return powctl::SetChargerBatteryCompensation(m_charger_session, v); } Result GetVoltageClamp(int *out) { - return powctl::GetChargerVoltageClamp(out, this->charger_session); + return powctl::GetChargerVoltageClamp(out, m_charger_session); } Result SetVoltageClamp(int v) { - return powctl::SetChargerVoltageClamp(this->charger_session, v); + return powctl::SetChargerVoltageClamp(m_charger_session, v); } }; diff --git a/stratosphere/boot/source/boot_check_battery.cpp b/stratosphere/boot/source/boot_check_battery.cpp index 59a600f90..e8bdd981c 100644 --- a/stratosphere/boot/source/boot_check_battery.cpp +++ b/stratosphere/boot/source/boot_check_battery.cpp @@ -42,18 +42,18 @@ namespace ams::boot { class BatteryChecker { private: - boot::ChargerDriver &charger_driver; - boot::BatteryDriver &battery_driver; - const powctl::driver::impl::ChargeParameters &charge_parameters; - powctl::driver::impl::ChargeArbiter charge_arbiter; - powctl::ChargeCurrentState charge_current_state; - int fast_charge_current_limit; - int charge_voltage_limit; - int battery_compensation; - int voltage_clamp; - TimeSpan charging_done_interval; - bool has_start_time; - TimeSpan start_time; + boot::ChargerDriver &m_charger_driver; + boot::BatteryDriver &m_battery_driver; + const powctl::driver::impl::ChargeParameters &m_charge_parameters; + powctl::driver::impl::ChargeArbiter m_charge_arbiter; + powctl::ChargeCurrentState m_charge_current_state; + int m_fast_charge_current_limit; + int m_charge_voltage_limit; + int m_battery_compensation; + int m_voltage_clamp; + TimeSpan m_charging_done_interval; + bool m_has_start_time; + TimeSpan m_start_time; private: bool IsChargeDone(); void UpdateChargeDoneCurrent(); @@ -63,25 +63,25 @@ namespace ams::boot { void UpdateStartTime() { /* Update start time. */ - this->start_time = os::ConvertToTimeSpan(os::GetSystemTick()); - this->has_start_time = true; + m_start_time = os::ConvertToTimeSpan(os::GetSystemTick()); + m_has_start_time = true; } public: - BatteryChecker(boot::ChargerDriver &cd, boot::BatteryDriver &bd, const powctl::driver::impl::ChargeParameters &cp, int cvl) : charger_driver(cd), battery_driver(bd), charge_parameters(cp), charge_arbiter(cp.rules, cp.num_rules, cvl), charging_done_interval(TimeSpan::FromSeconds(2)), has_start_time(false) { + BatteryChecker(boot::ChargerDriver &cd, boot::BatteryDriver &bd, const powctl::driver::impl::ChargeParameters &cp, int cvl) : m_charger_driver(cd), m_battery_driver(bd), m_charge_parameters(cp), m_charge_arbiter(cp.rules, cp.num_rules, cvl), m_charging_done_interval(TimeSpan::FromSeconds(2)), m_has_start_time(false) { /* Get parameters from charger. */ - if (R_FAILED(this->charger_driver.GetChargeCurrentState(std::addressof(this->charge_current_state)))) { + if (R_FAILED(m_charger_driver.GetChargeCurrentState(std::addressof(m_charge_current_state)))) { boot::ShutdownSystem(); } - if (R_FAILED(this->charger_driver.GetFastChargeCurrentLimit(std::addressof(this->fast_charge_current_limit)))) { + if (R_FAILED(m_charger_driver.GetFastChargeCurrentLimit(std::addressof(m_fast_charge_current_limit)))) { boot::ShutdownSystem(); } - if (R_FAILED(this->charger_driver.GetChargeVoltageLimit(std::addressof(this->charge_voltage_limit)))) { + if (R_FAILED(m_charger_driver.GetChargeVoltageLimit(std::addressof(m_charge_voltage_limit)))) { boot::ShutdownSystem(); } - if (R_FAILED(this->charger_driver.GetBatteryCompensation(std::addressof(this->battery_compensation)))) { + if (R_FAILED(m_charger_driver.GetBatteryCompensation(std::addressof(m_battery_compensation)))) { boot::ShutdownSystem(); } - if (R_FAILED(this->charger_driver.GetVoltageClamp(std::addressof(this->voltage_clamp)))) { + if (R_FAILED(m_charger_driver.GetVoltageClamp(std::addressof(m_voltage_clamp)))) { boot::ShutdownSystem(); } @@ -112,16 +112,16 @@ namespace ams::boot { /* Get various battery metrics. */ int avg_current, current, open_circuit_voltage; float temp; - if (R_FAILED(this->battery_driver.GetAverageCurrent(std::addressof(avg_current)))) { + if (R_FAILED(m_battery_driver.GetAverageCurrent(std::addressof(avg_current)))) { return; } - if (R_FAILED(this->battery_driver.GetCurrent(std::addressof(current)))) { + if (R_FAILED(m_battery_driver.GetCurrent(std::addressof(current)))) { return; } - if (R_FAILED(this->battery_driver.GetTemperature(std::addressof(temp)))) { + if (R_FAILED(m_battery_driver.GetTemperature(std::addressof(temp)))) { return; } - if (R_FAILED(this->battery_driver.GetOpenCircuitVoltage(std::addressof(open_circuit_voltage)))) { + if (R_FAILED(m_battery_driver.GetOpenCircuitVoltage(std::addressof(open_circuit_voltage)))) { return; } @@ -132,7 +132,7 @@ namespace ams::boot { bool BatteryChecker::IsChargeDone() { /* Get the charger status. */ boot::ChargerStatus charger_status; - if (R_FAILED(this->charger_driver.GetChargerStatus(std::addressof(charger_status)))) { + if (R_FAILED(m_charger_driver.GetChargerStatus(std::addressof(charger_status)))) { boot::ShutdownSystem(); } @@ -142,20 +142,20 @@ namespace ams::boot { } /* Return whether a done current of zero is acceptable. */ - return this->charge_arbiter.IsBatteryDoneCurrentAcceptable(0); + return m_charge_arbiter.IsBatteryDoneCurrentAcceptable(0); } void BatteryChecker::UpdateChargeDoneCurrent() { int done_current = 0; - if (this->has_start_time && (os::ConvertToTimeSpan(os::GetSystemTick()) - this->start_time) >= this->charging_done_interval) { + if (m_has_start_time && (os::ConvertToTimeSpan(os::GetSystemTick()) - m_start_time) >= m_charging_done_interval) { /* Get the current. */ - if (R_FAILED(this->battery_driver.GetCurrent(std::addressof(done_current)))) { + if (R_FAILED(m_battery_driver.GetCurrent(std::addressof(done_current)))) { boot::ShutdownSystem(); } } else { /* Get the charger status. */ boot::ChargerStatus charger_status; - if (R_FAILED(this->charger_driver.GetChargerStatus(std::addressof(charger_status)))) { + if (R_FAILED(m_charger_driver.GetChargerStatus(std::addressof(charger_status)))) { boot::ShutdownSystem(); } @@ -166,50 +166,50 @@ namespace ams::boot { } /* Update done current. */ - this->charge_arbiter.SetBatteryDoneCurrent(done_current); + m_charge_arbiter.SetBatteryDoneCurrent(done_current); } void BatteryChecker::UpdateCharger() { /* Get the battery temperature. */ float temp; - if (R_FAILED(this->battery_driver.GetTemperature(std::addressof(temp)))) { + if (R_FAILED(m_battery_driver.GetTemperature(std::addressof(temp)))) { boot::ShutdownSystem(); } /* Update the temperature level. */ powctl::BatteryTemperatureLevel temp_level; - if (temp < static_cast(this->charge_parameters.temp_min)) { + if (temp < static_cast(m_charge_parameters.temp_min)) { temp_level = powctl::BatteryTemperatureLevel::TooLow; - } else if (temp < static_cast(this->charge_parameters.temp_low)) { + } else if (temp < static_cast(m_charge_parameters.temp_low)) { temp_level = powctl::BatteryTemperatureLevel::Low; - } else if (temp < static_cast(this->charge_parameters.temp_high)) { + } else if (temp < static_cast(m_charge_parameters.temp_high)) { temp_level = powctl::BatteryTemperatureLevel::Medium; - } else if (temp < static_cast(this->charge_parameters.temp_max)) { + } else if (temp < static_cast(m_charge_parameters.temp_max)) { temp_level = powctl::BatteryTemperatureLevel::High; } else { temp_level = powctl::BatteryTemperatureLevel::TooHigh; } - this->charge_arbiter.SetBatteryTemperatureLevel(temp_level); + m_charge_arbiter.SetBatteryTemperatureLevel(temp_level); /* Update average voltage. */ int avg_v_cell; - if (R_FAILED(this->battery_driver.GetAverageVCell(std::addressof(avg_v_cell)))) { + if (R_FAILED(m_battery_driver.GetAverageVCell(std::addressof(avg_v_cell)))) { boot::ShutdownSystem(); } - this->charge_arbiter.SetBatteryAverageVCell(avg_v_cell); + m_charge_arbiter.SetBatteryAverageVCell(avg_v_cell); /* Update open circuit voltage. */ int ocv; - if (R_FAILED(this->battery_driver.GetOpenCircuitVoltage(std::addressof(ocv)))) { + if (R_FAILED(m_battery_driver.GetOpenCircuitVoltage(std::addressof(ocv)))) { boot::ShutdownSystem(); } - this->charge_arbiter.SetBatteryOpenCircuitVoltage(ocv); + m_charge_arbiter.SetBatteryOpenCircuitVoltage(ocv); /* Update charge done current. */ this->UpdateChargeDoneCurrent(); /* Update arbiter power state. */ - this->charge_arbiter.SetPowerState(powctl::PowerState::ShutdownChargeMain); + m_charge_arbiter.SetPowerState(powctl::PowerState::ShutdownChargeMain); /* Apply the newly selected rule. */ this->ApplyArbiterRule(); @@ -217,19 +217,19 @@ namespace ams::boot { void BatteryChecker::ApplyArbiterRule() { /* Get the selected rule. */ - const auto *rule = this->charge_arbiter.GetSelectedRule(); + const auto *rule = m_charge_arbiter.GetSelectedRule(); AMS_ASSERT(rule != nullptr); /* Check if we need to perform charger initialization. */ const bool reinit_charger = rule->reinitialize_charger; - const auto cur_charge_current_state = this->charge_current_state; + const auto cur_charge_current_state = m_charge_current_state; /* Set the charger to not charging while we make changes. */ if (!reinit_charger || cur_charge_current_state != powctl::ChargeCurrentState_NotCharging) { - if (R_FAILED(this->charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_NotCharging))) { + if (R_FAILED(m_charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_NotCharging))) { boot::ShutdownSystem(); } - this->charge_current_state = powctl::ChargeCurrentState_NotCharging; + m_charge_current_state = powctl::ChargeCurrentState_NotCharging; /* Update start time. */ this->UpdateStartTime(); @@ -237,25 +237,25 @@ namespace ams::boot { /* Process fast charge current limit when rule is smaller. */ const auto rule_fast_charge_current_limit = rule->fast_charge_current_limit; - const auto cur_fast_charge_current_limit = this->fast_charge_current_limit; + const auto cur_fast_charge_current_limit = m_fast_charge_current_limit; if (rule_fast_charge_current_limit < cur_fast_charge_current_limit) { - if (R_FAILED(this->charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) { + if (R_FAILED(m_charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) { boot::ShutdownSystem(); } - this->fast_charge_current_limit = rule_fast_charge_current_limit; + m_fast_charge_current_limit = rule_fast_charge_current_limit; /* Update start time. */ this->UpdateStartTime(); } /* Process charge voltage limit when rule is smaller. */ - const auto rule_charge_voltage_limit = std::min(rule->charge_voltage_limit, this->charge_arbiter.GetChargeVoltageLimit()); - const auto cur_charge_voltage_limit = this->charge_voltage_limit; + const auto rule_charge_voltage_limit = std::min(rule->charge_voltage_limit, m_charge_arbiter.GetChargeVoltageLimit()); + const auto cur_charge_voltage_limit = m_charge_voltage_limit; if (rule_charge_voltage_limit < cur_charge_voltage_limit) { - if (R_FAILED(this->charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) { + if (R_FAILED(m_charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) { boot::ShutdownSystem(); } - this->charge_voltage_limit = rule_charge_voltage_limit; + m_charge_voltage_limit = rule_charge_voltage_limit; /* Update start time. */ this->UpdateStartTime(); @@ -263,12 +263,12 @@ namespace ams::boot { /* Process battery compensation when rule is smaller. */ const auto rule_battery_compensation = rule->battery_compensation; - const auto cur_battery_compensation = this->battery_compensation; + const auto cur_battery_compensation = m_battery_compensation; if (rule_battery_compensation < cur_battery_compensation) { - if (R_FAILED(this->charger_driver.SetBatteryCompensation(rule_battery_compensation))) { + if (R_FAILED(m_charger_driver.SetBatteryCompensation(rule_battery_compensation))) { boot::ShutdownSystem(); } - this->battery_compensation = rule_battery_compensation; + m_battery_compensation = rule_battery_compensation; /* Update start time. */ this->UpdateStartTime(); @@ -276,12 +276,12 @@ namespace ams::boot { /* Process voltage clamp when rule is smaller. */ const auto rule_voltage_clamp = rule->voltage_clamp; - const auto cur_voltage_clamp = this->voltage_clamp; + const auto cur_voltage_clamp = m_voltage_clamp; if (rule_voltage_clamp < cur_voltage_clamp) { - if (R_FAILED(this->charger_driver.SetVoltageClamp(rule_voltage_clamp))) { + if (R_FAILED(m_charger_driver.SetVoltageClamp(rule_voltage_clamp))) { boot::ShutdownSystem(); } - this->voltage_clamp = rule_voltage_clamp; + m_voltage_clamp = rule_voltage_clamp; /* Update start time. */ this->UpdateStartTime(); @@ -289,10 +289,10 @@ namespace ams::boot { /* Process voltage clamp when rule is larger. */ if (rule_voltage_clamp > cur_voltage_clamp) { - if (R_FAILED(this->charger_driver.SetVoltageClamp(rule_voltage_clamp))) { + if (R_FAILED(m_charger_driver.SetVoltageClamp(rule_voltage_clamp))) { boot::ShutdownSystem(); } - this->voltage_clamp = rule_voltage_clamp; + m_voltage_clamp = rule_voltage_clamp; /* Update start time. */ this->UpdateStartTime(); @@ -300,10 +300,10 @@ namespace ams::boot { /* Process battery compensation when rule is larger. */ if (rule_battery_compensation > cur_battery_compensation) { - if (R_FAILED(this->charger_driver.SetBatteryCompensation(rule_battery_compensation))) { + if (R_FAILED(m_charger_driver.SetBatteryCompensation(rule_battery_compensation))) { boot::ShutdownSystem(); } - this->battery_compensation = rule_battery_compensation; + m_battery_compensation = rule_battery_compensation; /* Update start time. */ this->UpdateStartTime(); @@ -311,10 +311,10 @@ namespace ams::boot { /* Process fast charge current limit when rule is larger. */ if (rule_fast_charge_current_limit > cur_fast_charge_current_limit) { - if (R_FAILED(this->charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) { + if (R_FAILED(m_charger_driver.SetFastChargeCurrentLimit(rule_fast_charge_current_limit))) { boot::ShutdownSystem(); } - this->fast_charge_current_limit = rule_fast_charge_current_limit; + m_fast_charge_current_limit = rule_fast_charge_current_limit; /* Update start time. */ this->UpdateStartTime(); @@ -322,10 +322,10 @@ namespace ams::boot { /* Process charge voltage limit when rule is larger. */ if (rule_charge_voltage_limit > cur_charge_voltage_limit) { - if (R_FAILED(this->charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) { + if (R_FAILED(m_charger_driver.SetChargeVoltageLimit(rule_charge_voltage_limit))) { boot::ShutdownSystem(); } - this->charge_voltage_limit = rule_charge_voltage_limit; + m_charge_voltage_limit = rule_charge_voltage_limit; /* Update start time. */ this->UpdateStartTime(); @@ -333,10 +333,10 @@ namespace ams::boot { /* If we're not charging and we expect to reinitialize the charger, do so. */ if (cur_charge_current_state != powctl::ChargeCurrentState_Charging && reinit_charger) { - if (R_FAILED(this->charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_Charging))) { + if (R_FAILED(m_charger_driver.SetChargeCurrentState(powctl::ChargeCurrentState_Charging))) { boot::ShutdownSystem(); } - this->charge_current_state = powctl::ChargeCurrentState_Charging; + m_charge_current_state = powctl::ChargeCurrentState_Charging; /* Update start time. */ this->UpdateStartTime(); @@ -357,7 +357,7 @@ namespace ams::boot { if (show_charging_display) { /* Get the raw battery charge. */ float raw_battery_charge; - if (R_FAILED(this->battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) { + if (R_FAILED(m_battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) { return CheckBatteryResult::Shutdown; } @@ -372,13 +372,13 @@ namespace ams::boot { while (true) { /* Get the raw battery charge. */ float raw_battery_charge; - if (R_FAILED(this->battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) { + if (R_FAILED(m_battery_driver.GetSocRep(std::addressof(raw_battery_charge)))) { return CheckBatteryResult::Shutdown; } /* Get the average vcell. */ int battery_voltage; - if (R_FAILED(this->battery_driver.GetAverageVCell(std::addressof(battery_voltage)))) { + if (R_FAILED(m_battery_driver.GetAverageVCell(std::addressof(battery_voltage)))) { return CheckBatteryResult::Shutdown; } diff --git a/stratosphere/boot/source/boot_pmic_driver.cpp b/stratosphere/boot/source/boot_pmic_driver.cpp index 322ca6291..0303a0d12 100644 --- a/stratosphere/boot/source/boot_pmic_driver.cpp +++ b/stratosphere/boot/source/boot_pmic_driver.cpp @@ -36,17 +36,17 @@ namespace ams::boot { Result PmicDriver::GetOnOffIrq(u8 *out) { const u8 addr = 0x0B; - return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); } Result PmicDriver::GetPowerStatus(u8 *out) { const u8 addr = 0x15; - return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); } Result PmicDriver::GetNvErc(u8 *out) { const u8 addr = 0x0C; - return ReadI2cRegister(this->i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); + return ReadI2cRegister(m_i2c_session, out, sizeof(*out), std::addressof(addr), sizeof(addr)); } Result PmicDriver::GetPowerButtonPressed(bool *out) { @@ -62,17 +62,17 @@ namespace ams::boot { /* Get value, set or clear software reset mask. */ u8 on_off_2_val = 0; - R_ABORT_UNLESS(ReadI2cRegister(this->i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr))); + R_ABORT_UNLESS(ReadI2cRegister(m_i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr))); if (reboot) { on_off_2_val |= 0x80; } else { on_off_2_val &= ~0x80; } - R_ABORT_UNLESS(WriteI2cRegister(this->i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr))); + R_ABORT_UNLESS(WriteI2cRegister(m_i2c_session, std::addressof(on_off_2_val), sizeof(on_off_2_val), std::addressof(on_off_2_addr), sizeof(on_off_2_addr))); /* Get value, set software reset mask. */ u8 on_off_1_val = 0; - R_ABORT_UNLESS(ReadI2cRegister(this->i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr))); + R_ABORT_UNLESS(ReadI2cRegister(m_i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr))); on_off_1_val |= 0x80; /* Finalize the battery on non-Calcio. */ @@ -82,7 +82,7 @@ namespace ams::boot { } /* Actually write the value to trigger shutdown/reset. */ - R_ABORT_UNLESS(WriteI2cRegister(this->i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr))); + R_ABORT_UNLESS(WriteI2cRegister(m_i2c_session, std::addressof(on_off_1_val), sizeof(on_off_1_val), std::addressof(on_off_1_addr), sizeof(on_off_1_addr))); /* Allow up to 5 seconds for shutdown/reboot to take place. */ os::SleepThread(TimeSpan::FromSeconds(5)); diff --git a/stratosphere/boot/source/boot_pmic_driver.hpp b/stratosphere/boot/source/boot_pmic_driver.hpp index c2851e2b7..e54701abb 100644 --- a/stratosphere/boot/source/boot_pmic_driver.hpp +++ b/stratosphere/boot/source/boot_pmic_driver.hpp @@ -21,14 +21,14 @@ namespace ams::boot { /* Driver object. */ class PmicDriver { private: - i2c::driver::I2cSession i2c_session; + i2c::driver::I2cSession m_i2c_session; public: PmicDriver() { - R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Max77620Pmic)); + R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max77620Pmic)); } ~PmicDriver() { - i2c::driver::CloseSession(this->i2c_session); + i2c::driver::CloseSession(m_i2c_session); } private: Result GetPowerStatus(u8 *out); diff --git a/stratosphere/boot/source/boot_rtc_driver.cpp b/stratosphere/boot/source/boot_rtc_driver.cpp index a3dfbfb77..f3e9b9560 100644 --- a/stratosphere/boot/source/boot_rtc_driver.cpp +++ b/stratosphere/boot/source/boot_rtc_driver.cpp @@ -21,14 +21,14 @@ namespace ams::boot { Result RtcDriver::ReadRtcRegister(u8 *out, u8 address) { const u8 update_addr = 0x04; const u8 update_val = 0x10; - R_TRY(WriteI2cRegister(this->i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr))); + R_TRY(WriteI2cRegister(m_i2c_session, &update_val, sizeof(update_val), &update_addr, sizeof(update_addr))); os::SleepThread(TimeSpan::FromMilliSeconds(16)); - return ReadI2cRegister(this->i2c_session, out, sizeof(*out), &address, sizeof(address)); + return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &address, sizeof(address)); } Result RtcDriver::GetRtcIntr(u8 *out) { const u8 addr = 0x00; - return ReadI2cRegister(this->i2c_session, out, sizeof(*out), &addr, sizeof(addr)); + return ReadI2cRegister(m_i2c_session, out, sizeof(*out), &addr, sizeof(addr)); } Result RtcDriver::GetRtcIntrM(u8 *out) { diff --git a/stratosphere/boot/source/boot_rtc_driver.hpp b/stratosphere/boot/source/boot_rtc_driver.hpp index f3d9ec490..b9a08ce59 100644 --- a/stratosphere/boot/source/boot_rtc_driver.hpp +++ b/stratosphere/boot/source/boot_rtc_driver.hpp @@ -20,14 +20,14 @@ namespace ams::boot { class RtcDriver { private: - i2c::driver::I2cSession i2c_session; + i2c::driver::I2cSession m_i2c_session; public: RtcDriver() { - R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(this->i2c_session), i2c::DeviceCode_Max77620Rtc)); + R_ABORT_UNLESS(i2c::driver::OpenSession(std::addressof(m_i2c_session), i2c::DeviceCode_Max77620Rtc)); } ~RtcDriver() { - i2c::driver::CloseSession(this->i2c_session); + i2c::driver::CloseSession(m_i2c_session); } private: Result ReadRtcRegister(u8 *out, u8 address); diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index 262191377..e4d147dd8 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -86,31 +86,31 @@ namespace ams::creport { void CrashReport::Initialize() { /* Initialize the heap. */ - this->heap_handle = lmem::CreateExpHeap(this->heap_storage, sizeof(this->heap_storage), lmem::CreateOption_None); + m_heap_handle = lmem::CreateExpHeap(m_heap_storage, sizeof(m_heap_storage), lmem::CreateOption_None); /* Allocate members. */ - this->module_list = std::construct_at(static_cast(lmem::AllocateFromExpHeap(this->heap_handle, sizeof(ModuleList)))); - this->thread_list = std::construct_at(static_cast(lmem::AllocateFromExpHeap(this->heap_handle, sizeof(ThreadList)))); - this->dying_message = static_cast(lmem::AllocateFromExpHeap(this->heap_handle, DyingMessageSizeMax)); - if (this->dying_message != nullptr) { - std::memset(this->dying_message, 0, DyingMessageSizeMax); + m_module_list = std::construct_at(static_cast(lmem::AllocateFromExpHeap(m_heap_handle, sizeof(ModuleList)))); + m_thread_list = std::construct_at(static_cast(lmem::AllocateFromExpHeap(m_heap_handle, sizeof(ThreadList)))); + m_dying_message = static_cast(lmem::AllocateFromExpHeap(m_heap_handle, DyingMessageSizeMax)); + if (m_dying_message != nullptr) { + std::memset(m_dying_message, 0, DyingMessageSizeMax); } } void CrashReport::BuildReport(os::ProcessId process_id, bool has_extra_info) { - this->has_extra_info = has_extra_info; + m_has_extra_info = has_extra_info; if (this->OpenProcess(process_id)) { ON_SCOPE_EXIT { this->Close(); }; /* Parse info from the crashed process. */ this->ProcessExceptions(); - this->module_list->FindModulesFromThreadInfo(this->debug_handle, this->crashed_thread); - this->thread_list->ReadFromProcess(this->debug_handle, this->thread_tls_map, this->Is64Bit()); + m_module_list->FindModulesFromThreadInfo(m_debug_handle, m_crashed_thread); + m_thread_list->ReadFromProcess(m_debug_handle, m_thread_tls_map, this->Is64Bit()); /* Associate module list to threads. */ - this->crashed_thread.SetModuleList(this->module_list); - this->thread_list->SetModuleList(this->module_list); + m_crashed_thread.SetModuleList(m_module_list); + m_thread_list->SetModuleList(m_module_list); /* Process dying message for applications. */ if (this->IsApplication()) { @@ -119,13 +119,13 @@ namespace ams::creport { /* Nintendo's creport finds extra modules by looking at all threads if application, */ /* but there's no reason for us not to always go looking. */ - for (size_t i = 0; i < this->thread_list->GetThreadCount(); i++) { - this->module_list->FindModulesFromThreadInfo(this->debug_handle, this->thread_list->GetThreadInfo(i)); + for (size_t i = 0; i < m_thread_list->GetThreadCount(); i++) { + m_module_list->FindModulesFromThreadInfo(m_debug_handle, m_thread_list->GetThreadInfo(i)); } /* Cache the module base address to send to fatal. */ - if (this->module_list->GetModuleCount()) { - this->module_base_address = this->module_list->GetModuleStartAddress(0); + if (m_module_list->GetModuleCount()) { + m_module_base_address = m_module_list->GetModuleStartAddress(0); } /* Nintendo's creport saves the report to erpt here, but we'll save to SD card later. */ @@ -139,33 +139,33 @@ namespace ams::creport { /* TODO: Support generating 32-bit fatal contexts? */ out->architecture = fatal::CpuContext::Architecture_Aarch64; - out->type = static_cast(this->exception_info.type); + out->type = static_cast(m_exception_info.type); for (size_t i = 0; i < fatal::aarch64::RegisterName_FP; i++) { - out->aarch64_ctx.SetRegisterValue(static_cast(i), this->crashed_thread.GetGeneralPurposeRegister(i)); + out->aarch64_ctx.SetRegisterValue(static_cast(i), m_crashed_thread.GetGeneralPurposeRegister(i)); } - out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_FP, this->crashed_thread.GetFP()); - out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_LR, this->crashed_thread.GetLR()); - out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_SP, this->crashed_thread.GetSP()); - out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_PC, this->crashed_thread.GetPC()); + out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_FP, m_crashed_thread.GetFP()); + out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_LR, m_crashed_thread.GetLR()); + out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_SP, m_crashed_thread.GetSP()); + out->aarch64_ctx.SetRegisterValue(fatal::aarch64::RegisterName_PC, m_crashed_thread.GetPC()); - out->aarch64_ctx.stack_trace_size = this->crashed_thread.GetStackTraceSize(); + out->aarch64_ctx.stack_trace_size = m_crashed_thread.GetStackTraceSize(); for (size_t i = 0; i < out->aarch64_ctx.stack_trace_size; i++) { - out->aarch64_ctx.stack_trace[i] = this->crashed_thread.GetStackTrace(i); + out->aarch64_ctx.stack_trace[i] = m_crashed_thread.GetStackTrace(i); } - if (this->module_base_address != 0) { - out->aarch64_ctx.SetBaseAddress(this->module_base_address); + if (m_module_base_address != 0) { + out->aarch64_ctx.SetBaseAddress(m_module_base_address); } /* For ams fatal, which doesn't use afsr0, pass program_id instead. */ - out->aarch64_ctx.SetProgramIdForAtmosphere(ncm::ProgramId{this->process_info.program_id}); + out->aarch64_ctx.SetProgramIdForAtmosphere(ncm::ProgramId{m_process_info.program_id}); } void CrashReport::ProcessExceptions() { /* Loop all debug events. */ svc::DebugEventInfo d; - while (R_SUCCEEDED(svc::GetDebugEvent(std::addressof(d), this->debug_handle))) { + while (R_SUCCEEDED(svc::GetDebugEvent(std::addressof(d), m_debug_handle))) { switch (d.type) { case svc::DebugEvent_CreateProcess: this->HandleDebugEventInfoCreateProcess(d); @@ -183,11 +183,11 @@ namespace ams::creport { } /* Parse crashed thread info. */ - this->crashed_thread.ReadFromProcess(this->debug_handle, this->thread_tls_map, this->crashed_thread_id, this->Is64Bit()); + m_crashed_thread.ReadFromProcess(m_debug_handle, m_thread_tls_map, m_crashed_thread_id, this->Is64Bit()); } void CrashReport::HandleDebugEventInfoCreateProcess(const svc::DebugEventInfo &d) { - this->process_info = d.info.create_process; + m_process_info = d.info.create_process; /* On 5.0.0+, we want to parse out a dying message from application crashes. */ if (hos::GetVersion() < hos::Version_5_0_0 || !IsApplication()) { @@ -195,12 +195,12 @@ namespace ams::creport { } /* Parse out user data. */ - const u64 address = this->process_info.user_exception_context_address + DyingMessageAddressOffset; + const u64 address = m_process_info.user_exception_context_address + DyingMessageAddressOffset; u64 userdata_address = 0; u64 userdata_size = 0; /* Read userdata address. */ - if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(userdata_address)), this->debug_handle, address, sizeof(userdata_address)))) { + if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(userdata_address)), m_debug_handle, address, sizeof(userdata_address)))) { return; } @@ -210,48 +210,48 @@ namespace ams::creport { } /* Read userdata size. */ - if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(userdata_size)), this->debug_handle, address + sizeof(userdata_address), sizeof(userdata_size)))) { + if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(userdata_size)), m_debug_handle, address + sizeof(userdata_address), sizeof(userdata_size)))) { return; } /* Cap userdata size. */ userdata_size = std::min(size_t(userdata_size), DyingMessageSizeMax); - this->dying_message_address = userdata_address; - this->dying_message_size = userdata_size; + m_dying_message_address = userdata_address; + m_dying_message_size = userdata_size; } void CrashReport::HandleDebugEventInfoCreateThread(const svc::DebugEventInfo &d) { /* Save info on the thread's TLS address for later. */ - this->thread_tls_map.SetThreadTls(d.info.create_thread.thread_id, d.info.create_thread.tls_address); + m_thread_tls_map.SetThreadTls(d.info.create_thread.thread_id, d.info.create_thread.tls_address); } void CrashReport::HandleDebugEventInfoException(const svc::DebugEventInfo &d) { switch (d.info.exception.type) { case svc::DebugException_UndefinedInstruction: - this->result = creport::ResultUndefinedInstruction(); + m_result = creport::ResultUndefinedInstruction(); break; case svc::DebugException_InstructionAbort: - this->result = creport::ResultInstructionAbort(); + m_result = creport::ResultInstructionAbort(); break; case svc::DebugException_DataAbort: - this->result = creport::ResultDataAbort(); + m_result = creport::ResultDataAbort(); break; case svc::DebugException_AlignmentFault: - this->result = creport::ResultAlignmentFault(); + m_result = creport::ResultAlignmentFault(); break; case svc::DebugException_UserBreak: - this->result = creport::ResultUserBreak(); + m_result = creport::ResultUserBreak(); /* Try to parse out the user break result. */ if (hos::GetVersion() >= hos::Version_5_0_0) { - svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(this->result)), this->debug_handle, d.info.exception.specific.user_break.address, sizeof(this->result)); + svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(m_result)), m_debug_handle, d.info.exception.specific.user_break.address, sizeof(m_result)); } break; case svc::DebugException_UndefinedSystemCall: - this->result = creport::ResultUndefinedSystemCall(); + m_result = creport::ResultUndefinedSystemCall(); break; case svc::DebugException_MemorySystemError: - this->result = creport::ResultMemorySystemError(); + m_result = creport::ResultMemorySystemError(); break; case svc::DebugException_DebuggerAttached: case svc::DebugException_BreakPoint: @@ -260,8 +260,8 @@ namespace ams::creport { } /* Save exception info. */ - this->exception_info = d.info.exception; - this->crashed_thread_id = d.thread_id; + m_exception_info = d.info.exception; + m_crashed_thread_id = d.thread_id; } void CrashReport::ProcessDyingMessage() { @@ -271,10 +271,10 @@ namespace ams::creport { } /* Validate address/size. */ - if (this->dying_message_address == 0 || this->dying_message_address & 0xFFF) { + if (m_dying_message_address == 0 || m_dying_message_address & 0xFFF) { return; } - if (this->dying_message_size > DyingMessageSizeMax) { + if (m_dying_message_size > DyingMessageSizeMax) { return; } @@ -284,12 +284,12 @@ namespace ams::creport { } /* Verify that we have a dying message buffer. */ - if (this->dying_message == nullptr) { + if (m_dying_message == nullptr) { return; } /* Read the dying message. */ - svc::ReadDebugProcessMemory(reinterpret_cast(this->dying_message), this->debug_handle, this->dying_message_address, this->dying_message_size); + svc::ReadDebugProcessMemory(reinterpret_cast(m_dying_message), m_debug_handle, m_dying_message_address, m_dying_message_size); } void CrashReport::SaveReport(bool enable_screenshot) { @@ -307,7 +307,7 @@ namespace ams::creport { char file_path[fs::EntryNameLengthMax + 1]; /* Save crash report. */ - util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.log", timestamp, this->process_info.program_id); + util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.log", timestamp, m_process_info.program_id); { ScopedFile file(file_path); if (file.IsOpen()) { @@ -316,25 +316,25 @@ namespace ams::creport { } /* Dump threads. */ - util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, this->process_info.program_id); + util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/dumps/%011lu_%016lx_thread_info.bin", timestamp, m_process_info.program_id); { ScopedFile file(file_path); if (file.IsOpen()) { - this->thread_list->DumpBinary(file, this->crashed_thread.GetThreadId()); + m_thread_list->DumpBinary(file, m_crashed_thread.GetThreadId()); } } /* Finalize our heap. */ - std::destroy_at(this->module_list); - std::destroy_at(this->thread_list); - lmem::FreeToExpHeap(this->heap_handle, this->module_list); - lmem::FreeToExpHeap(this->heap_handle, this->thread_list); - if (this->dying_message != nullptr) { - lmem::FreeToExpHeap(this->heap_handle, this->dying_message); + std::destroy_at(m_module_list); + std::destroy_at(m_thread_list); + lmem::FreeToExpHeap(m_heap_handle, m_module_list); + lmem::FreeToExpHeap(m_heap_handle, m_thread_list); + if (m_dying_message != nullptr) { + lmem::FreeToExpHeap(m_heap_handle, m_dying_message); } - this->module_list = nullptr; - this->thread_list = nullptr; - this->dying_message = nullptr; + m_module_list = nullptr; + m_thread_list = nullptr; + m_dying_message = nullptr; /* Try to take a screenshot. */ /* NOTE: Nintendo validates that enable_screenshot is true here, and validates that the application id is not in a blacklist. */ @@ -345,11 +345,11 @@ namespace ams::creport { ON_SCOPE_EXIT { capsrv::FinalizeScreenShotControl(); }; u64 jpeg_size; - if (R_SUCCEEDED(capsrv::CaptureJpegScreenshot(std::addressof(jpeg_size), this->heap_storage, sizeof(this->heap_storage), vi::LayerStack_ApplicationForDebug, TimeSpan::FromSeconds(10)))) { - util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.jpg", timestamp, this->process_info.program_id); + if (R_SUCCEEDED(capsrv::CaptureJpegScreenshot(std::addressof(jpeg_size), m_heap_storage, sizeof(m_heap_storage), vi::LayerStack_ApplicationForDebug, TimeSpan::FromSeconds(10)))) { + util::SNPrintf(file_path, sizeof(file_path), "sdmc:/atmosphere/crash_reports/%011lu_%016lx.jpg", timestamp, m_process_info.program_id); ScopedFile file(file_path); if (file.IsOpen()) { - file.Write(this->heap_storage, jpeg_size); + file.Write(m_heap_storage, jpeg_size); } } } @@ -360,42 +360,42 @@ namespace ams::creport { void CrashReport::SaveToFile(ScopedFile &file) { file.WriteFormat("Atmosphère Crash Report (v1.6):\n"); - file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", this->result.GetValue(), this->result.GetModule(), this->result.GetDescription()); + file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", m_result.GetValue(), m_result.GetModule(), m_result.GetDescription()); /* Process Info. */ char name_buf[0x10] = {}; - static_assert(sizeof(name_buf) >= sizeof(this->process_info.name), "buffer overflow!"); - std::memcpy(name_buf, this->process_info.name, sizeof(this->process_info.name)); + static_assert(sizeof(name_buf) >= sizeof(m_process_info.name), "buffer overflow!"); + std::memcpy(name_buf, m_process_info.name, sizeof(m_process_info.name)); file.WriteFormat("Process Info:\n"); file.WriteFormat(" Process Name: %s\n", name_buf); - file.WriteFormat(" Program ID: %016lx\n", this->process_info.program_id); - file.WriteFormat(" Process ID: %016lx\n", this->process_info.process_id); - file.WriteFormat(" Process Flags: %08x\n", this->process_info.flags); + file.WriteFormat(" Program ID: %016lx\n", m_process_info.program_id); + file.WriteFormat(" Process ID: %016lx\n", m_process_info.process_id); + file.WriteFormat(" Process Flags: %08x\n", m_process_info.flags); if (hos::GetVersion() >= hos::Version_5_0_0) { - file.WriteFormat(" User Exception Address: %s\n", this->module_list->GetFormattedAddressString(this->process_info.user_exception_context_address)); + file.WriteFormat(" User Exception Address: %s\n", m_module_list->GetFormattedAddressString(m_process_info.user_exception_context_address)); } /* Exception Info. */ file.WriteFormat("Exception Info:\n"); - file.WriteFormat(" Type: %s\n", GetDebugExceptionString(this->exception_info.type)); - file.WriteFormat(" Address: %s\n", this->module_list->GetFormattedAddressString(this->exception_info.address)); - switch (this->exception_info.type) { + file.WriteFormat(" Type: %s\n", GetDebugExceptionString(m_exception_info.type)); + file.WriteFormat(" Address: %s\n", m_module_list->GetFormattedAddressString(m_exception_info.address)); + switch (m_exception_info.type) { case svc::DebugException_UndefinedInstruction: - file.WriteFormat(" Opcode: %08x\n", this->exception_info.specific.undefined_instruction.insn); + file.WriteFormat(" Opcode: %08x\n", m_exception_info.specific.undefined_instruction.insn); break; case svc::DebugException_DataAbort: case svc::DebugException_AlignmentFault: - if (this->exception_info.specific.raw != this->exception_info.address) { - file.WriteFormat(" Fault Address: %s\n", this->module_list->GetFormattedAddressString(this->exception_info.specific.raw)); + if (m_exception_info.specific.raw != m_exception_info.address) { + file.WriteFormat(" Fault Address: %s\n", m_module_list->GetFormattedAddressString(m_exception_info.specific.raw)); } break; case svc::DebugException_UndefinedSystemCall: - file.WriteFormat(" Svc Id: 0x%02x\n", this->exception_info.specific.undefined_system_call.id); + file.WriteFormat(" Svc Id: 0x%02x\n", m_exception_info.specific.undefined_system_call.id); break; case svc::DebugException_UserBreak: - file.WriteFormat(" Break Reason: 0x%x\n", this->exception_info.specific.user_break.break_reason); - file.WriteFormat(" Break Address: %s\n", this->module_list->GetFormattedAddressString(this->exception_info.specific.user_break.address)); - file.WriteFormat(" Break Size: 0x%lx\n", this->exception_info.specific.user_break.size); + file.WriteFormat(" Break Reason: 0x%x\n", m_exception_info.specific.user_break.break_reason); + file.WriteFormat(" Break Address: %s\n", m_module_list->GetFormattedAddressString(m_exception_info.specific.user_break.address)); + file.WriteFormat(" Break Size: 0x%lx\n", m_exception_info.specific.user_break.size); break; default: break; @@ -403,23 +403,23 @@ namespace ams::creport { /* Crashed Thread Info. */ file.WriteFormat("Crashed Thread Info:\n"); - this->crashed_thread.SaveToFile(file); + m_crashed_thread.SaveToFile(file); /* Dying Message. */ - if (hos::GetVersion() >= hos::Version_5_0_0 && this->dying_message_size != 0) { + if (hos::GetVersion() >= hos::Version_5_0_0 && m_dying_message_size != 0) { file.WriteFormat("Dying Message Info:\n"); - file.WriteFormat(" Address: 0x%s\n", this->module_list->GetFormattedAddressString(this->dying_message_address)); - file.WriteFormat(" Size: 0x%016lx\n", this->dying_message_size); - file.DumpMemory( " Dying Message: ", this->dying_message, this->dying_message_size); + file.WriteFormat(" Address: 0x%s\n", m_module_list->GetFormattedAddressString(m_dying_message_address)); + file.WriteFormat(" Size: 0x%016lx\n", m_dying_message_size); + file.DumpMemory( " Dying Message: ", m_dying_message, m_dying_message_size); } /* Module Info. */ file.WriteFormat("Module Info:\n"); - this->module_list->SaveToFile(file); + m_module_list->SaveToFile(file); /* Thread Info. */ file.WriteFormat("Thread Report:\n"); - this->thread_list->SaveToFile(file); + m_thread_list->SaveToFile(file); } } diff --git a/stratosphere/creport/source/creport_crash_report.hpp b/stratosphere/creport/source/creport_crash_report.hpp index 0ed1ff2e4..36aee6b11 100644 --- a/stratosphere/creport/source/creport_crash_report.hpp +++ b/stratosphere/creport/source/creport_crash_report.hpp @@ -25,66 +25,66 @@ namespace ams::creport { static constexpr size_t MemoryHeapSize = 512_KB; static_assert(MemoryHeapSize >= DyingMessageSizeMax + sizeof(ModuleList) + sizeof(ThreadList) + os::MemoryPageSize); private: - os::NativeHandle debug_handle = os::InvalidNativeHandle; - bool has_extra_info = true; - Result result = creport::ResultIncompleteReport(); + os::NativeHandle m_debug_handle = os::InvalidNativeHandle; + bool m_has_extra_info = true; + Result m_result = creport::ResultIncompleteReport(); /* Meta, used for building module/thread list. */ - ThreadTlsMap thread_tls_map = {}; + ThreadTlsMap m_thread_tls_map = {}; /* Attach process info. */ - svc::DebugInfoCreateProcess process_info = {}; - u64 dying_message_address = 0; - u64 dying_message_size = 0; - u8 *dying_message = nullptr; + svc::DebugInfoCreateProcess m_process_info = {}; + u64 m_dying_message_address = 0; + u64 m_dying_message_size = 0; + u8 *m_dying_message = nullptr; /* Exception info. */ - svc::DebugInfoException exception_info = {}; - u64 module_base_address = 0; - u64 crashed_thread_id = 0; - ThreadInfo crashed_thread; + svc::DebugInfoException m_exception_info = {}; + u64 m_module_base_address = 0; + u64 m_crashed_thread_id = 0; + ThreadInfo m_crashed_thread; /* Lists. */ - ModuleList *module_list = nullptr; - ThreadList *thread_list = nullptr; + ModuleList *m_module_list = nullptr; + ThreadList *m_thread_list = nullptr; /* Memory heap. */ - lmem::HeapHandle heap_handle = nullptr; - u8 heap_storage[MemoryHeapSize] = {}; + lmem::HeapHandle m_heap_handle = nullptr; + u8 m_heap_storage[MemoryHeapSize] = {}; public: constexpr CrashReport() = default; Result GetResult() const { - return this->result; + return m_result; } bool IsComplete() const { - return !ResultIncompleteReport::Includes(this->result); + return !ResultIncompleteReport::Includes(m_result); } bool IsOpen() const { - return this->debug_handle != os::InvalidNativeHandle; + return m_debug_handle != os::InvalidNativeHandle; } bool IsApplication() const { - return (this->process_info.flags & svc::CreateProcessFlag_IsApplication) != 0; + return (m_process_info.flags & svc::CreateProcessFlag_IsApplication) != 0; } bool Is64Bit() const { - return (this->process_info.flags & svc::CreateProcessFlag_Is64Bit) != 0; + return (m_process_info.flags & svc::CreateProcessFlag_Is64Bit) != 0; } bool IsUserBreak() const { - return this->exception_info.type == svc::DebugException_UserBreak; + return m_exception_info.type == svc::DebugException_UserBreak; } bool OpenProcess(os::ProcessId process_id) { - return R_SUCCEEDED(svc::DebugActiveProcess(std::addressof(this->debug_handle), process_id.value)); + return R_SUCCEEDED(svc::DebugActiveProcess(std::addressof(m_debug_handle), process_id.value)); } void Close() { - os::CloseNativeHandle(this->debug_handle); - this->debug_handle = os::InvalidNativeHandle; + os::CloseNativeHandle(m_debug_handle); + m_debug_handle = os::InvalidNativeHandle; } void Initialize(); diff --git a/stratosphere/creport/source/creport_modules.cpp b/stratosphere/creport/source/creport_modules.cpp index a832cc3cf..a9ec94810 100644 --- a/stratosphere/creport/source/creport_modules.cpp +++ b/stratosphere/creport/source/creport_modules.cpp @@ -46,12 +46,12 @@ namespace ams::creport { } void ModuleList::SaveToFile(ScopedFile &file) { - file.WriteFormat(" Number of Modules: %zu\n", this->num_modules); - for (size_t i = 0; i < this->num_modules; i++) { - const auto& module = this->modules[i]; + file.WriteFormat(" Number of Modules: %zu\n", m_num_modules); + for (size_t i = 0; i < m_num_modules; i++) { + const auto& module = m_modules[i]; file.WriteFormat(" Module %02zu:\n", i); file.WriteFormat(" Address: %016lx-%016lx\n", module.start_address, module.end_address); - if (std::strcmp(this->modules[i].name, "") != 0) { + if (std::strcmp(m_modules[i].name, "") != 0) { file.WriteFormat(" Name: %s\n", module.name); } file.DumpMemory(" Build Id: ", module.build_id, sizeof(module.build_id)); @@ -60,7 +60,7 @@ namespace ams::creport { void ModuleList::FindModulesFromThreadInfo(os::NativeHandle debug_handle, const ThreadInfo &thread) { /* Set the debug handle, for access in other member functions. */ - this->debug_handle = debug_handle; + m_debug_handle = debug_handle; /* Try to add the thread's PC. */ this->TryAddModule(thread.GetPC()); @@ -82,25 +82,25 @@ namespace ams::creport { } /* Check whether we already have this module. */ - for (size_t i = 0; i < this->num_modules; i++) { - if (this->modules[i].start_address <= base_address && base_address < this->modules[i].end_address) { + for (size_t i = 0; i < m_num_modules; i++) { + if (m_modules[i].start_address <= base_address && base_address < m_modules[i].end_address) { return; } } /* Add all contiguous modules. */ uintptr_t cur_address = base_address; - while (this->num_modules < ModuleCountMax) { + while (m_num_modules < ModuleCountMax) { /* Get the region extents. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, cur_address))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, cur_address))) { break; } /* Parse module. */ if (mi.permission == svc::MemoryPermission_ReadExecute) { - auto& module = this->modules[this->num_modules++]; + auto& module = m_modules[m_num_modules++]; module.start_address = mi.base_address; module.end_address = mi.base_address + mi.size; GetModuleName(module.name, module.start_address, module.end_address); @@ -129,20 +129,20 @@ namespace ams::creport { /* Query the memory region our guess falls in. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, guess))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, guess))) { return false; } /* If we fall into a RW region, it may be rwdata. Query the region before it, which may be rodata or text. */ if (mi.permission == svc::MemoryPermission_ReadWrite) { - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, mi.base_address - 4))) { return false; } } /* If we fall into an RO region, it may be rodata. Query the region before it, which should be text. */ if (mi.permission == svc::MemoryPermission_Read) { - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, mi.base_address - 4))) { return false; } } @@ -155,7 +155,7 @@ namespace ams::creport { /* Modules are a series of contiguous (text/rodata/rwdata) regions. */ /* Iterate backwards until we find unmapped memory, to find the start of the set of modules loaded here. */ while (mi.base_address > 0) { - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, mi.base_address - 4))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, mi.base_address - 4))) { return false; } @@ -181,7 +181,7 @@ namespace ams::creport { svc::PageInfo pi; /* Verify .rodata is read-only. */ - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { return; } @@ -189,7 +189,7 @@ namespace ams::creport { const u64 rw_start_address = mi.base_address + mi.size; /* Read start of .rodata. */ - if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(rodata_start)), this->debug_handle, ro_start_address, sizeof(rodata_start)))) { + if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(std::addressof(rodata_start)), m_debug_handle, ro_start_address, sizeof(rodata_start)))) { return; } @@ -228,13 +228,13 @@ namespace ams::creport { /* Verify .rodata is read-only. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), this->debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), m_debug_handle, ro_start_address)) || mi.permission != svc::MemoryPermission_Read) { return; } /* We want to read the last two pages of .rodata. */ const size_t read_size = mi.size >= sizeof(g_last_rodata_pages) ? sizeof(g_last_rodata_pages) : (sizeof(g_last_rodata_pages) / 2); - if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(g_last_rodata_pages), this->debug_handle, mi.base_address + mi.size - read_size, read_size))) { + if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(g_last_rodata_pages), m_debug_handle, mi.base_address + mi.size - read_size, read_size))) { return; } @@ -249,18 +249,18 @@ namespace ams::creport { const char *ModuleList::GetFormattedAddressString(uintptr_t address) { /* Print default formatted string. */ - util::SNPrintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx", address); + util::SNPrintf(m_address_str_buf, sizeof(m_address_str_buf), "%016lx", address); /* See if the address is inside a module, for pretty-printing. */ - for (size_t i = 0; i < this->num_modules; i++) { - const auto& module = this->modules[i]; + for (size_t i = 0; i < m_num_modules; i++) { + const auto& module = m_modules[i]; if (module.start_address <= address && address < module.end_address) { - util::SNPrintf(this->address_str_buf, sizeof(this->address_str_buf), "%016lx (%s + 0x%lx)", address, module.name, address - module.start_address); + util::SNPrintf(m_address_str_buf, sizeof(m_address_str_buf), "%016lx (%s + 0x%lx)", address, module.name, address - module.start_address); break; } } - return this->address_str_buf; + return m_address_str_buf; } } diff --git a/stratosphere/creport/source/creport_modules.hpp b/stratosphere/creport/source/creport_modules.hpp index 882487a72..13602032b 100644 --- a/stratosphere/creport/source/creport_modules.hpp +++ b/stratosphere/creport/source/creport_modules.hpp @@ -32,23 +32,23 @@ namespace ams::creport { u64 end_address; }; private: - os::NativeHandle debug_handle; - size_t num_modules; - ModuleInfo modules[ModuleCountMax]; + os::NativeHandle m_debug_handle; + size_t m_num_modules; + ModuleInfo m_modules[ModuleCountMax]; /* For pretty-printing. */ - char address_str_buf[0x280]; + char m_address_str_buf[0x280]; public: - ModuleList() : debug_handle(os::InvalidNativeHandle), num_modules(0) { - std::memset(this->modules, 0, sizeof(this->modules)); + ModuleList() : m_debug_handle(os::InvalidNativeHandle), m_num_modules(0) { + std::memset(m_modules, 0, sizeof(m_modules)); } size_t GetModuleCount() const { - return this->num_modules; + return m_num_modules; } u64 GetModuleStartAddress(size_t i) const { - return this->modules[i].start_address; + return m_modules[i].start_address; } void FindModulesFromThreadInfo(os::NativeHandle debug_handle, const ThreadInfo &thread); diff --git a/stratosphere/creport/source/creport_scoped_file.cpp b/stratosphere/creport/source/creport_scoped_file.cpp index 8fa22ec28..4daf9e046 100644 --- a/stratosphere/creport/source/creport_scoped_file.cpp +++ b/stratosphere/creport/source/creport_scoped_file.cpp @@ -90,8 +90,8 @@ namespace ams::creport { } /* Advance, if we write successfully. */ - if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, data, size, fs::WriteOption::Flush))) { - this->offset += size; + if (R_SUCCEEDED(fs::WriteFile(m_file, m_offset, data, size, fs::WriteOption::Flush))) { + m_offset += size; } } diff --git a/stratosphere/creport/source/creport_scoped_file.hpp b/stratosphere/creport/source/creport_scoped_file.hpp index 2958e48a7..7b302b589 100644 --- a/stratosphere/creport/source/creport_scoped_file.hpp +++ b/stratosphere/creport/source/creport_scoped_file.hpp @@ -22,24 +22,24 @@ namespace ams::creport { NON_COPYABLE(ScopedFile); NON_MOVEABLE(ScopedFile); private: - fs::FileHandle file; - s64 offset; - bool opened; + fs::FileHandle m_file; + s64 m_offset; + bool m_opened; public: - ScopedFile(const char *path) : file(), offset(), opened(false) { + ScopedFile(const char *path) : m_file(), m_offset(), m_opened(false) { if (R_SUCCEEDED(fs::CreateFile(path, 0))) { - this->opened = R_SUCCEEDED(fs::OpenFile(std::addressof(this->file), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); + m_opened = R_SUCCEEDED(fs::OpenFile(std::addressof(m_file), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); } } ~ScopedFile() { - if (this->opened) { - fs::CloseFile(file); + if (m_opened) { + fs::CloseFile(m_file); } } bool IsOpen() const { - return this->opened; + return m_opened; } void WriteString(const char *str); diff --git a/stratosphere/creport/source/creport_threads.cpp b/stratosphere/creport/source/creport_threads.cpp index 1757534f7..bb08d8591 100644 --- a/stratosphere/creport/source/creport_threads.cpp +++ b/stratosphere/creport/source/creport_threads.cpp @@ -61,67 +61,67 @@ namespace ams::creport { } void ThreadList::SaveToFile(ScopedFile &file) { - file.WriteFormat("Number of Threads: %02zu\n", this->thread_count); - for (size_t i = 0; i < this->thread_count; i++) { + file.WriteFormat("Number of Threads: %02zu\n", m_thread_count); + for (size_t i = 0; i < m_thread_count; i++) { file.WriteFormat("Threads[%02zu]:\n", i); - this->threads[i].SaveToFile(file); + m_threads[i].SaveToFile(file); } } void ThreadInfo::SaveToFile(ScopedFile &file) { - file.WriteFormat(" Thread ID: %016lx\n", this->thread_id); - if (std::strcmp(this->name, "") != 0) { - file.WriteFormat(" Thread Name: %s\n", this->name); + file.WriteFormat(" Thread ID: %016lx\n", m_thread_id); + if (std::strcmp(m_name, "") != 0) { + file.WriteFormat(" Thread Name: %s\n", m_name); } - if (this->stack_top != 0) { - file.WriteFormat(" Stack Region: %016lx-%016lx\n", this->stack_bottom, this->stack_top); + if (m_stack_top != 0) { + file.WriteFormat(" Stack Region: %016lx-%016lx\n", m_stack_bottom, m_stack_top); } file.WriteFormat(" Registers:\n"); { for (unsigned int i = 0; i <= 28; i++) { - file.WriteFormat(" X[%02u]: %s\n", i, this->module_list->GetFormattedAddressString(this->context.r[i])); + file.WriteFormat(" X[%02u]: %s\n", i, m_module_list->GetFormattedAddressString(m_context.r[i])); } - file.WriteFormat(" FP: %s\n", this->module_list->GetFormattedAddressString(this->context.fp)); - file.WriteFormat(" LR: %s\n", this->module_list->GetFormattedAddressString(this->context.lr)); - file.WriteFormat(" SP: %s\n", this->module_list->GetFormattedAddressString(this->context.sp)); - file.WriteFormat(" PC: %s\n", this->module_list->GetFormattedAddressString(this->context.pc)); + file.WriteFormat(" FP: %s\n", m_module_list->GetFormattedAddressString(m_context.fp)); + file.WriteFormat(" LR: %s\n", m_module_list->GetFormattedAddressString(m_context.lr)); + file.WriteFormat(" SP: %s\n", m_module_list->GetFormattedAddressString(m_context.sp)); + file.WriteFormat(" PC: %s\n", m_module_list->GetFormattedAddressString(m_context.pc)); } - if (this->stack_trace_size != 0) { + if (m_stack_trace_size != 0) { file.WriteFormat(" Stack Trace:\n"); - for (size_t i = 0; i < this->stack_trace_size; i++) { - file.WriteFormat(" ReturnAddress[%02zu]: %s\n", i, this->module_list->GetFormattedAddressString(this->stack_trace[i])); + for (size_t i = 0; i < m_stack_trace_size; i++) { + file.WriteFormat(" ReturnAddress[%02zu]: %s\n", i, m_module_list->GetFormattedAddressString(m_stack_trace[i])); } } - if (this->stack_dump_base != 0) { + if (m_stack_dump_base != 0) { file.WriteFormat(" Stack Dump: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); for (size_t i = 0; i < 0x10; i++) { const size_t ofs = i * 0x10; file.WriteFormat(" %012lx %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - this->stack_dump_base + ofs, this->stack_dump[ofs + 0], this->stack_dump[ofs + 1], this->stack_dump[ofs + 2], this->stack_dump[ofs + 3], this->stack_dump[ofs + 4], this->stack_dump[ofs + 5], this->stack_dump[ofs + 6], this->stack_dump[ofs + 7], - this->stack_dump[ofs + 8], this->stack_dump[ofs + 9], this->stack_dump[ofs + 10], this->stack_dump[ofs + 11], this->stack_dump[ofs + 12], this->stack_dump[ofs + 13], this->stack_dump[ofs + 14], this->stack_dump[ofs + 15]); + m_stack_dump_base + ofs, m_stack_dump[ofs + 0], m_stack_dump[ofs + 1], m_stack_dump[ofs + 2], m_stack_dump[ofs + 3], m_stack_dump[ofs + 4], m_stack_dump[ofs + 5], m_stack_dump[ofs + 6], m_stack_dump[ofs + 7], + m_stack_dump[ofs + 8], m_stack_dump[ofs + 9], m_stack_dump[ofs + 10], m_stack_dump[ofs + 11], m_stack_dump[ofs + 12], m_stack_dump[ofs + 13], m_stack_dump[ofs + 14], m_stack_dump[ofs + 15]); } } - if (this->tls_address != 0) { - file.WriteFormat(" TLS Address: %016lx\n", this->tls_address); + if (m_tls_address != 0) { + file.WriteFormat(" TLS Address: %016lx\n", m_tls_address); file.WriteFormat(" TLS Dump: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); for (size_t i = 0; i < 0x10; i++) { const size_t ofs = i * 0x10; file.WriteFormat(" %012lx %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - this->tls_address + ofs, this->tls[ofs + 0], this->tls[ofs + 1], this->tls[ofs + 2], this->tls[ofs + 3], this->tls[ofs + 4], this->tls[ofs + 5], this->tls[ofs + 6], this->tls[ofs + 7], - this->tls[ofs + 8], this->tls[ofs + 9], this->tls[ofs + 10], this->tls[ofs + 11], this->tls[ofs + 12], this->tls[ofs + 13], this->tls[ofs + 14], this->tls[ofs + 15]); + m_tls_address + ofs, m_tls[ofs + 0], m_tls[ofs + 1], m_tls[ofs + 2], m_tls[ofs + 3], m_tls[ofs + 4], m_tls[ofs + 5], m_tls[ofs + 6], m_tls[ofs + 7], + m_tls[ofs + 8], m_tls[ofs + 9], m_tls[ofs + 10], m_tls[ofs + 11], m_tls[ofs + 12], m_tls[ofs + 13], m_tls[ofs + 14], m_tls[ofs + 15]); } } } bool ThreadInfo::ReadFromProcess(os::NativeHandle debug_handle, ThreadTlsMap &tls_map, u64 thread_id, bool is_64_bit) { /* Set thread id. */ - this->thread_id = thread_id; + m_thread_id = thread_id; /* Verify that the thread is running or waiting. */ { u64 _; u32 _thread_state; - if (R_FAILED(svc::GetDebugThreadParam(&_, &_thread_state, debug_handle, this->thread_id, svc::DebugThreadParam_State))) { + if (R_FAILED(svc::GetDebugThreadParam(&_, &_thread_state, debug_handle, m_thread_id, svc::DebugThreadParam_State))) { return false; } @@ -132,24 +132,24 @@ namespace ams::creport { } /* Get the thread context. */ - if (R_FAILED(svc::GetDebugThreadContext(std::addressof(this->context), debug_handle, this->thread_id, svc::ThreadContextFlag_All))) { + if (R_FAILED(svc::GetDebugThreadContext(std::addressof(m_context), debug_handle, m_thread_id, svc::ThreadContextFlag_All))) { return false; } /* In aarch32 mode svc::GetDebugThreadContext does not set the LR, FP, and SP registers correctly. */ if (!is_64_bit) { - this->context.fp = this->context.r[11]; - this->context.sp = this->context.r[13]; - this->context.lr = this->context.r[14]; + m_context.fp = m_context.r[11]; + m_context.sp = m_context.r[13]; + m_context.lr = m_context.r[14]; } /* Read TLS, if present. */ /* TODO: struct definitions for nnSdk's ThreadType/TLS Layout? */ - this->tls_address = 0; - if (tls_map.GetThreadTls(std::addressof(this->tls_address), thread_id)) { + m_tls_address = 0; + if (tls_map.GetThreadTls(std::addressof(m_tls_address), thread_id)) { u8 thread_tls[sizeof(svc::ThreadLocalRegion)]; - if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast(thread_tls), debug_handle, this->tls_address, sizeof(thread_tls)))) { - std::memcpy(this->tls, thread_tls, sizeof(this->tls)); + if (R_SUCCEEDED(svc::ReadDebugProcessMemory(reinterpret_cast(thread_tls), debug_handle, m_tls_address, sizeof(thread_tls)))) { + std::memcpy(m_tls, thread_tls, sizeof(m_tls)); /* Try to detect libnx threads, and skip name parsing then. */ if (*(reinterpret_cast(std::addressof(thread_tls[0x1E0]))) != LibnxThreadVarMagic) { u8 thread_type[0x1C0]; @@ -161,12 +161,12 @@ namespace ams::creport { /* Check thread name is actually at thread name. */ static_assert(0x1A8 - 0x188 == NameLengthMax, "NameLengthMax definition!"); if (*(reinterpret_cast(std::addressof(thread_type[0x1A8]))) == thread_type_addr + 0x188) { - std::memcpy(this->name, thread_type + 0x188, NameLengthMax); + std::memcpy(m_name, thread_type + 0x188, NameLengthMax); } } else if (thread_version == 1) { static_assert(0x1A0 - 0x180 == NameLengthMax, "NameLengthMax definition!"); if (*(reinterpret_cast(std::addressof(thread_type[0x1A0]))) == thread_type_addr + 0x180) { - std::memcpy(this->name, thread_type + 0x180, NameLengthMax); + std::memcpy(m_name, thread_type + 0x180, NameLengthMax); } } } @@ -179,9 +179,9 @@ namespace ams::creport { /* Dump stack trace. */ if (is_64_bit) { - ReadStackTrace(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); + ReadStackTrace(std::addressof(m_stack_trace_size), m_stack_trace, StackTraceSizeMax, debug_handle, m_context.fp); } else { - ReadStackTrace(std::addressof(this->stack_trace_size), this->stack_trace, StackTraceSizeMax, debug_handle, this->context.fp); + ReadStackTrace(std::addressof(m_stack_trace_size), m_stack_trace, StackTraceSizeMax, debug_handle, m_context.fp); } return true; @@ -191,7 +191,7 @@ namespace ams::creport { /* Query stack region. */ svc::MemoryInfo mi; svc::PageInfo pi; - if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, this->context.sp))) { + if (R_FAILED(svc::QueryDebugProcessMemory(std::addressof(mi), std::addressof(pi), debug_handle, m_context.sp))) { return; } @@ -204,56 +204,56 @@ namespace ams::creport { } /* Save stack extents. */ - this->stack_bottom = mi.base_address; - this->stack_top = mi.base_address + mi.size; + m_stack_bottom = mi.base_address; + m_stack_top = mi.base_address + mi.size; /* We always want to dump 0x100 of stack, starting from the lowest 0x10-byte aligned address below the stack pointer. */ /* Note: if the stack pointer is below the stack bottom, we will start dumping from the stack bottom. */ - this->stack_dump_base = std::min(std::max(this->context.sp & ~0xFul, this->stack_bottom), this->stack_top - sizeof(this->stack_dump)); + m_stack_dump_base = std::min(std::max(m_context.sp & ~0xFul, m_stack_bottom), m_stack_top - sizeof(m_stack_dump)); /* Try to read stack. */ - if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(this->stack_dump), debug_handle, this->stack_dump_base, sizeof(this->stack_dump)))) { - this->stack_dump_base = 0; + if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast(m_stack_dump), debug_handle, m_stack_dump_base, sizeof(m_stack_dump)))) { + m_stack_dump_base = 0; } } void ThreadInfo::DumpBinary(ScopedFile &file) { /* Dump id and context. */ - file.Write(std::addressof(this->thread_id), sizeof(this->thread_id)); - file.Write(std::addressof(this->context), sizeof(this->context)); + file.Write(std::addressof(m_thread_id), sizeof(m_thread_id)); + file.Write(std::addressof(m_context), sizeof(m_context)); /* Dump TLS info and name. */ - file.Write(std::addressof(this->tls_address), sizeof(this->tls_address)); - file.Write(std::addressof(this->tls), sizeof(this->tls)); - file.Write(std::addressof(this->name), sizeof(this->name)); + file.Write(std::addressof(m_tls_address), sizeof(m_tls_address)); + file.Write(std::addressof(m_tls), sizeof(m_tls)); + file.Write(std::addressof(m_name), sizeof(m_name)); /* Dump stack extents and stack dump. */ - file.Write(std::addressof(this->stack_bottom), sizeof(this->stack_bottom)); - file.Write(std::addressof(this->stack_top), sizeof(this->stack_top)); - file.Write(std::addressof(this->stack_dump_base), sizeof(this->stack_dump_base)); - file.Write(std::addressof(this->stack_dump), sizeof(this->stack_dump)); + file.Write(std::addressof(m_stack_bottom), sizeof(m_stack_bottom)); + file.Write(std::addressof(m_stack_top), sizeof(m_stack_top)); + file.Write(std::addressof(m_stack_dump_base), sizeof(m_stack_dump_base)); + file.Write(std::addressof(m_stack_dump), sizeof(m_stack_dump)); /* Dump stack trace. */ { - const u64 sts = this->stack_trace_size; + const u64 sts = m_stack_trace_size; file.Write(std::addressof(sts), sizeof(sts)); } - file.Write(this->stack_trace, this->stack_trace_size); + file.Write(m_stack_trace, m_stack_trace_size); } void ThreadList::DumpBinary(ScopedFile &file, u64 crashed_thread_id) { const u32 magic = DumpedThreadInfoMagic; - const u32 count = this->thread_count; + const u32 count = m_thread_count; file.Write(std::addressof(magic), sizeof(magic)); file.Write(std::addressof(count), sizeof(count)); file.Write(std::addressof(crashed_thread_id), sizeof(crashed_thread_id)); - for (size_t i = 0; i < this->thread_count; i++) { - this->threads[i].DumpBinary(file); + for (size_t i = 0; i < m_thread_count; i++) { + m_threads[i].DumpBinary(file); } } void ThreadList::ReadFromProcess(os::NativeHandle debug_handle, ThreadTlsMap &tls_map, bool is_64_bit) { - this->thread_count = 0; + m_thread_count = 0; /* Get thread list. */ s32 num_threads; @@ -267,8 +267,8 @@ namespace ams::creport { /* Parse thread infos. */ for (s32 i = 0; i < num_threads; i++) { - if (this->threads[this->thread_count].ReadFromProcess(debug_handle, tls_map, thread_ids[i], is_64_bit)) { - this->thread_count++; + if (m_threads[m_thread_count].ReadFromProcess(debug_handle, tls_map, thread_ids[i], is_64_bit)) { + m_thread_count++; } } } diff --git a/stratosphere/creport/source/creport_threads.hpp b/stratosphere/creport/source/creport_threads.hpp index ed89261a8..a47a9aeb4 100644 --- a/stratosphere/creport/source/creport_threads.hpp +++ b/stratosphere/creport/source/creport_threads.hpp @@ -60,53 +60,53 @@ namespace ams::creport { static constexpr size_t StackTraceSizeMax = 0x20; static constexpr size_t NameLengthMax = 0x20; private: - svc::ThreadContext context = {}; - u64 thread_id = 0; - u64 stack_top = 0; - u64 stack_bottom = 0; - u64 stack_trace[StackTraceSizeMax] = {}; - size_t stack_trace_size = 0; - u64 tls_address = 0; - u8 tls[0x100] = {}; - u64 stack_dump_base = 0; - u8 stack_dump[0x100] = {}; - char name[NameLengthMax + 1] = {}; - ModuleList *module_list = nullptr; + svc::ThreadContext m_context = {}; + u64 m_thread_id = 0; + u64 m_stack_top = 0; + u64 m_stack_bottom = 0; + u64 m_stack_trace[StackTraceSizeMax] = {}; + size_t m_stack_trace_size = 0; + u64 m_tls_address = 0; + u8 m_tls[0x100] = {}; + u64 m_stack_dump_base = 0; + u8 m_stack_dump[0x100] = {}; + char m_name[NameLengthMax + 1] = {}; + ModuleList *m_module_list = nullptr; public: u64 GetGeneralPurposeRegister(size_t i) const { - return this->context.r[i]; + return m_context.r[i]; } u64 GetPC() const { - return this->context.pc; + return m_context.pc; } u64 GetLR() const { - return this->context.lr; + return m_context.lr; } u64 GetFP() const { - return this->context.fp; + return m_context.fp; } u64 GetSP() const { - return this->context.sp; + return m_context.sp; } u64 GetThreadId() const { - return this->thread_id; + return m_thread_id; } size_t GetStackTraceSize() const { - return this->stack_trace_size; + return m_stack_trace_size; } u64 GetStackTrace(size_t i) const { - return this->stack_trace[i]; + return m_stack_trace[i]; } void SetModuleList(ModuleList *ml) { - this->module_list = ml; + m_module_list = ml; } bool ReadFromProcess(os::NativeHandle debug_handle, ThreadTlsMap &tls_map, u64 thread_id, bool is_64_bit); @@ -118,20 +118,20 @@ namespace ams::creport { class ThreadList { private: - size_t thread_count = 0; - ThreadInfo threads[ThreadCountMax]; + size_t m_thread_count = 0; + ThreadInfo m_threads[ThreadCountMax]; public: size_t GetThreadCount() const { - return this->thread_count; + return m_thread_count; } const ThreadInfo &GetThreadInfo(size_t i) const { - return this->threads[i]; + return m_threads[i]; } void SetModuleList(ModuleList *ml) { - for (size_t i = 0; i < this->thread_count; i++) { - this->threads[i].SetModuleList(ml); + for (size_t i = 0; i < m_thread_count; i++) { + m_threads[i].SetModuleList(ml); } } diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp index fe43d97e5..f8c1017f7 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp @@ -83,28 +83,28 @@ namespace ams::dmnt::cheat::impl { private: static constexpr size_t ThreadStackSize = 0x4000; private: - os::SdkMutex cheat_lock; - os::Event unsafe_break_event; - os::Event debug_events_event; /* Autoclear. */ - os::ThreadType detect_thread, debug_events_thread; - os::SystemEvent cheat_process_event; - os::NativeHandle cheat_process_debug_handle = os::InvalidNativeHandle; - CheatProcessMetadata cheat_process_metadata = {}; + os::SdkMutex m_cheat_lock; + os::Event m_unsafe_break_event; + os::Event m_debug_events_event; /* Autoclear. */ + os::ThreadType m_detect_thread, m_debug_events_thread; + os::SystemEvent m_cheat_process_event; + os::NativeHandle m_cheat_process_debug_handle = os::InvalidNativeHandle; + CheatProcessMetadata m_cheat_process_metadata = {}; - os::ThreadType vm_thread; - bool broken_unsafe = false; - bool needs_reload_vm = false; - CheatVirtualMachine cheat_vm; + os::ThreadType m_vm_thread; + bool m_broken_unsafe = false; + bool m_needs_reload_vm = false; + CheatVirtualMachine m_cheat_vm; - bool enable_cheats_by_default = true; - bool always_save_cheat_toggles = false; - bool should_save_cheat_toggles = false; - CheatEntry cheat_entries[MaxCheatCount] = {}; - FrozenAddressMap frozen_addresses_map = {}; + bool m_enable_cheats_by_default = true; + bool m_always_save_cheat_toggles = false; + bool m_should_save_cheat_toggles = false; + CheatEntry m_cheat_entries[MaxCheatCount] = {}; + FrozenAddressMap m_frozen_addresses_map = {}; - alignas(os::MemoryPageSize) u8 detect_thread_stack[ThreadStackSize] = {}; - alignas(os::MemoryPageSize) u8 debug_events_thread_stack[ThreadStackSize] = {}; - alignas(os::MemoryPageSize) u8 vm_thread_stack[ThreadStackSize] = {}; + alignas(os::MemoryPageSize) u8 m_detect_thread_stack[ThreadStackSize] = {}; + alignas(os::MemoryPageSize) u8 m_debug_events_thread_stack[ThreadStackSize] = {}; + alignas(os::MemoryPageSize) u8 m_vm_thread_stack[ThreadStackSize] = {}; private: static void DetectLaunchThread(void *_this); static void VirtualMachineThread(void *_this); @@ -119,18 +119,18 @@ namespace ams::dmnt::cheat::impl { void SaveCheatToggles(const ncm::ProgramId program_id); bool GetNeedsReloadVm() const { - return this->needs_reload_vm; + return m_needs_reload_vm; } void SetNeedsReloadVm(bool reload) { - this->needs_reload_vm = reload; + m_needs_reload_vm = reload; } void ResetCheatEntry(size_t i) { if (i < MaxCheatCount) { - std::memset(this->cheat_entries + i, 0, sizeof(this->cheat_entries[i])); - this->cheat_entries[i].cheat_id = i; + std::memset(m_cheat_entries + i, 0, sizeof(m_cheat_entries[i])); + m_cheat_entries[i].cheat_id = i; this->SetNeedsReloadVm(true); } @@ -141,12 +141,12 @@ namespace ams::dmnt::cheat::impl { this->ResetCheatEntry(i); } - this->cheat_vm.ResetStaticRegisters(); + m_cheat_vm.ResetStaticRegisters(); } CheatEntry *GetCheatEntryById(size_t i) { if (i < MaxCheatCount) { - return this->cheat_entries + i; + return m_cheat_entries + i; } return nullptr; @@ -155,8 +155,8 @@ namespace ams::dmnt::cheat::impl { CheatEntry *GetCheatEntryByReadableName(const char *readable_name) { /* Check all non-master cheats for match. */ for (size_t i = 1; i < MaxCheatCount; i++) { - if (std::strncmp(this->cheat_entries[i].definition.readable_name, readable_name, sizeof(this->cheat_entries[i].definition.readable_name)) == 0) { - return this->cheat_entries + i; + if (std::strncmp(m_cheat_entries[i].definition.readable_name, readable_name, sizeof(m_cheat_entries[i].definition.readable_name)) == 0) { + return m_cheat_entries + i; } } @@ -166,8 +166,8 @@ namespace ams::dmnt::cheat::impl { CheatEntry *GetFreeCheatEntry() { /* Check all non-master cheats for availability. */ for (size_t i = 1; i < MaxCheatCount; i++) { - if (this->cheat_entries[i].definition.num_opcodes == 0) { - return this->cheat_entries + i; + if (m_cheat_entries[i].definition.num_opcodes == 0) { + return m_cheat_entries + i; } } @@ -175,53 +175,53 @@ namespace ams::dmnt::cheat::impl { } void CloseActiveCheatProcess() { - if (this->cheat_process_debug_handle != os::InvalidNativeHandle) { + if (m_cheat_process_debug_handle != os::InvalidNativeHandle) { /* We don't need to do any unsafe brekaing. */ - this->broken_unsafe = false; - this->unsafe_break_event.Signal(); + m_broken_unsafe = false; + m_unsafe_break_event.Signal(); /* Knock out the debug events thread. */ - os::CancelThreadSynchronization(std::addressof(this->debug_events_thread)); + os::CancelThreadSynchronization(std::addressof(m_debug_events_thread)); /* Close resources. */ - R_ABORT_UNLESS(svc::CloseHandle(this->cheat_process_debug_handle)); - this->cheat_process_debug_handle = os::InvalidNativeHandle; + R_ABORT_UNLESS(svc::CloseHandle(m_cheat_process_debug_handle)); + m_cheat_process_debug_handle = os::InvalidNativeHandle; /* Save cheat toggles. */ - if (this->always_save_cheat_toggles || this->should_save_cheat_toggles) { - this->SaveCheatToggles(this->cheat_process_metadata.program_id); - this->should_save_cheat_toggles = false; + if (m_always_save_cheat_toggles || m_should_save_cheat_toggles) { + this->SaveCheatToggles(m_cheat_process_metadata.program_id); + m_should_save_cheat_toggles = false; } /* Clear metadata. */ - static_assert(util::is_podcheat_process_metadata)>::value, "CheatProcessMetadata definition!"); - std::memset(std::addressof(this->cheat_process_metadata), 0, sizeof(this->cheat_process_metadata)); + static_assert(util::is_pod::value, "CheatProcessMetadata definition!"); + std::memset(std::addressof(m_cheat_process_metadata), 0, sizeof(m_cheat_process_metadata)); /* Clear cheat list. */ this->ResetAllCheatEntries(); /* Clear frozen addresses. */ { - auto it = this->frozen_addresses_map.begin(); - while (it != this->frozen_addresses_map.end()) { + auto it = m_frozen_addresses_map.begin(); + while (it != m_frozen_addresses_map.end()) { FrozenAddressMapEntry *entry = std::addressof(*it); - it = this->frozen_addresses_map.erase(it); + it = m_frozen_addresses_map.erase(it); DeallocateFrozenAddress(entry); } } /* Signal to our fans. */ - this->cheat_process_event.Signal(); + m_cheat_process_event.Signal(); } } bool HasActiveCheatProcess() { /* Note: This function *MUST* be called only with the cheat lock held. */ os::ProcessId pid; - bool has_cheat_process = this->cheat_process_debug_handle != os::InvalidNativeHandle; - has_cheat_process &= R_SUCCEEDED(os::GetProcessId(std::addressof(pid), this->cheat_process_debug_handle)); + bool has_cheat_process = m_cheat_process_debug_handle != os::InvalidNativeHandle; + has_cheat_process &= R_SUCCEEDED(os::GetProcessId(std::addressof(pid), m_cheat_process_debug_handle)); has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(std::addressof(pid))); - has_cheat_process &= (pid == this->cheat_process_metadata.process_id); + has_cheat_process &= (pid == m_cheat_process_metadata.process_id); if (!has_cheat_process) { this->CloseActiveCheatProcess(); @@ -236,7 +236,7 @@ namespace ams::dmnt::cheat::impl { } os::NativeHandle GetCheatProcessHandle() const { - return this->cheat_process_debug_handle; + return m_cheat_process_debug_handle; } os::NativeHandle HookToCreateApplicationProcess() const { @@ -250,50 +250,50 @@ namespace ams::dmnt::cheat::impl { } public: - CheatProcessManager() : cheat_lock(), unsafe_break_event(os::EventClearMode_ManualClear), debug_events_event(os::EventClearMode_AutoClear), cheat_process_event(os::EventClearMode_AutoClear, true) { + CheatProcessManager() : m_cheat_lock(), m_unsafe_break_event(os::EventClearMode_ManualClear), m_debug_events_event(os::EventClearMode_AutoClear), m_cheat_process_event(os::EventClearMode_AutoClear, true) { /* Learn whether we should enable cheats by default. */ { u8 en = 0; if (settings::fwdbg::GetSettingsItemValue(std::addressof(en), sizeof(en), "atmosphere", "dmnt_cheats_enabled_by_default") == sizeof(en)) { - this->enable_cheats_by_default = (en != 0); + m_enable_cheats_by_default = (en != 0); } en = 0; if (settings::fwdbg::GetSettingsItemValue( std::addressof(en), sizeof(en), "atmosphere", "dmnt_always_save_cheat_toggles") == sizeof(en)) { - this->always_save_cheat_toggles = (en != 0); + m_always_save_cheat_toggles = (en != 0); } } /* Spawn application detection thread, spawn cheat vm thread. */ - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->detect_thread), DetectLaunchThread, this, this->detect_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDetect))); - os::SetThreadNamePointer(std::addressof(this->detect_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDetect)); - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->vm_thread), VirtualMachineThread, this, this->vm_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatVirtualMachine))); - os::SetThreadNamePointer(std::addressof(this->vm_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatVirtualMachine)); - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->debug_events_thread), DebugEventsThread, this, this->debug_events_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDebugEvents))); - os::SetThreadNamePointer(std::addressof(this->debug_events_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDebugEvents)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_detect_thread), DetectLaunchThread, this, m_detect_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDetect))); + os::SetThreadNamePointer(std::addressof(m_detect_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDetect)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_vm_thread), VirtualMachineThread, this, m_vm_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatVirtualMachine))); + os::SetThreadNamePointer(std::addressof(m_vm_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatVirtualMachine)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_debug_events_thread), DebugEventsThread, this, m_debug_events_thread_stack, ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, CheatDebugEvents))); + os::SetThreadNamePointer(std::addressof(m_debug_events_thread), AMS_GET_SYSTEM_THREAD_NAME(dmnt, CheatDebugEvents)); /* Start threads. */ - os::StartThread(std::addressof(this->detect_thread)); - os::StartThread(std::addressof(this->vm_thread)); - os::StartThread(std::addressof(this->debug_events_thread)); + os::StartThread(std::addressof(m_detect_thread)); + os::StartThread(std::addressof(m_vm_thread)); + os::StartThread(std::addressof(m_debug_events_thread)); } bool GetHasActiveCheatProcess() { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); return this->HasActiveCheatProcess(); } os::NativeHandle GetCheatProcessEventHandle() const { - return this->cheat_process_event.GetReadableHandle(); + return m_cheat_process_event.GetReadableHandle(); } Result GetCheatProcessMetadata(CheatProcessMetadata *out) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - std::memcpy(out, std::addressof(this->cheat_process_metadata), sizeof(*out)); + std::memcpy(out, std::addressof(m_cheat_process_metadata), sizeof(*out)); return ResultSuccess(); } @@ -313,7 +313,7 @@ namespace ams::dmnt::cheat::impl { Result WriteCheatProcessMemoryUnsafe(u64 proc_addr, const void *data, size_t size) { R_TRY(svc::WriteDebugProcessMemory(this->GetCheatProcessHandle(), reinterpret_cast(data), proc_addr, size)); - for (auto &entry : this->frozen_addresses_map) { + for (auto &entry : m_frozen_addresses_map) { /* Get address/value. */ const u64 address = entry.GetAddress(); auto &value = entry.GetValue(); @@ -335,20 +335,20 @@ namespace ams::dmnt::cheat::impl { } Result PauseCheatProcessUnsafe() { - this->broken_unsafe = true; - this->unsafe_break_event.Clear(); + m_broken_unsafe = true; + m_unsafe_break_event.Clear(); return svc::BreakDebugProcess(this->GetCheatProcessHandle()); } Result ResumeCheatProcessUnsafe() { - this->broken_unsafe = false; - this->unsafe_break_event.Signal(); + m_broken_unsafe = false; + m_unsafe_break_event.Signal(); dmnt::cheat::impl::ContinueCheatProcess(this->GetCheatProcessHandle()); return ResultSuccess(); } Result GetCheatProcessMappingCount(u64 *out_count) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -372,7 +372,7 @@ namespace ams::dmnt::cheat::impl { } Result GetCheatProcessMappings(svc::MemoryInfo *mappings, size_t max_count, u64 *out_count, u64 offset) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -399,7 +399,7 @@ namespace ams::dmnt::cheat::impl { } Result ReadCheatProcessMemory(u64 proc_addr, void *out_data, size_t size) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -407,7 +407,7 @@ namespace ams::dmnt::cheat::impl { } Result WriteCheatProcessMemory(u64 proc_addr, const void *data, size_t size) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -415,7 +415,7 @@ namespace ams::dmnt::cheat::impl { } Result QueryCheatProcessMemory(svc::MemoryInfo *mapping, u64 address) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -424,7 +424,7 @@ namespace ams::dmnt::cheat::impl { } Result PauseCheatProcess() { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -432,7 +432,7 @@ namespace ams::dmnt::cheat::impl { } Result ResumeCheatProcess() { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -440,13 +440,13 @@ namespace ams::dmnt::cheat::impl { } Result GetCheatCount(u64 *out_count) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); size_t count = 0; for (size_t i = 0; i < MaxCheatCount; i++) { - if (this->cheat_entries[i].definition.num_opcodes) { + if (m_cheat_entries[i].definition.num_opcodes) { count++; } } @@ -456,16 +456,16 @@ namespace ams::dmnt::cheat::impl { } Result GetCheats(CheatEntry *out_cheats, size_t max_count, u64 *out_count, u64 offset) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); size_t count = 0, total_count = 0; for (size_t i = 0; i < MaxCheatCount && count < max_count; i++) { - if (this->cheat_entries[i].definition.num_opcodes) { + if (m_cheat_entries[i].definition.num_opcodes) { total_count++; if (total_count > offset) { - out_cheats[count++] = this->cheat_entries[i]; + out_cheats[count++] = m_cheat_entries[i]; } } } @@ -475,7 +475,7 @@ namespace ams::dmnt::cheat::impl { } Result GetCheatById(CheatEntry *out_cheat, u32 cheat_id) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -488,7 +488,7 @@ namespace ams::dmnt::cheat::impl { } Result ToggleCheat(u32 cheat_id) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -507,7 +507,7 @@ namespace ams::dmnt::cheat::impl { } Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); @@ -530,7 +530,7 @@ namespace ams::dmnt::cheat::impl { } Result RemoveCheat(u32 cheat_id) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); R_UNLESS(cheat_id < MaxCheatCount, dmnt::cheat::ResultCheatUnknownId()); @@ -544,14 +544,14 @@ namespace ams::dmnt::cheat::impl { } Result SetMasterCheat(const CheatDefinition &def) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); R_UNLESS(def.num_opcodes != 0, dmnt::cheat::ResultCheatInvalid()); R_UNLESS(def.num_opcodes <= util::size(def.opcodes), dmnt::cheat::ResultCheatInvalid()); - CheatEntry *master_entry = this->cheat_entries + 0; + CheatEntry *master_entry = m_cheat_entries + 0; master_entry->enabled = true; master_entry->definition = def; @@ -563,50 +563,50 @@ namespace ams::dmnt::cheat::impl { } Result ReadStaticRegister(u64 *out, size_t which) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, dmnt::cheat::ResultCheatInvalid()); - *out = this->cheat_vm.GetStaticRegister(which); + *out = m_cheat_vm.GetStaticRegister(which); return ResultSuccess(); } Result WriteStaticRegister(size_t which, u64 value) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, dmnt::cheat::ResultCheatInvalid()); - this->cheat_vm.SetStaticRegister(which, value); + m_cheat_vm.SetStaticRegister(which, value); return ResultSuccess(); } Result ResetStaticRegisters() { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - this->cheat_vm.ResetStaticRegisters(); + m_cheat_vm.ResetStaticRegisters(); return ResultSuccess(); } Result GetFrozenAddressCount(u64 *out_count) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - *out_count = std::distance(this->frozen_addresses_map.begin(), this->frozen_addresses_map.end()); + *out_count = std::distance(m_frozen_addresses_map.begin(), m_frozen_addresses_map.end()); return ResultSuccess(); } Result GetFrozenAddresses(FrozenAddressEntry *frz_addrs, size_t max_count, u64 *out_count, u64 offset) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); u64 total_count = 0, written_count = 0; - for (const auto &entry : this->frozen_addresses_map) { + for (const auto &entry : m_frozen_addresses_map) { if (written_count >= max_count) { break; } @@ -624,12 +624,12 @@ namespace ams::dmnt::cheat::impl { } Result GetFrozenAddress(FrozenAddressEntry *frz_addr, u64 address) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_key(address); - R_UNLESS(it != this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound()); + const auto it = m_frozen_addresses_map.find_key(address); + R_UNLESS(it != m_frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound()); frz_addr->address = it->GetAddress(); frz_addr->value = it->GetValue(); @@ -637,12 +637,12 @@ namespace ams::dmnt::cheat::impl { } Result EnableFrozenAddress(u64 *out_value, u64 address, u64 width) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_key(address); - R_UNLESS(it == this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressAlreadyExists()); + const auto it = m_frozen_addresses_map.find_key(address); + R_UNLESS(it == m_frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressAlreadyExists()); FrozenAddressValue value = {}; value.width = width; @@ -651,21 +651,21 @@ namespace ams::dmnt::cheat::impl { FrozenAddressMapEntry *entry = AllocateFrozenAddress(address, value); R_UNLESS(entry != nullptr, dmnt::cheat::ResultFrozenAddressOutOfResource()); - this->frozen_addresses_map.insert(*entry); + m_frozen_addresses_map.insert(*entry); *out_value = value.value; return ResultSuccess(); } Result DisableFrozenAddress(u64 address) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); R_TRY(this->EnsureCheatProcess()); - const auto it = this->frozen_addresses_map.find_key(address); - R_UNLESS(it != this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound()); + const auto it = m_frozen_addresses_map.find_key(address); + R_UNLESS(it != m_frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound()); FrozenAddressMapEntry *entry = std::addressof(*it); - this->frozen_addresses_map.erase(it); + m_frozen_addresses_map.erase(it); DeallocateFrozenAddress(entry); return ResultSuccess(); @@ -674,37 +674,37 @@ namespace ams::dmnt::cheat::impl { }; void CheatProcessManager::DetectLaunchThread(void *_this) { - CheatProcessManager *this_ptr = reinterpret_cast(_this); + CheatProcessManager *manager = reinterpret_cast(_this); Event hook; while (true) { - eventLoadRemote(std::addressof(hook), this_ptr->HookToCreateApplicationProcess(), true); + eventLoadRemote(std::addressof(hook), manager->HookToCreateApplicationProcess(), true); if (R_SUCCEEDED(eventWait(std::addressof(hook), std::numeric_limits::max()))) { - this_ptr->AttachToApplicationProcess(true); + manager->AttachToApplicationProcess(true); } eventClose(std::addressof(hook)); } } void CheatProcessManager::DebugEventsThread(void *_this) { - CheatProcessManager *this_ptr = reinterpret_cast(_this); + CheatProcessManager *manager = reinterpret_cast(_this); while (true) { /* Atomically wait (and clear) signal for new process. */ - this_ptr->debug_events_event.Wait(); + manager->m_debug_events_event.Wait(); while (true) { - os::NativeHandle cheat_process_handle = this_ptr->GetCheatProcessHandle(); + os::NativeHandle cheat_process_handle = manager->GetCheatProcessHandle(); s32 dummy; while (cheat_process_handle != os::InvalidNativeHandle && R_SUCCEEDED(svc::WaitSynchronization(std::addressof(dummy), std::addressof(cheat_process_handle), 1, std::numeric_limits::max()))) { - this_ptr->cheat_lock.Lock(); - ON_SCOPE_EXIT { this_ptr->cheat_lock.Unlock(); }; + manager->m_cheat_lock.Lock(); + ON_SCOPE_EXIT { manager->m_cheat_lock.Unlock(); }; { - ON_SCOPE_EXIT { cheat_process_handle = this_ptr->GetCheatProcessHandle(); }; + ON_SCOPE_EXIT { cheat_process_handle = manager->GetCheatProcessHandle(); }; /* If we did an unsafe break, wait until we're not broken. */ - if (this_ptr->broken_unsafe) { - this_ptr->cheat_lock.Unlock(); - this_ptr->unsafe_break_event.Wait(); - this_ptr->cheat_lock.Lock(); - if (this_ptr->GetCheatProcessHandle() != os::InvalidNativeHandle) { + if (manager->m_broken_unsafe) { + manager->m_cheat_lock.Unlock(); + manager->m_unsafe_break_event.Wait(); + manager->m_cheat_lock.Lock(); + if (manager->GetCheatProcessHandle() != os::InvalidNativeHandle) { continue; } else { break; @@ -712,10 +712,10 @@ namespace ams::dmnt::cheat::impl { } /* Handle any pending debug events. */ - if (this_ptr->HasActiveCheatProcess()) { - R_TRY_CATCH(dmnt::cheat::impl::ContinueCheatProcess(this_ptr->GetCheatProcessHandle())) { + if (manager->HasActiveCheatProcess()) { + R_TRY_CATCH(dmnt::cheat::impl::ContinueCheatProcess(manager->GetCheatProcessHandle())) { R_CATCH(svc::ResultProcessTerminated) { - this_ptr->CloseActiveCheatProcess(); + manager->CloseActiveCheatProcess(); break; } } R_END_TRY_CATCH_WITH_ABORT_UNLESS; @@ -725,8 +725,8 @@ namespace ams::dmnt::cheat::impl { /* WaitSynchronization failed. This means someone canceled our synchronization, possibly us. */ /* Let's check if we should quit! */ - std::scoped_lock lk(this_ptr->cheat_lock); - if (!this_ptr->HasActiveCheatProcess()) { + std::scoped_lock lk(manager->m_cheat_lock); + if (!manager->HasActiveCheatProcess()) { break; } } @@ -734,30 +734,30 @@ namespace ams::dmnt::cheat::impl { } void CheatProcessManager::VirtualMachineThread(void *_this) { - CheatProcessManager *this_ptr = reinterpret_cast(_this); + CheatProcessManager *manager = reinterpret_cast(_this); while (true) { /* Apply cheats. */ { - std::scoped_lock lk(this_ptr->cheat_lock); + std::scoped_lock lk(manager->m_cheat_lock); - if (this_ptr->HasActiveCheatProcess()) { + if (manager->HasActiveCheatProcess()) { /* Execute VM. */ - if (!this_ptr->GetNeedsReloadVm() || this_ptr->cheat_vm.LoadProgram(this_ptr->cheat_entries, util::size(this_ptr->cheat_entries))) { - this_ptr->SetNeedsReloadVm(false); + if (!manager->GetNeedsReloadVm() || manager->m_cheat_vm.LoadProgram(manager->m_cheat_entries, util::size(manager->m_cheat_entries))) { + manager->SetNeedsReloadVm(false); /* Execute program only if it has opcodes. */ - if (this_ptr->cheat_vm.GetProgramSize()) { - this_ptr->cheat_vm.Execute(std::addressof(this_ptr->cheat_process_metadata)); + if (manager->m_cheat_vm.GetProgramSize()) { + manager->m_cheat_vm.Execute(std::addressof(manager->m_cheat_process_metadata)); } } /* Apply frozen addresses. */ - for (const auto &entry : this_ptr->frozen_addresses_map) { + for (const auto &entry : manager->m_frozen_addresses_map) { const auto address = entry.GetAddress(); const auto &value = entry.GetValue(); /* Use Write SVC directly, to avoid the usual frozen address update logic. */ - svc::WriteDebugProcessMemory(this_ptr->GetCheatProcessHandle(), reinterpret_cast(std::addressof(value.value)), address, value.width); + svc::WriteDebugProcessMemory(manager->GetCheatProcessHandle(), reinterpret_cast(std::addressof(value.value)), address, value.width); } } } @@ -778,7 +778,7 @@ namespace ams::dmnt::cheat::impl { } Result CheatProcessManager::AttachToApplicationProcess(bool on_process_launch) { - std::scoped_lock lk(this->cheat_lock); + std::scoped_lock lk(m_cheat_lock); /* Close the active process, if needed. */ { @@ -792,12 +792,12 @@ namespace ams::dmnt::cheat::impl { } /* Get the application process's ID. */ - R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(std::addressof(this->cheat_process_metadata.process_id))); + R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(std::addressof(m_cheat_process_metadata.process_id))); auto proc_guard = SCOPE_GUARD { if (on_process_launch) { - this->StartProcess(this->cheat_process_metadata.process_id); + this->StartProcess(m_cheat_process_metadata.process_id); } - this->cheat_process_metadata.process_id = os::ProcessId{}; + m_cheat_process_metadata.process_id = os::ProcessId{}; }; /* Get process handle, use it to learn memory extents. */ @@ -806,17 +806,17 @@ namespace ams::dmnt::cheat::impl { ncm::ProgramLocation loc = {}; cfg::OverrideStatus status = {}; - R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(std::addressof(proc_h), std::addressof(loc), std::addressof(status), this->cheat_process_metadata.process_id)); + R_ABORT_UNLESS_IF_NEW_PROCESS(pm::dmnt::AtmosphereGetProcessInfo(std::addressof(proc_h), std::addressof(loc), std::addressof(status), m_cheat_process_metadata.process_id)); ON_SCOPE_EXIT { os::CloseNativeHandle(proc_h); }; - this->cheat_process_metadata.program_id = loc.program_id; + m_cheat_process_metadata.program_id = loc.program_id; - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.heap_extents.base), svc::InfoType_HeapRegionAddress, proc_h, 0)); - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.heap_extents.size), svc::InfoType_HeapRegionSize, proc_h, 0)); - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.alias_extents.base), svc::InfoType_AliasRegionAddress, proc_h, 0)); - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.alias_extents.size), svc::InfoType_AliasRegionSize, proc_h, 0)); - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.aslr_extents.base), svc::InfoType_AslrRegionAddress, proc_h, 0)); - R_ABORT_UNLESS(svc::GetInfo(std::addressof(this->cheat_process_metadata.aslr_extents.size), svc::InfoType_AslrRegionSize, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.heap_extents.base), svc::InfoType_HeapRegionAddress, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.heap_extents.size), svc::InfoType_HeapRegionSize, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.alias_extents.base), svc::InfoType_AliasRegionAddress, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.alias_extents.size), svc::InfoType_AliasRegionSize, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.aslr_extents.base), svc::InfoType_AslrRegionAddress, proc_h, 0)); + R_ABORT_UNLESS(svc::GetInfo(std::addressof(m_cheat_process_metadata.aslr_extents.size), svc::InfoType_AslrRegionSize, proc_h, 0)); /* If new process launch, we may not want to actually attach. */ if (on_process_launch) { @@ -830,7 +830,7 @@ namespace ams::dmnt::cheat::impl { s32 num_modules; /* TODO: ldr::dmnt:: */ - R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), std::addressof(num_modules))); + R_ABORT_UNLESS_IF_NEW_PROCESS(ldrDmntGetProcessModuleInfo(static_cast(m_cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), std::addressof(num_modules))); /* All applications must have two modules. */ /* Only accept one (which means we're attaching to HBL) */ @@ -844,42 +844,42 @@ namespace ams::dmnt::cheat::impl { return dmnt::cheat::ResultCheatNotAttached(); } - this->cheat_process_metadata.main_nso_extents.base = proc_module->base_address; - this->cheat_process_metadata.main_nso_extents.size = proc_module->size; - std::memcpy(this->cheat_process_metadata.main_nso_build_id, proc_module->build_id, sizeof(this->cheat_process_metadata.main_nso_build_id)); + m_cheat_process_metadata.main_nso_extents.base = proc_module->base_address; + m_cheat_process_metadata.main_nso_extents.size = proc_module->size; + std::memcpy(m_cheat_process_metadata.main_nso_build_id, proc_module->build_id, sizeof(m_cheat_process_metadata.main_nso_build_id)); } /* Read cheats off the SD. */ - if (!this->LoadCheats(this->cheat_process_metadata.program_id, this->cheat_process_metadata.main_nso_build_id) || - !this->LoadCheatToggles(this->cheat_process_metadata.program_id)) { + if (!this->LoadCheats(m_cheat_process_metadata.program_id, m_cheat_process_metadata.main_nso_build_id) || + !this->LoadCheatToggles(m_cheat_process_metadata.program_id)) { /* If new process launch, require success. */ R_UNLESS(!on_process_launch, dmnt::cheat::ResultCheatNotAttached()); } /* Open a debug handle. */ svc::Handle debug_handle = svc::InvalidHandle; - R_ABORT_UNLESS_IF_NEW_PROCESS(svc::DebugActiveProcess(std::addressof(debug_handle), this->cheat_process_metadata.process_id.value)); + R_ABORT_UNLESS_IF_NEW_PROCESS(svc::DebugActiveProcess(std::addressof(debug_handle), m_cheat_process_metadata.process_id.value)); /* Set our debug handle. */ - this->cheat_process_debug_handle = debug_handle; + m_cheat_process_debug_handle = debug_handle; /* Cancel process guard. */ proc_guard.Cancel(); /* Reset broken state. */ - this->broken_unsafe = false; - this->unsafe_break_event.Signal(); + m_broken_unsafe = false; + m_unsafe_break_event.Signal(); /* If new process, start the process. */ if (on_process_launch) { - this->StartProcess(this->cheat_process_metadata.process_id); + this->StartProcess(m_cheat_process_metadata.process_id); } /* Signal to the debug events thread. */ - this->debug_events_event.Signal(); + m_debug_events_event.Signal(); /* Signal to our fans. */ - this->cheat_process_event.Signal(); + m_cheat_process_event.Signal(); return ResultSuccess(); } @@ -922,7 +922,7 @@ namespace ams::dmnt::cheat::impl { i = j + 1; } else if (s[i] == '{') { /* We're parsing a master cheat. */ - cur_entry = std::addressof(this->cheat_entries[0]); + cur_entry = std::addressof(m_cheat_entries[0]); /* There can only be one master cheat. */ if (cur_entry->definition.num_opcodes > 0) { @@ -978,14 +978,14 @@ namespace ams::dmnt::cheat::impl { } /* Master cheat can't be disabled. */ - if (this->cheat_entries[0].definition.num_opcodes > 0) { - this->cheat_entries[0].enabled = true; + if (m_cheat_entries[0].definition.num_opcodes > 0) { + m_cheat_entries[0].enabled = true; } /* Enable all entries we parsed. */ for (size_t i = 1; i < MaxCheatCount; i++) { - if (this->cheat_entries[i].definition.num_opcodes > 0) { - this->cheat_entries[i].enabled = this->enable_cheats_by_default; + if (m_cheat_entries[i].definition.num_opcodes > 0) { + m_cheat_entries[i].enabled = m_enable_cheats_by_default; } } @@ -1098,7 +1098,7 @@ namespace ams::dmnt::cheat::impl { bool CheatProcessManager::LoadCheatToggles(const ncm::ProgramId program_id) { /* Unless we successfully parse, don't save toggles on close. */ - this->should_save_cheat_toggles = false; + m_should_save_cheat_toggles = false; /* Open the file for program_id. */ fs::FileHandle file; @@ -1130,8 +1130,8 @@ namespace ams::dmnt::cheat::impl { g_text_file_buffer[file_size] = '\x00'; /* Parse toggle buffer. */ - this->should_save_cheat_toggles = this->ParseCheatToggles(g_text_file_buffer, std::strlen(g_text_file_buffer)); - return this->should_save_cheat_toggles; + m_should_save_cheat_toggles = this->ParseCheatToggles(g_text_file_buffer, std::strlen(g_text_file_buffer)); + return m_should_save_cheat_toggles; } void CheatProcessManager::SaveCheatToggles(const ncm::ProgramId program_id) { @@ -1153,14 +1153,14 @@ namespace ams::dmnt::cheat::impl { /* Save all non-master cheats. */ for (size_t i = 1; i < MaxCheatCount; i++) { - if (this->cheat_entries[i].definition.num_opcodes != 0) { - util::SNPrintf(buf, sizeof(buf), "[%s]\n", this->cheat_entries[i].definition.readable_name); + if (m_cheat_entries[i].definition.num_opcodes != 0) { + util::SNPrintf(buf, sizeof(buf), "[%s]\n", m_cheat_entries[i].definition.readable_name); const size_t name_len = std::strlen(buf); if (R_SUCCEEDED(fs::WriteFile(file, offset, buf, name_len, fs::WriteOption::Flush))) { offset += name_len; } - const char *entry = this->cheat_entries[i].enabled ? "true\n" : "false\n"; + const char *entry = m_cheat_entries[i].enabled ? "true\n" : "false\n"; const size_t entry_len = std::strlen(entry); if (R_SUCCEEDED(fs::WriteFile(file, offset, entry, entry_len, fs::WriteOption::Flush))) { offset += entry_len; diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp index 0493fcb1e..cca48aa29 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_debug_events_manager.cpp @@ -27,13 +27,13 @@ namespace ams::dmnt::cheat::impl { static constexpr size_t NumCores = 4; static constexpr size_t ThreadStackSize = os::MemoryPageSize; private: - std::array handle_message_queue_buffers; - std::array result_message_queue_buffers; - std::array handle_message_queues; - std::array result_message_queues; - std::array threads; + std::array m_handle_message_queue_buffers; + std::array m_result_message_queue_buffers; + std::array m_handle_message_queues; + std::array m_result_message_queues; + std::array m_threads; - alignas(os::MemoryPageSize) u8 thread_stacks[NumCores][ThreadStackSize]; + alignas(os::MemoryPageSize) u8 m_thread_stacks[NumCores][ThreadStackSize]; private: static void PerCoreThreadFunction(void *_this) { /* This thread will wait on the appropriate message queue. */ @@ -73,12 +73,12 @@ namespace ams::dmnt::cheat::impl { } void SendHandle(size_t target_core, os::NativeHandle debug_handle) { - this->handle_message_queues[target_core].Send(static_cast(debug_handle)); + m_handle_message_queues[target_core].Send(static_cast(debug_handle)); } os::NativeHandle WaitReceiveHandle(size_t core_id) { uintptr_t x = 0; - this->handle_message_queues[core_id].Receive(&x); + m_handle_message_queues[core_id].Receive(&x); return static_cast(x); } @@ -91,38 +91,38 @@ namespace ams::dmnt::cheat::impl { } void SendContinueResult(size_t target_core, Result result) { - this->result_message_queues[target_core].Send(static_cast(result.GetValue())); + m_result_message_queues[target_core].Send(static_cast(result.GetValue())); } Result GetContinueResult(size_t core_id) { uintptr_t x = 0; - this->result_message_queues[core_id].Receive(&x); + m_result_message_queues[core_id].Receive(&x); return static_cast(x); } public: DebugEventsManager() - : handle_message_queues{ - os::MessageQueue(std::addressof(handle_message_queue_buffers[0]), 1), - os::MessageQueue(std::addressof(handle_message_queue_buffers[1]), 1), - os::MessageQueue(std::addressof(handle_message_queue_buffers[2]), 1), - os::MessageQueue(std::addressof(handle_message_queue_buffers[3]), 1)}, - result_message_queues{ - os::MessageQueue(std::addressof(result_message_queue_buffers[0]), 1), - os::MessageQueue(std::addressof(result_message_queue_buffers[1]), 1), - os::MessageQueue(std::addressof(result_message_queue_buffers[2]), 1), - os::MessageQueue(std::addressof(result_message_queue_buffers[3]), 1)}, - thread_stacks{} + : m_handle_message_queues{ + os::MessageQueue(std::addressof(m_handle_message_queue_buffers[0]), 1), + os::MessageQueue(std::addressof(m_handle_message_queue_buffers[1]), 1), + os::MessageQueue(std::addressof(m_handle_message_queue_buffers[2]), 1), + os::MessageQueue(std::addressof(m_handle_message_queue_buffers[3]), 1)}, + m_result_message_queues{ + os::MessageQueue(std::addressof(m_result_message_queue_buffers[0]), 1), + os::MessageQueue(std::addressof(m_result_message_queue_buffers[1]), 1), + os::MessageQueue(std::addressof(m_result_message_queue_buffers[2]), 1), + os::MessageQueue(std::addressof(m_result_message_queue_buffers[3]), 1)}, + m_thread_stacks{} { for (size_t i = 0; i < NumCores; i++) { /* Create thread. */ - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->threads[i]), PerCoreThreadFunction, this, this->thread_stacks[i], ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, MultiCoreEventManager), i)); - os::SetThreadNamePointer(std::addressof(this->threads[i]), AMS_GET_SYSTEM_THREAD_NAME(dmnt, MultiCoreEventManager)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_threads[i]), PerCoreThreadFunction, this, m_thread_stacks[i], ThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(dmnt, MultiCoreEventManager), i)); + os::SetThreadNamePointer(std::addressof(m_threads[i]), AMS_GET_SYSTEM_THREAD_NAME(dmnt, MultiCoreEventManager)); /* Set core mask. */ - os::SetThreadCoreMask(std::addressof(this->threads[i]), i, (1u << i)); + os::SetThreadCoreMask(std::addressof(m_threads[i]), i, (1u << i)); /* Start thread. */ - os::StartThread(std::addressof(this->threads[i])); + os::StartThread(std::addressof(m_threads[i])); } } diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp index 68bf7ea42..eeac104d6 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.cpp @@ -46,41 +46,41 @@ namespace ams::dmnt::cheat::impl { void CheatVirtualMachine::OpenDebugLogFile() { #ifdef DMNT_CHEAT_VM_DEBUG_LOG CloseDebugLogFile(); - R_ABORT_UNLESS(fs::OpenFile(std::addressof(this->debug_log_file), "sdmc:/atmosphere/cheat_vm_logs/debug_log.txt")); - this->debug_log_file_offset = 0; + R_ABORT_UNLESS(fs::OpenFile(std::addressof(m_debug_log_file), "sdmc:/atmosphere/cheat_vm_logs/debug_log.txt")); + m_debug_log_file_offset = 0; #endif } void CheatVirtualMachine::CloseDebugLogFile() { #ifdef DMNT_CHEAT_VM_DEBUG_LOG - if (this->has_debug_log_file) { - fs::CloseFile(this->debug_log_file); + if (m_has_debug_log_file) { + fs::CloseFile(m_debug_log_file); } - this->has_debug_log_file = false; + m_has_debug_log_file = false; #endif } void CheatVirtualMachine::LogToDebugFile(const char *format, ...) { #ifdef DMNT_CHEAT_VM_DEBUG_LOG - if (!this->has_debug_log_file) { + if (!m_has_debug_log_file) { return; } { std::va_list vl; va_start(vl, format); - util::VSNPrintf(this->debug_log_format_buf, sizeof(this->debug_log_format_buf) - 1, format, vl); + util::VSNPrintf(m_debug_log_format_buf, sizeof(m_debug_log_format_buf) - 1, format, vl); va_end(vl); } - size_t fmt_len = std::strlen(this->debug_log_format_buf); - if (this->debug_log_format_buf[fmt_len - 1] != '\n') { - this->debug_log_format_buf[fmt_len + 0] = '\n'; - this->debug_log_format_buf[fmt_len + 1] = '\x00'; + size_t fmt_len = std::strlen(m_debug_log_format_buf); + if (m_debug_log_format_buf[fmt_len - 1] != '\n') { + m_debug_log_format_buf[fmt_len + 0] = '\n'; + m_debug_log_format_buf[fmt_len + 1] = '\x00'; fmt_len += 1; } - fs::WriteFile(this->debug_log_file, this->debug_log_offset, this->debug_log_format_buf, fmt_len, fs::WriteOption::Flush); + fs::WriteFile(m_debug_log_file, m_debug_log_offset, m_debug_log_format_buf, fmt_len, fs::WriteOption::Flush); #else AMS_UNUSED(format); #endif @@ -295,10 +295,10 @@ namespace ams::dmnt::cheat::impl { bool CheatVirtualMachine::DecodeNextOpcode(CheatVmOpcode *out) { /* If we've ever seen a decode failure, return false. */ - bool valid = this->decode_success; + bool valid = m_decode_success; CheatVmOpcode opcode = {}; ON_SCOPE_EXIT { - this->decode_success &= valid; + m_decode_success &= valid; if (valid) { *out = opcode; } @@ -306,11 +306,11 @@ namespace ams::dmnt::cheat::impl { /* Helper function for getting instruction dwords. */ auto GetNextDword = [&]() { - if (this->instruction_ptr >= this->num_opcodes) { + if (m_instruction_ptr >= m_num_opcodes) { valid = false; return static_cast(0); } - return this->program[this->instruction_ptr++]; + return m_program[m_instruction_ptr++]; }; /* Helper function for parsing a VmInt. */ @@ -671,12 +671,12 @@ namespace ams::dmnt::cheat::impl { } void CheatVirtualMachine::SkipConditionalBlock(bool is_if) { - if (this->condition_depth > 0) { + if (m_condition_depth > 0) { /* We want to continue until we're out of the current block. */ - const size_t desired_depth = this->condition_depth - 1; + const size_t desired_depth = m_condition_depth - 1; CheatVmOpcode skip_opcode; - while (this->condition_depth > desired_depth && this->DecodeNextOpcode(std::addressof(skip_opcode))) { + while (m_condition_depth > desired_depth && this->DecodeNextOpcode(std::addressof(skip_opcode))) { /* Decode instructions until we see end of the current conditional block. */ /* NOTE: This is broken in gateway's implementation. */ /* Gateway currently checks for "0x2" instead of "0x20000000" */ @@ -685,18 +685,18 @@ namespace ams::dmnt::cheat::impl { /* We also support nesting of conditional blocks, and Gateway does not. */ if (skip_opcode.begin_conditional_block) { - this->condition_depth++; + m_condition_depth++; } else if (skip_opcode.opcode == CheatVmOpcodeType_EndConditionalBlock) { if (!skip_opcode.end_cond.is_else) { - this->condition_depth--; - } else if (is_if && this->condition_depth - 1 == desired_depth) { + m_condition_depth--; + } else if (is_if && m_condition_depth - 1 == desired_depth) { /* An if will continue to an else at the same depth. */ break; } } } } else { - /* Skipping, but this->condition_depth = 0. */ + /* Skipping, but m_condition_depth = 0. */ /* This is an error condition. */ /* This could occur with a mismatched "else" opcode, for example. */ R_ABORT_UNLESS(ResultVirtualMachineInvalidConditionDepth()); @@ -735,29 +735,29 @@ namespace ams::dmnt::cheat::impl { void CheatVirtualMachine::ResetState() { for (size_t i = 0; i < CheatVirtualMachine::NumRegisters; i++) { - this->registers[i] = 0; - this->saved_values[i] = 0; - this->loop_tops[i] = 0; + m_registers[i] = 0; + m_saved_values[i] = 0; + m_loop_tops[i] = 0; } - this->instruction_ptr = 0; - this->condition_depth = 0; - this->decode_success = true; + m_instruction_ptr = 0; + m_condition_depth = 0; + m_decode_success = true; } bool CheatVirtualMachine::LoadProgram(const CheatEntry *cheats, size_t num_cheats) { /* Reset opcode count. */ - this->num_opcodes = 0; + m_num_opcodes = 0; for (size_t i = 0; i < num_cheats; i++) { if (cheats[i].enabled) { /* Bounds check. */ - if (cheats[i].definition.num_opcodes + this->num_opcodes > MaximumProgramOpcodeCount) { - this->num_opcodes = 0; + if (cheats[i].definition.num_opcodes + m_num_opcodes > MaximumProgramOpcodeCount) { + m_num_opcodes = 0; return false; } for (size_t n = 0; n < cheats[i].definition.num_opcodes; n++) { - this->program[this->num_opcodes++] = cheats[i].definition.opcodes[n]; + m_program[m_num_opcodes++] = cheats[i].definition.opcodes[n]; } } } @@ -785,27 +785,27 @@ namespace ams::dmnt::cheat::impl { /* Loop until program finishes. */ while (this->DecodeNextOpcode(std::addressof(cur_opcode))) { - this->LogToDebugFile("Instruction Ptr: %04x\n", (u32)this->instruction_ptr); + this->LogToDebugFile("Instruction Ptr: %04x\n", (u32)m_instruction_ptr); for (size_t i = 0; i < NumRegisters; i++) { - this->LogToDebugFile("Registers[%02x]: %016lx\n", i, this->registers[i]); + this->LogToDebugFile("Registers[%02x]: %016lx\n", i, m_registers[i]); } for (size_t i = 0; i < NumRegisters; i++) { - this->LogToDebugFile("SavedRegs[%02x]: %016lx\n", i, this->saved_values[i]); + this->LogToDebugFile("SavedRegs[%02x]: %016lx\n", i, m_saved_values[i]); } this->LogOpcode(std::addressof(cur_opcode)); /* Increment conditional depth, if relevant. */ if (cur_opcode.begin_conditional_block) { - this->condition_depth++; + m_condition_depth++; } switch (cur_opcode.opcode) { case CheatVmOpcodeType_StoreStatic: { /* Calculate address, write value to memory. */ - u64 dst_address = GetCheatProcessAddress(metadata, cur_opcode.store_static.mem_type, cur_opcode.store_static.rel_address + this->registers[cur_opcode.store_static.offset_register]); + u64 dst_address = GetCheatProcessAddress(metadata, cur_opcode.store_static.mem_type, cur_opcode.store_static.rel_address + m_registers[cur_opcode.store_static.offset_register]); u64 dst_value = GetVmInt(cur_opcode.store_static.value, cur_opcode.store_static.bit_width); switch (cur_opcode.store_static.bit_width) { case 1: @@ -866,34 +866,34 @@ namespace ams::dmnt::cheat::impl { } else { /* Decrement the condition depth. */ /* We will assume, graciously, that mismatched conditional block ends are a nop. */ - if (this->condition_depth > 0) { - this->condition_depth--; + if (m_condition_depth > 0) { + m_condition_depth--; } } break; case CheatVmOpcodeType_ControlLoop: if (cur_opcode.ctrl_loop.start_loop) { /* Start a loop. */ - this->registers[cur_opcode.ctrl_loop.reg_index] = cur_opcode.ctrl_loop.num_iters; - this->loop_tops[cur_opcode.ctrl_loop.reg_index] = this->instruction_ptr; + m_registers[cur_opcode.ctrl_loop.reg_index] = cur_opcode.ctrl_loop.num_iters; + m_loop_tops[cur_opcode.ctrl_loop.reg_index] = m_instruction_ptr; } else { /* End a loop. */ - this->registers[cur_opcode.ctrl_loop.reg_index]--; - if (this->registers[cur_opcode.ctrl_loop.reg_index] != 0) { - this->instruction_ptr = this->loop_tops[cur_opcode.ctrl_loop.reg_index]; + m_registers[cur_opcode.ctrl_loop.reg_index]--; + if (m_registers[cur_opcode.ctrl_loop.reg_index] != 0) { + m_instruction_ptr = m_loop_tops[cur_opcode.ctrl_loop.reg_index]; } } break; case CheatVmOpcodeType_LoadRegisterStatic: /* Set a register to a static value. */ - this->registers[cur_opcode.ldr_static.reg_index] = cur_opcode.ldr_static.value; + m_registers[cur_opcode.ldr_static.reg_index] = cur_opcode.ldr_static.value; break; case CheatVmOpcodeType_LoadRegisterMemory: { /* Choose source address. */ u64 src_address; if (cur_opcode.ldr_memory.load_from_reg) { - src_address = this->registers[cur_opcode.ldr_memory.reg_index] + cur_opcode.ldr_memory.rel_address; + src_address = m_registers[cur_opcode.ldr_memory.reg_index] + cur_opcode.ldr_memory.rel_address; } else { src_address = GetCheatProcessAddress(metadata, cur_opcode.ldr_memory.mem_type, cur_opcode.ldr_memory.rel_address); } @@ -903,7 +903,7 @@ namespace ams::dmnt::cheat::impl { case 2: case 4: case 8: - dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(this->registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width); + dmnt::cheat::impl::ReadCheatProcessMemoryUnsafe(src_address, std::addressof(m_registers[cur_opcode.ldr_memory.reg_index]), cur_opcode.ldr_memory.bit_width); break; } } @@ -911,10 +911,10 @@ namespace ams::dmnt::cheat::impl { case CheatVmOpcodeType_StoreStaticToAddress: { /* Calculate address. */ - u64 dst_address = this->registers[cur_opcode.str_static.reg_index]; + u64 dst_address = m_registers[cur_opcode.str_static.reg_index]; u64 dst_value = cur_opcode.str_static.value; if (cur_opcode.str_static.add_offset_reg) { - dst_address += this->registers[cur_opcode.str_static.offset_reg_index]; + dst_address += m_registers[cur_opcode.str_static.offset_reg_index]; } /* Write value to memory. Gateway only writes on valid bitwidth. */ switch (cur_opcode.str_static.bit_width) { @@ -927,7 +927,7 @@ namespace ams::dmnt::cheat::impl { } /* Increment register if relevant. */ if (cur_opcode.str_static.increment_reg) { - this->registers[cur_opcode.str_static.reg_index] += cur_opcode.str_static.bit_width; + m_registers[cur_opcode.str_static.reg_index] += cur_opcode.str_static.bit_width; } } break; @@ -936,19 +936,19 @@ namespace ams::dmnt::cheat::impl { /* Do requested math. */ switch (cur_opcode.perform_math_static.math_type) { case RegisterArithmeticType_Addition: - this->registers[cur_opcode.perform_math_static.reg_index] += (u64)cur_opcode.perform_math_static.value; + m_registers[cur_opcode.perform_math_static.reg_index] += (u64)cur_opcode.perform_math_static.value; break; case RegisterArithmeticType_Subtraction: - this->registers[cur_opcode.perform_math_static.reg_index] -= (u64)cur_opcode.perform_math_static.value; + m_registers[cur_opcode.perform_math_static.reg_index] -= (u64)cur_opcode.perform_math_static.value; break; case RegisterArithmeticType_Multiplication: - this->registers[cur_opcode.perform_math_static.reg_index] *= (u64)cur_opcode.perform_math_static.value; + m_registers[cur_opcode.perform_math_static.reg_index] *= (u64)cur_opcode.perform_math_static.value; break; case RegisterArithmeticType_LeftShift: - this->registers[cur_opcode.perform_math_static.reg_index] <<= (u64)cur_opcode.perform_math_static.value; + m_registers[cur_opcode.perform_math_static.reg_index] <<= (u64)cur_opcode.perform_math_static.value; break; case RegisterArithmeticType_RightShift: - this->registers[cur_opcode.perform_math_static.reg_index] >>= (u64)cur_opcode.perform_math_static.value; + m_registers[cur_opcode.perform_math_static.reg_index] >>= (u64)cur_opcode.perform_math_static.value; break; default: /* Do not handle extensions here. */ @@ -957,16 +957,16 @@ namespace ams::dmnt::cheat::impl { /* Apply bit width. */ switch (cur_opcode.perform_math_static.bit_width) { case 1: - this->registers[cur_opcode.perform_math_static.reg_index] = static_cast(this->registers[cur_opcode.perform_math_static.reg_index]); + m_registers[cur_opcode.perform_math_static.reg_index] = static_cast(m_registers[cur_opcode.perform_math_static.reg_index]); break; case 2: - this->registers[cur_opcode.perform_math_static.reg_index] = static_cast(this->registers[cur_opcode.perform_math_static.reg_index]); + m_registers[cur_opcode.perform_math_static.reg_index] = static_cast(m_registers[cur_opcode.perform_math_static.reg_index]); break; case 4: - this->registers[cur_opcode.perform_math_static.reg_index] = static_cast(this->registers[cur_opcode.perform_math_static.reg_index]); + m_registers[cur_opcode.perform_math_static.reg_index] = static_cast(m_registers[cur_opcode.perform_math_static.reg_index]); break; case 8: - this->registers[cur_opcode.perform_math_static.reg_index] = static_cast(this->registers[cur_opcode.perform_math_static.reg_index]); + m_registers[cur_opcode.perform_math_static.reg_index] = static_cast(m_registers[cur_opcode.perform_math_static.reg_index]); break; } } @@ -980,10 +980,10 @@ namespace ams::dmnt::cheat::impl { break; case CheatVmOpcodeType_PerformArithmeticRegister: { - const u64 operand_1_value = this->registers[cur_opcode.perform_math_reg.src_reg_1_index]; + const u64 operand_1_value = m_registers[cur_opcode.perform_math_reg.src_reg_1_index]; const u64 operand_2_value = cur_opcode.perform_math_reg.has_immediate ? GetVmInt(cur_opcode.perform_math_reg.value, cur_opcode.perform_math_reg.bit_width) : - this->registers[cur_opcode.perform_math_reg.src_reg_2_index]; + m_registers[cur_opcode.perform_math_reg.src_reg_2_index]; u64 res_val = 0; /* Do requested math. */ @@ -1038,32 +1038,32 @@ namespace ams::dmnt::cheat::impl { } /* Save to register. */ - this->registers[cur_opcode.perform_math_reg.dst_reg_index] = res_val; + m_registers[cur_opcode.perform_math_reg.dst_reg_index] = res_val; } break; case CheatVmOpcodeType_StoreRegisterToAddress: { /* Calculate address. */ - u64 dst_value = this->registers[cur_opcode.str_register.str_reg_index]; - u64 dst_address = this->registers[cur_opcode.str_register.addr_reg_index]; + u64 dst_value = m_registers[cur_opcode.str_register.str_reg_index]; + u64 dst_address = m_registers[cur_opcode.str_register.addr_reg_index]; switch (cur_opcode.str_register.ofs_type) { case StoreRegisterOffsetType_None: /* Nothing more to do */ break; case StoreRegisterOffsetType_Reg: - dst_address += this->registers[cur_opcode.str_register.ofs_reg_index]; + dst_address += m_registers[cur_opcode.str_register.ofs_reg_index]; break; case StoreRegisterOffsetType_Imm: dst_address += cur_opcode.str_register.rel_address; break; case StoreRegisterOffsetType_MemReg: - dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, this->registers[cur_opcode.str_register.addr_reg_index]); + dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, m_registers[cur_opcode.str_register.addr_reg_index]); break; case StoreRegisterOffsetType_MemImm: dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, cur_opcode.str_register.rel_address); break; case StoreRegisterOffsetType_MemImmReg: - dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, this->registers[cur_opcode.str_register.addr_reg_index] + cur_opcode.str_register.rel_address); + dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, m_registers[cur_opcode.str_register.addr_reg_index] + cur_opcode.str_register.rel_address); break; } @@ -1079,7 +1079,7 @@ namespace ams::dmnt::cheat::impl { /* Increment register if relevant. */ if (cur_opcode.str_register.increment_reg) { - this->registers[cur_opcode.str_register.addr_reg_index] += cur_opcode.str_register.bit_width; + m_registers[cur_opcode.str_register.addr_reg_index] += cur_opcode.str_register.bit_width; } } break; @@ -1089,16 +1089,16 @@ namespace ams::dmnt::cheat::impl { u64 src_value = 0; switch (cur_opcode.begin_reg_cond.bit_width) { case 1: - src_value = static_cast(this->registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFul); + src_value = static_cast(m_registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFul); break; case 2: - src_value = static_cast(this->registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFul); + src_value = static_cast(m_registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFul); break; case 4: - src_value = static_cast(this->registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFFFFFul); + src_value = static_cast(m_registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFFFFFul); break; case 8: - src_value = static_cast(this->registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFFFFFFFFFFFFFul); + src_value = static_cast(m_registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFFFFFFFFFFFFFul); break; } @@ -1109,16 +1109,16 @@ namespace ams::dmnt::cheat::impl { } else if (cur_opcode.begin_reg_cond.comp_type == CompareRegisterValueType_OtherRegister) { switch (cur_opcode.begin_reg_cond.bit_width) { case 1: - cond_value = static_cast(this->registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFul); + cond_value = static_cast(m_registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFul); break; case 2: - cond_value = static_cast(this->registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFul); + cond_value = static_cast(m_registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFul); break; case 4: - cond_value = static_cast(this->registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFFFFFul); + cond_value = static_cast(m_registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFFFFFul); break; case 8: - cond_value = static_cast(this->registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFFFFFFFFFFFFFul); + cond_value = static_cast(m_registers[cur_opcode.begin_reg_cond.other_reg_index] & 0xFFFFFFFFFFFFFFFFul); break; } } else { @@ -1128,13 +1128,13 @@ namespace ams::dmnt::cheat::impl { cond_address = GetCheatProcessAddress(metadata, cur_opcode.begin_reg_cond.mem_type, cur_opcode.begin_reg_cond.rel_address); break; case CompareRegisterValueType_MemoryOfsReg: - cond_address = GetCheatProcessAddress(metadata, cur_opcode.begin_reg_cond.mem_type, this->registers[cur_opcode.begin_reg_cond.ofs_reg_index]); + cond_address = GetCheatProcessAddress(metadata, cur_opcode.begin_reg_cond.mem_type, m_registers[cur_opcode.begin_reg_cond.ofs_reg_index]); break; case CompareRegisterValueType_RegisterRelAddr: - cond_address = this->registers[cur_opcode.begin_reg_cond.addr_reg_index] + cur_opcode.begin_reg_cond.rel_address; + cond_address = m_registers[cur_opcode.begin_reg_cond.addr_reg_index] + cur_opcode.begin_reg_cond.rel_address; break; case CompareRegisterValueType_RegisterOfsReg: - cond_address = this->registers[cur_opcode.begin_reg_cond.addr_reg_index] + this->registers[cur_opcode.begin_reg_cond.ofs_reg_index]; + cond_address = m_registers[cur_opcode.begin_reg_cond.addr_reg_index] + m_registers[cur_opcode.begin_reg_cond.ofs_reg_index]; break; default: break; @@ -1182,17 +1182,17 @@ namespace ams::dmnt::cheat::impl { /* Save or restore a register. */ switch (cur_opcode.save_restore_reg.op_type) { case SaveRestoreRegisterOpType_ClearRegs: - this->registers[cur_opcode.save_restore_reg.dst_index] = 0ul; + m_registers[cur_opcode.save_restore_reg.dst_index] = 0ul; break; case SaveRestoreRegisterOpType_ClearSaved: - this->saved_values[cur_opcode.save_restore_reg.dst_index] = 0ul; + m_saved_values[cur_opcode.save_restore_reg.dst_index] = 0ul; break; case SaveRestoreRegisterOpType_Save: - this->saved_values[cur_opcode.save_restore_reg.dst_index] = this->registers[cur_opcode.save_restore_reg.src_index]; + m_saved_values[cur_opcode.save_restore_reg.dst_index] = m_registers[cur_opcode.save_restore_reg.src_index]; break; case SaveRestoreRegisterOpType_Restore: default: - this->registers[cur_opcode.save_restore_reg.dst_index] = this->saved_values[cur_opcode.save_restore_reg.src_index]; + m_registers[cur_opcode.save_restore_reg.dst_index] = m_saved_values[cur_opcode.save_restore_reg.src_index]; break; } break; @@ -1203,14 +1203,14 @@ namespace ams::dmnt::cheat::impl { switch (cur_opcode.save_restore_regmask.op_type) { case SaveRestoreRegisterOpType_ClearSaved: case SaveRestoreRegisterOpType_Save: - src = this->registers; - dst = this->saved_values; + src = m_registers; + dst = m_saved_values; break; case SaveRestoreRegisterOpType_ClearRegs: case SaveRestoreRegisterOpType_Restore: default: - src = this->saved_values; - dst = this->registers; + src = m_saved_values; + dst = m_registers; break; } for (size_t i = 0; i < NumRegisters; i++) { @@ -1232,10 +1232,10 @@ namespace ams::dmnt::cheat::impl { case CheatVmOpcodeType_ReadWriteStaticRegister: if (cur_opcode.rw_static_reg.static_idx < NumReadableStaticRegisters) { /* Load a register with a static register. */ - this->registers[cur_opcode.rw_static_reg.idx] = this->static_registers[cur_opcode.rw_static_reg.static_idx]; + m_registers[cur_opcode.rw_static_reg.idx] = m_static_registers[cur_opcode.rw_static_reg.static_idx]; } else { /* Store a register to a static register. */ - this->static_registers[cur_opcode.rw_static_reg.static_idx] = this->registers[cur_opcode.rw_static_reg.idx]; + m_static_registers[cur_opcode.rw_static_reg.static_idx] = m_registers[cur_opcode.rw_static_reg.idx]; } break; case CheatVmOpcodeType_PauseProcess: @@ -1251,16 +1251,16 @@ namespace ams::dmnt::cheat::impl { if (cur_opcode.debug_log.val_type == DebugLogValueType_RegisterValue) { switch (cur_opcode.debug_log.bit_width) { case 1: - log_value = static_cast(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFul); + log_value = static_cast(m_registers[cur_opcode.debug_log.val_reg_index] & 0xFFul); break; case 2: - log_value = static_cast(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFul); + log_value = static_cast(m_registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFul); break; case 4: - log_value = static_cast(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFul); + log_value = static_cast(m_registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFul); break; case 8: - log_value = static_cast(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFFFFFFFFFul); + log_value = static_cast(m_registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFFFFFFFFFul); break; } } else { @@ -1270,13 +1270,13 @@ namespace ams::dmnt::cheat::impl { val_address = GetCheatProcessAddress(metadata, cur_opcode.debug_log.mem_type, cur_opcode.debug_log.rel_address); break; case DebugLogValueType_MemoryOfsReg: - val_address = GetCheatProcessAddress(metadata, cur_opcode.debug_log.mem_type, this->registers[cur_opcode.debug_log.ofs_reg_index]); + val_address = GetCheatProcessAddress(metadata, cur_opcode.debug_log.mem_type, m_registers[cur_opcode.debug_log.ofs_reg_index]); break; case DebugLogValueType_RegisterRelAddr: - val_address = this->registers[cur_opcode.debug_log.addr_reg_index] + cur_opcode.debug_log.rel_address; + val_address = m_registers[cur_opcode.debug_log.addr_reg_index] + cur_opcode.debug_log.rel_address; break; case DebugLogValueType_RegisterOfsReg: - val_address = this->registers[cur_opcode.debug_log.addr_reg_index] + this->registers[cur_opcode.debug_log.ofs_reg_index]; + val_address = m_registers[cur_opcode.debug_log.addr_reg_index] + m_registers[cur_opcode.debug_log.ofs_reg_index]; break; default: break; diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.hpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.hpp index 2901ced6b..0eb47b2a2 100644 --- a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.hpp +++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_vm.hpp @@ -277,15 +277,15 @@ namespace ams::dmnt::cheat::impl { constexpr static size_t NumWritableStaticRegisters = 0x80; constexpr static size_t NumStaticRegisters = NumReadableStaticRegisters + NumWritableStaticRegisters; private: - size_t num_opcodes = 0; - size_t instruction_ptr = 0; - size_t condition_depth = 0; - bool decode_success = false; - u32 program[MaximumProgramOpcodeCount] = {0}; - u64 registers[NumRegisters] = {0}; - u64 saved_values[NumRegisters] = {0}; - u64 static_registers[NumStaticRegisters] = {0}; - size_t loop_tops[NumRegisters] = {0}; + size_t m_num_opcodes = 0; + size_t m_instruction_ptr = 0; + size_t m_condition_depth = 0; + bool m_decode_success = false; + u32 m_program[MaximumProgramOpcodeCount] = {0}; + u64 m_registers[NumRegisters] = {0}; + u64 m_saved_values[NumRegisters] = {0}; + u64 m_static_registers[NumStaticRegisters] = {0}; + size_t m_loop_tops[NumRegisters] = {0}; private: bool DecodeNextOpcode(CheatVmOpcode *out); void SkipConditionalBlock(bool is_if); @@ -303,32 +303,32 @@ namespace ams::dmnt::cheat::impl { static u64 GetVmInt(VmInt value, u32 bit_width); static u64 GetCheatProcessAddress(const CheatProcessMetadata* metadata, MemoryAccessType mem_type, u64 rel_address); public: - CheatVirtualMachine() { } + constexpr CheatVirtualMachine() = default; size_t GetProgramSize() { - return this->num_opcodes; + return m_num_opcodes; } bool LoadProgram(const CheatEntry *cheats, size_t num_cheats); void Execute(const CheatProcessMetadata *metadata); u64 GetStaticRegister(size_t which) const { - return this->static_registers[which]; + return m_static_registers[which]; } void SetStaticRegister(size_t which, u64 value) { - this->static_registers[which] = value; + m_static_registers[which] = value; } void ResetStaticRegisters() { - std::memset(this->static_registers, 0, sizeof(this->static_registers)); + std::memset(m_static_registers, 0, sizeof(m_static_registers)); } #ifdef DMNT_CHEAT_VM_DEBUG_LOG private: - fs::FileHandle debug_log_file; - s64 debug_log_file_offset; - bool has_debug_log_file; - char debug_log_format_buf[0x100]; + fs::FileHandle m_debug_log_file = {}; + s64 m_debug_log_file_offset = 0; + bool m_has_debug_log_file = false; + char m_debug_log_format_buf[0x100] = {0}; #endif }; diff --git a/stratosphere/fatal/source/fatal_config.cpp b/stratosphere/fatal/source/fatal_config.cpp index 210350cbc..e079d1cab 100644 --- a/stratosphere/fatal/source/fatal_config.cpp +++ b/stratosphere/fatal/source/fatal_config.cpp @@ -75,43 +75,43 @@ namespace ams::fatal::srv { FatalConfig::FatalConfig() { /* Get information from set. */ - settings::system::GetSerialNumber(std::addressof(this->serial_number)); - settings::system::GetFirmwareVersion(std::addressof(this->firmware_version)); - setsysGetQuestFlag(std::addressof(this->quest_flag)); + settings::system::GetSerialNumber(std::addressof(m_serial_number)); + settings::system::GetFirmwareVersion(std::addressof(m_firmware_version)); + setsysGetQuestFlag(std::addressof(m_quest_flag)); this->UpdateLanguageCode(); /* Read information from settings. */ - settings::fwdbg::GetSettingsItemValue(std::addressof(this->transition_to_fatal), sizeof(this->transition_to_fatal), "fatal", "transition_to_fatal"); - settings::fwdbg::GetSettingsItemValue(std::addressof(this->show_extra_info), sizeof(this->show_extra_info), "fatal", "show_extra_info"); + settings::fwdbg::GetSettingsItemValue(std::addressof(m_transition_to_fatal), sizeof(m_transition_to_fatal), "fatal", "transition_to_fatal"); + settings::fwdbg::GetSettingsItemValue(std::addressof(m_show_extra_info), sizeof(m_show_extra_info), "fatal", "show_extra_info"); u64 quest_interval_second; settings::fwdbg::GetSettingsItemValue(std::addressof(quest_interval_second), sizeof(quest_interval_second), "fatal", "quest_reboot_interval_second"); - this->quest_reboot_interval = TimeSpan::FromSeconds(quest_interval_second); + m_quest_reboot_interval = TimeSpan::FromSeconds(quest_interval_second); /* Atmosphere extension for automatic reboot. */ u64 auto_reboot_ms; if (settings::fwdbg::GetSettingsItemValue(std::addressof(auto_reboot_ms), sizeof(auto_reboot_ms), "atmosphere", "fatal_auto_reboot_interval") == sizeof(auto_reboot_ms)) { - this->fatal_auto_reboot_interval = TimeSpan::FromMilliSeconds(auto_reboot_ms); - this->fatal_auto_reboot_enabled = auto_reboot_ms != 0; + m_fatal_auto_reboot_interval = TimeSpan::FromMilliSeconds(auto_reboot_ms); + m_fatal_auto_reboot_enabled = auto_reboot_ms != 0; } /* Setup messages. */ { - this->error_msg = "Error Code: 2%03d-%04d (0x%x)\n"; + m_error_msg = "Error Code: 2%03d-%04d (0x%x)\n"; - this->error_desc = "An error has occurred.\n\n" - "Please press the POWER Button to restart the console normally, or a VOL button\n" - "to reboot to a payload (or RCM, if none is present). If you are unable to\n" - "restart the console, hold the POWER Button for 12 seconds to turn the console off.\n\n" - "If the problem persists, refer to the Nintendo Support Website.\n" - "support.nintendo.com/switch/error\n"; + m_error_desc = "An error has occurred.\n\n" + "Please press the POWER Button to restart the console normally, or a VOL button\n" + "to reboot to a payload (or RCM, if none is present). If you are unable to\n" + "restart the console, hold the POWER Button for 12 seconds to turn the console off.\n\n" + "If the problem persists, refer to the Nintendo Support Website.\n" + "support.nintendo.com/switch/error\n"; /* If you're running Atmosphere on a quest unit for some reason, talk to me on discord. */ - this->quest_desc = "Please call 1-800-875-1852 for service.\n\n" - "Also, please be aware that running Atmosphere on a Quest device is not fully\n" - "supported. Perhaps try booting your device without Atmosphere before calling\n" - "an official Nintendo service hotline. If you encounter further issues, please\n" - "contact SciresM#0524 on Discord, or via some other means.\n"; + m_quest_desc = "Please call 1-800-875-1852 for service.\n\n" + "Also, please be aware that running Atmosphere on a Quest device is not fully\n" + "supported. Perhaps try booting your device without Atmosphere before calling\n" + "an official Nintendo service hotline. If you encounter further issues, please\n" + "contact SciresM#0524 on Discord, or via some other means.\n"; /* TODO: Try to load dynamically? */ /* FsStorage message_storage; */ diff --git a/stratosphere/fatal/source/fatal_config.hpp b/stratosphere/fatal/source/fatal_config.hpp index f4f0843aa..f44b119ac 100644 --- a/stratosphere/fatal/source/fatal_config.hpp +++ b/stratosphere/fatal/source/fatal_config.hpp @@ -20,70 +20,70 @@ namespace ams::fatal::srv { class FatalConfig { private: - settings::system::SerialNumber serial_number{}; - settings::system::FirmwareVersion firmware_version{}; - u64 language_code{}; - TimeSpan quest_reboot_interval{}; - bool transition_to_fatal{}; - bool show_extra_info{}; - bool quest_flag{}; - const char *error_msg{}; - const char *error_desc{}; - const char *quest_desc{}; - TimeSpan fatal_auto_reboot_interval{}; - bool fatal_auto_reboot_enabled{}; + settings::system::SerialNumber m_serial_number{}; + settings::system::FirmwareVersion m_firmware_version{}; + u64 m_language_code{}; + TimeSpan m_quest_reboot_interval{}; + bool m_transition_to_fatal{}; + bool m_show_extra_info{}; + bool m_quest_flag{}; + const char *m_error_msg{}; + const char *m_error_desc{}; + const char *m_quest_desc{}; + TimeSpan m_fatal_auto_reboot_interval{}; + bool m_fatal_auto_reboot_enabled{}; public: FatalConfig(); const settings::system::SerialNumber &GetSerialNumber() const { - return this->serial_number; + return m_serial_number; } const settings::system::FirmwareVersion &GetFirmwareVersion() const { - return this->firmware_version; + return m_firmware_version; } void UpdateLanguageCode() { - setGetLanguageCode(&this->language_code); + setGetLanguageCode(&m_language_code); } u64 GetLanguageCode() const { - return this->language_code; + return m_language_code; } bool ShouldTransitionToFatal() const { - return this->transition_to_fatal; + return m_transition_to_fatal; } bool ShouldShowExtraInfo() const { - return this->show_extra_info; + return m_show_extra_info; } bool IsQuest() const { - return this->quest_flag; + return m_quest_flag; } bool IsFatalRebootEnabled() const { - return this->fatal_auto_reboot_enabled; + return m_fatal_auto_reboot_enabled; } TimeSpan GetQuestRebootTimeoutInterval() const { - return this->quest_reboot_interval; + return m_quest_reboot_interval; } TimeSpan GetFatalRebootTimeoutInterval() const { - return this->fatal_auto_reboot_interval; + return m_fatal_auto_reboot_interval; } const char *GetErrorMessage() const { - return this->error_msg; + return m_error_msg; } const char *GetErrorDescription() const { if (this->IsQuest()) { - return this->quest_desc; + return m_quest_desc; } else { - return this->error_desc; + return m_error_desc; } } }; diff --git a/stratosphere/fatal/source/fatal_event_manager.cpp b/stratosphere/fatal/source/fatal_event_manager.cpp index b50351b08..230242007 100644 --- a/stratosphere/fatal/source/fatal_event_manager.cpp +++ b/stratosphere/fatal/source/fatal_event_manager.cpp @@ -18,26 +18,26 @@ namespace ams::fatal::srv { - FatalEventManager::FatalEventManager() : lock() { + FatalEventManager::FatalEventManager() : m_lock() { /* Just create all the events. */ for (size_t i = 0; i < FatalEventManager::NumFatalEvents; i++) { - R_ABORT_UNLESS(os::CreateSystemEvent(std::addressof(this->events[i]), os::EventClearMode_AutoClear, true)); + R_ABORT_UNLESS(os::CreateSystemEvent(std::addressof(m_events[i]), os::EventClearMode_AutoClear, true)); } } Result FatalEventManager::GetEvent(const os::SystemEventType **out) { - std::scoped_lock lk{this->lock}; + std::scoped_lock lk{m_lock}; /* Only allow GetEvent to succeed NumFatalEvents times. */ - R_UNLESS(this->num_events_gotten < FatalEventManager::NumFatalEvents, fatal::ResultTooManyEvents()); + R_UNLESS(m_num_events_gotten < FatalEventManager::NumFatalEvents, fatal::ResultTooManyEvents()); - *out = std::addressof(this->events[this->num_events_gotten++]); + *out = std::addressof(m_events[m_num_events_gotten++]); return ResultSuccess(); } void FatalEventManager::SignalEvents() { for (size_t i = 0; i < FatalEventManager::NumFatalEvents; i++) { - os::SignalSystemEvent(std::addressof(this->events[i])); + os::SignalSystemEvent(std::addressof(m_events[i])); } } diff --git a/stratosphere/fatal/source/fatal_event_manager.hpp b/stratosphere/fatal/source/fatal_event_manager.hpp index 832e33a58..99a93906b 100644 --- a/stratosphere/fatal/source/fatal_event_manager.hpp +++ b/stratosphere/fatal/source/fatal_event_manager.hpp @@ -24,9 +24,9 @@ namespace ams::fatal::srv { public: static constexpr size_t NumFatalEvents = 3; private: - os::SdkMutex lock; - size_t num_events_gotten = 0; - os::SystemEventType events[NumFatalEvents]; + os::SdkMutex m_lock; + size_t m_num_events_gotten = 0; + os::SystemEventType m_events[NumFatalEvents]; public: FatalEventManager(); Result GetEvent(const os::SystemEventType **out); diff --git a/stratosphere/fatal/source/fatal_scoped_file.cpp b/stratosphere/fatal/source/fatal_scoped_file.cpp index fbe21ed28..8dc0282d5 100644 --- a/stratosphere/fatal/source/fatal_scoped_file.cpp +++ b/stratosphere/fatal/source/fatal_scoped_file.cpp @@ -90,8 +90,8 @@ namespace ams::fatal::srv { } /* Advance, if we write successfully. */ - if (R_SUCCEEDED(fs::WriteFile(this->file, this->offset, data, size, fs::WriteOption::Flush))) { - this->offset += size; + if (R_SUCCEEDED(fs::WriteFile(m_file, m_offset, data, size, fs::WriteOption::Flush))) { + m_offset += size; } } diff --git a/stratosphere/fatal/source/fatal_scoped_file.hpp b/stratosphere/fatal/source/fatal_scoped_file.hpp index 1516b2ee8..80ce73bda 100644 --- a/stratosphere/fatal/source/fatal_scoped_file.hpp +++ b/stratosphere/fatal/source/fatal_scoped_file.hpp @@ -22,24 +22,24 @@ namespace ams::fatal::srv { NON_COPYABLE(ScopedFile); NON_MOVEABLE(ScopedFile); private: - fs::FileHandle file; - s64 offset; - bool opened; + fs::FileHandle m_file; + s64 m_offset; + bool m_opened; public: - ScopedFile(const char *path) : file(), offset(), opened(false) { + ScopedFile(const char *path) : m_file(), m_offset(), m_opened(false) { if (R_SUCCEEDED(fs::CreateFile(path, 0))) { - this->opened = R_SUCCEEDED(fs::OpenFile(std::addressof(this->file), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); + m_opened = R_SUCCEEDED(fs::OpenFile(std::addressof(m_file), path, fs::OpenMode_Write | fs::OpenMode_AllowAppend)); } } ~ScopedFile() { - if (this->opened) { - fs::CloseFile(file); + if (m_opened) { + fs::CloseFile(m_file); } } bool IsOpen() const { - return this->opened; + return m_opened; } void WriteString(const char *str); diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index b052d9b7e..dc07c91f7 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -28,27 +28,27 @@ namespace ams::fatal::srv { /* Service Context. */ class ServiceContext { private: - os::Event erpt_event; - os::Event battery_event; - ThrowContext context; - FatalEventManager event_manager; - bool has_thrown; + os::Event m_erpt_event; + os::Event m_battery_event; + ThrowContext m_context; + FatalEventManager m_event_manager; + bool m_has_thrown; private: Result TrySetHasThrown() { - R_UNLESS(!this->has_thrown, fatal::ResultAlreadyThrown()); - this->has_thrown = true; + R_UNLESS(!m_has_thrown, fatal::ResultAlreadyThrown()); + m_has_thrown = true; return ResultSuccess(); } public: ServiceContext() - : erpt_event(os::EventClearMode_ManualClear), battery_event(os::EventClearMode_ManualClear), - context(std::addressof(erpt_event), std::addressof(battery_event)), has_thrown(false) + : m_erpt_event(os::EventClearMode_ManualClear), m_battery_event(os::EventClearMode_ManualClear), + m_context(std::addressof(m_erpt_event), std::addressof(m_battery_event)), m_has_thrown(false) { /* ... */ } Result GetEvent(const os::SystemEventType **out) { - return this->event_manager.GetEvent(out); + return m_event_manager.GetEvent(out); } Result ThrowFatal(Result result, os::ProcessId process_id) { @@ -73,51 +73,51 @@ namespace ams::fatal::srv { /* Note that we've thrown fatal. */ R_TRY(this->TrySetHasThrown()); - /* At this point we have exclusive access to this->context. */ - this->context.result = result; - this->context.cpu_ctx = cpu_ctx; + /* At this point we have exclusive access to m_context. */ + m_context.result = result; + m_context.cpu_ctx = cpu_ctx; /* Cap the stack trace to a sane limit. */ if (cpu_ctx.architecture == CpuContext::Architecture_Aarch64) { - this->context.cpu_ctx.aarch64_ctx.stack_trace_size = std::max(size_t(this->context.cpu_ctx.aarch64_ctx.stack_trace_size), aarch64::CpuContext::MaxStackTraceDepth); + m_context.cpu_ctx.aarch64_ctx.stack_trace_size = std::max(size_t(m_context.cpu_ctx.aarch64_ctx.stack_trace_size), aarch64::CpuContext::MaxStackTraceDepth); } else { - this->context.cpu_ctx.aarch32_ctx.stack_trace_size = std::max(size_t(this->context.cpu_ctx.aarch32_ctx.stack_trace_size), aarch32::CpuContext::MaxStackTraceDepth); + m_context.cpu_ctx.aarch32_ctx.stack_trace_size = std::max(size_t(m_context.cpu_ctx.aarch32_ctx.stack_trace_size), aarch32::CpuContext::MaxStackTraceDepth); } /* Get program id. */ - pm::info::GetProgramId(std::addressof(this->context.program_id), process_id); - this->context.is_creport = (this->context.program_id == ncm::SystemProgramId::Creport); + pm::info::GetProgramId(std::addressof(m_context.program_id), process_id); + m_context.is_creport = (m_context.program_id == ncm::SystemProgramId::Creport); - if (!this->context.is_creport) { + if (!m_context.is_creport) { /* On firmware version 2.0.0, use debugging SVCs to collect information. */ if (hos::GetVersion() >= hos::Version_2_0_0) { - fatal::srv::TryCollectDebugInformation(std::addressof(this->context), process_id); + fatal::srv::TryCollectDebugInformation(std::addressof(m_context), process_id); } } else { /* We received info from creport. Parse program id from afsr0. */ if (cpu_ctx.architecture == CpuContext::Architecture_Aarch64) { - this->context.program_id = cpu_ctx.aarch64_ctx.GetProgramIdForAtmosphere(); + m_context.program_id = cpu_ctx.aarch64_ctx.GetProgramIdForAtmosphere(); } else { - this->context.program_id = cpu_ctx.aarch32_ctx.GetProgramIdForAtmosphere(); + m_context.program_id = cpu_ctx.aarch32_ctx.GetProgramIdForAtmosphere(); } } /* Decide whether to generate a report. */ - this->context.generate_error_report = (policy == FatalPolicy_ErrorReportAndErrorScreen); + m_context.generate_error_report = (policy == FatalPolicy_ErrorReportAndErrorScreen); /* Adjust error code (ResultSuccess()/2000-0000 -> err::ResultSystemProgramAbort()/2162-0002). */ - if (R_SUCCEEDED(this->context.result)) { - this->context.result = err::ResultSystemProgramAbort(); + if (R_SUCCEEDED(m_context.result)) { + m_context.result = err::ResultSystemProgramAbort(); } switch (policy) { case FatalPolicy_ErrorReportAndErrorScreen: case FatalPolicy_ErrorScreen: /* Signal that we're throwing. */ - this->event_manager.SignalEvents(); + m_event_manager.SignalEvents(); if (GetFatalConfig().ShouldTransitionToFatal()) { - RunTasks(std::addressof(this->context)); + RunTasks(std::addressof(m_context)); } break; /* N aborts here. Should we just return an error code? */ diff --git a/stratosphere/fatal/source/fatal_task.cpp b/stratosphere/fatal/source/fatal_task.cpp index 6985b0424..99be1f1aa 100644 --- a/stratosphere/fatal/source/fatal_task.cpp +++ b/stratosphere/fatal/source/fatal_task.cpp @@ -29,7 +29,7 @@ namespace ams::fatal::srv { class TaskThread { NON_COPYABLE(TaskThread); private: - os::ThreadType thread; + os::ThreadType m_thread; private: static void RunTaskImpl(void *arg) { ITask *task = reinterpret_cast(arg); @@ -41,9 +41,9 @@ namespace ams::fatal::srv { public: TaskThread() { /* ... */ } void StartTask(ITask *task) { - R_ABORT_UNLESS(os::CreateThread(std::addressof(this->thread), RunTaskImpl, task, task->GetStack(), task->GetStackSize(), AMS_GET_SYSTEM_THREAD_PRIORITY(fatalsrv, FatalTaskThread), 3)); - os::SetThreadNamePointer(std::addressof(this->thread), AMS_GET_SYSTEM_THREAD_NAME(fatalsrv, FatalTaskThread)); - os::StartThread(std::addressof(this->thread)); + R_ABORT_UNLESS(os::CreateThread(std::addressof(m_thread), RunTaskImpl, task, task->GetStack(), task->GetStackSize(), AMS_GET_SYSTEM_THREAD_PRIORITY(fatalsrv, FatalTaskThread), 3)); + os::SetThreadNamePointer(std::addressof(m_thread), AMS_GET_SYSTEM_THREAD_NAME(fatalsrv, FatalTaskThread)); + os::StartThread(std::addressof(m_thread)); } }; @@ -52,13 +52,13 @@ namespace ams::fatal::srv { private: static constexpr size_t MaxTasks = 8; private: - TaskThread task_threads[MaxTasks]; - size_t task_count = 0; + TaskThread m_task_threads[MaxTasks]; + size_t m_task_count = 0; public: TaskManager() { /* ... */ } void StartTask(ITask *task) { - AMS_ABORT_UNLESS(this->task_count < MaxTasks); - this->task_threads[this->task_count++].StartTask(task); + AMS_ABORT_UNLESS(m_task_count < MaxTasks); + m_task_threads[m_task_count++].StartTask(task); } }; diff --git a/stratosphere/fatal/source/fatal_task.hpp b/stratosphere/fatal/source/fatal_task.hpp index e8f545488..b48cd9100 100644 --- a/stratosphere/fatal/source/fatal_task.hpp +++ b/stratosphere/fatal/source/fatal_task.hpp @@ -20,10 +20,10 @@ namespace ams::fatal::srv { class ITask { protected: - const ThrowContext *context = nullptr; + const ThrowContext *m_context = nullptr; public: void Initialize(const ThrowContext *context) { - this->context = context; + m_context = context; } virtual Result Run() = 0; @@ -38,10 +38,10 @@ namespace ams::fatal::srv { static constexpr size_t StackSize = _StackSize; static_assert(util::IsAligned(StackSize, os::MemoryPageSize), "StackSize alignment"); protected: - alignas(os::MemoryPageSize) u8 stack_mem[StackSize] = {}; + alignas(os::MemoryPageSize) u8 m_stack_mem[StackSize] = {}; public: virtual u8 *GetStack() override final { - return this->stack_mem; + return m_stack_mem; } virtual size_t GetStackSize() const override final { diff --git a/stratosphere/fatal/source/fatal_task_error_report.cpp b/stratosphere/fatal/source/fatal_task_error_report.cpp index 8f2f837e4..190bebbbe 100644 --- a/stratosphere/fatal/source/fatal_task_error_report.cpp +++ b/stratosphere/fatal/source/fatal_task_error_report.cpp @@ -79,61 +79,61 @@ namespace ams::fatal::srv { /* Open report file. */ { - util::SNPrintf(file_path, sizeof(file_path) - 1, "sdmc:/atmosphere/fatal_reports/%011lu_%016lx.log", timestamp, static_cast(this->context->program_id)); + util::SNPrintf(file_path, sizeof(file_path) - 1, "sdmc:/atmosphere/fatal_reports/%011lu_%016lx.log", timestamp, static_cast(m_context->program_id)); ScopedFile file(file_path); if (file.IsOpen()) { file.WriteFormat("Atmosphère Fatal Report (v1.1):\n"); - file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", this->context->result.GetValue(), this->context->result.GetModule(), this->context->result.GetDescription()); - file.WriteFormat("Program ID: %016lx\n", static_cast(this->context->program_id)); - if (strlen(this->context->proc_name)) { - file.WriteFormat("Process Name: %s\n", this->context->proc_name); + file.WriteFormat("Result: 0x%X (2%03d-%04d)\n\n", m_context->result.GetValue(), m_context->result.GetModule(), m_context->result.GetDescription()); + file.WriteFormat("Program ID: %016lx\n", static_cast(m_context->program_id)); + if (strlen(m_context->proc_name)) { + file.WriteFormat("Process Name: %s\n", m_context->proc_name); } file.WriteFormat("Firmware: %s (Atmosphère %u.%u.%u-%s)\n", GetFatalConfig().GetFirmwareVersion().display_version, ATMOSPHERE_RELEASE_VERSION, ams::GetGitRevision()); - if (this->context->cpu_ctx.architecture == CpuContext::Architecture_Aarch32) { + if (m_context->cpu_ctx.architecture == CpuContext::Architecture_Aarch32) { file.WriteFormat("General Purpose Registers:\n"); for (size_t i = 0; i <= aarch32::RegisterName_PC; i++) { - if (this->context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i))) { - file.WriteFormat( " %3s: %08x\n", aarch32::CpuContext::RegisterNameStrings[i], this->context->cpu_ctx.aarch32_ctx.r[i]); + if (m_context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i))) { + file.WriteFormat( " %3s: %08x\n", aarch32::CpuContext::RegisterNameStrings[i], m_context->cpu_ctx.aarch32_ctx.r[i]); } } - file.WriteFormat("Start Address: %08x\n", this->context->cpu_ctx.aarch32_ctx.base_address); + file.WriteFormat("Start Address: %08x\n", m_context->cpu_ctx.aarch32_ctx.base_address); file.WriteFormat("Stack Trace:\n"); - for (unsigned int i = 0; i < this->context->cpu_ctx.aarch32_ctx.stack_trace_size; i++) { - file.WriteFormat(" ReturnAddress[%02u]: %08x\n", i, this->context->cpu_ctx.aarch32_ctx.stack_trace[i]); + for (unsigned int i = 0; i < m_context->cpu_ctx.aarch32_ctx.stack_trace_size; i++) { + file.WriteFormat(" ReturnAddress[%02u]: %08x\n", i, m_context->cpu_ctx.aarch32_ctx.stack_trace[i]); } } else { file.WriteFormat("General Purpose Registers:\n"); for (size_t i = 0; i <= aarch64::RegisterName_PC; i++) { - if (this->context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i))) { - file.WriteFormat( " %3s: %016lx\n", aarch64::CpuContext::RegisterNameStrings[i], this->context->cpu_ctx.aarch64_ctx.x[i]); + if (m_context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i))) { + file.WriteFormat( " %3s: %016lx\n", aarch64::CpuContext::RegisterNameStrings[i], m_context->cpu_ctx.aarch64_ctx.x[i]); } } - file.WriteFormat("Start Address: %016lx\n", this->context->cpu_ctx.aarch64_ctx.base_address); + file.WriteFormat("Start Address: %016lx\n", m_context->cpu_ctx.aarch64_ctx.base_address); file.WriteFormat("Stack Trace:\n"); - for (unsigned int i = 0; i < this->context->cpu_ctx.aarch64_ctx.stack_trace_size; i++) { - file.WriteFormat(" ReturnAddress[%02u]: %016lx\n", i, this->context->cpu_ctx.aarch64_ctx.stack_trace[i]); + for (unsigned int i = 0; i < m_context->cpu_ctx.aarch64_ctx.stack_trace_size; i++) { + file.WriteFormat(" ReturnAddress[%02u]: %016lx\n", i, m_context->cpu_ctx.aarch64_ctx.stack_trace[i]); } } - if (this->context->stack_dump_size != 0) { + if (m_context->stack_dump_size != 0) { file.WriteFormat("Stack Dump: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); for (size_t i = 0; i < 0x10; i++) { const size_t ofs = i * 0x10; file.WriteFormat(" %012lx %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - this->context->stack_dump_base + ofs, this->context->stack_dump[ofs + 0], this->context->stack_dump[ofs + 1], this->context->stack_dump[ofs + 2], this->context->stack_dump[ofs + 3], this->context->stack_dump[ofs + 4], this->context->stack_dump[ofs + 5], this->context->stack_dump[ofs + 6], this->context->stack_dump[ofs + 7], - this->context->stack_dump[ofs + 8], this->context->stack_dump[ofs + 9], this->context->stack_dump[ofs + 10], this->context->stack_dump[ofs + 11], this->context->stack_dump[ofs + 12], this->context->stack_dump[ofs + 13], this->context->stack_dump[ofs + 14], this->context->stack_dump[ofs + 15]); + m_context->stack_dump_base + ofs, m_context->stack_dump[ofs + 0], m_context->stack_dump[ofs + 1], m_context->stack_dump[ofs + 2], m_context->stack_dump[ofs + 3], m_context->stack_dump[ofs + 4], m_context->stack_dump[ofs + 5], m_context->stack_dump[ofs + 6], m_context->stack_dump[ofs + 7], + m_context->stack_dump[ofs + 8], m_context->stack_dump[ofs + 9], m_context->stack_dump[ofs + 10], m_context->stack_dump[ofs + 11], m_context->stack_dump[ofs + 12], m_context->stack_dump[ofs + 13], m_context->stack_dump[ofs + 14], m_context->stack_dump[ofs + 15]); } } - if (this->context->tls_address != 0) { - file.WriteFormat("TLS Address: %016lx\n", this->context->tls_address); + if (m_context->tls_address != 0) { + file.WriteFormat("TLS Address: %016lx\n", m_context->tls_address); file.WriteFormat("TLS Dump: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n"); for (size_t i = 0; i < 0x10; i++) { const size_t ofs = i * 0x10; file.WriteFormat(" %012lx %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - this->context->tls_address + ofs, this->context->tls_dump[ofs + 0], this->context->tls_dump[ofs + 1], this->context->tls_dump[ofs + 2], this->context->tls_dump[ofs + 3], this->context->tls_dump[ofs + 4], this->context->tls_dump[ofs + 5], this->context->tls_dump[ofs + 6], this->context->tls_dump[ofs + 7], - this->context->tls_dump[ofs + 8], this->context->tls_dump[ofs + 9], this->context->tls_dump[ofs + 10], this->context->tls_dump[ofs + 11], this->context->tls_dump[ofs + 12], this->context->tls_dump[ofs + 13], this->context->tls_dump[ofs + 14], this->context->tls_dump[ofs + 15]); + m_context->tls_address + ofs, m_context->tls_dump[ofs + 0], m_context->tls_dump[ofs + 1], m_context->tls_dump[ofs + 2], m_context->tls_dump[ofs + 3], m_context->tls_dump[ofs + 4], m_context->tls_dump[ofs + 5], m_context->tls_dump[ofs + 6], m_context->tls_dump[ofs + 7], + m_context->tls_dump[ofs + 8], m_context->tls_dump[ofs + 9], m_context->tls_dump[ofs + 10], m_context->tls_dump[ofs + 11], m_context->tls_dump[ofs + 12], m_context->tls_dump[ofs + 13], m_context->tls_dump[ofs + 14], m_context->tls_dump[ofs + 15]); } } } @@ -141,29 +141,29 @@ namespace ams::fatal::srv { /* Dump data to file. */ { - util::SNPrintf(file_path, sizeof(file_path) - 1, "sdmc:/atmosphere/fatal_reports/dumps/%011lu_%016lx.bin", timestamp, static_cast(this->context->program_id)); + util::SNPrintf(file_path, sizeof(file_path) - 1, "sdmc:/atmosphere/fatal_reports/dumps/%011lu_%016lx.bin", timestamp, static_cast(m_context->program_id)); ScopedFile file(file_path); if (file.IsOpen()) { - file.Write(this->context->tls_dump, sizeof(this->context->tls_dump)); - if (this->context->stack_dump_size) { - file.Write(this->context->stack_dump, this->context->stack_dump_size); + file.Write(m_context->tls_dump, sizeof(m_context->tls_dump)); + if (m_context->stack_dump_size) { + file.Write(m_context->stack_dump, m_context->stack_dump_size); } } } } Result ErrorReportTask::Run() { - if (this->context->generate_error_report) { + if (m_context->generate_error_report) { /* Here, Nintendo creates an error report with erpt. AMS will not do that. */ } /* Save report to SD card. */ - if (!this->context->is_creport) { + if (!m_context->is_creport) { this->SaveReportToSdCard(); } /* Signal we're done with our job. */ - this->context->erpt_event->Signal(); + m_context->erpt_event->Signal(); return ResultSuccess(); } diff --git a/stratosphere/fatal/source/fatal_task_power.cpp b/stratosphere/fatal/source/fatal_task_power.cpp index 61569bf02..35f60d9a2 100644 --- a/stratosphere/fatal/source/fatal_task_power.cpp +++ b/stratosphere/fatal/source/fatal_task_power.cpp @@ -53,17 +53,17 @@ namespace ams::fatal::srv { class RebootTimingObserver { private: - os::Tick start_tick; - TimeSpan interval; - bool flag; + os::Tick m_start_tick; + TimeSpan m_interval; + bool m_flag; public: - RebootTimingObserver(bool flag, TimeSpan iv) : start_tick(os::GetSystemTick()), interval(iv), flag(flag) { + RebootTimingObserver(bool flag, TimeSpan iv) : m_start_tick(os::GetSystemTick()), m_interval(iv), m_flag(flag) { /* ... */ } bool IsRebootTiming() const { auto current_tick = os::GetSystemTick(); - return this->flag && (current_tick - this->start_tick).ToTimeSpan() >= this->interval; + return m_flag && (current_tick - m_start_tick).ToTimeSpan() >= m_interval; } }; @@ -114,13 +114,13 @@ namespace ams::fatal::srv { /* Check the battery state, and shutdown on low voltage. */ if (R_FAILED(psmGetBatteryVoltageState(std::addressof(bv_state))) || bv_state == PsmBatteryVoltageState_NeedsShutdown) { /* Wait a second for the error report task to finish. */ - this->context->erpt_event->TimedWait(TimeSpan::FromSeconds(1)); + m_context->erpt_event->TimedWait(TimeSpan::FromSeconds(1)); this->TryShutdown(); return; } /* Signal we've checked the battery at least once. */ - this->context->battery_event->Signal(); + m_context->battery_event->Signal(); /* Loop querying voltage state every 5 seconds. */ while (true) { @@ -148,7 +148,7 @@ namespace ams::fatal::srv { void PowerButtonObserveTask::WaitForPowerButton() { /* Wait up to a second for error report generation to finish. */ - this->context->erpt_event->TimedWait(TimeSpan::FromSeconds(1)); + m_context->erpt_event->TimedWait(TimeSpan::FromSeconds(1)); /* Force a reboot after some time if kiosk unit. */ const auto &config = GetFatalConfig(); diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 6330da4e1..95a61aabc 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -70,10 +70,10 @@ namespace ams::fatal::srv { /* Task definitions. */ class ShowFatalTask : public ITaskWithStack<0x8000> { private: - ViDisplay display; - ViLayer layer; - NWindow win; - NvMap map; + ViDisplay m_display; + ViLayer m_layer; + NWindow m_win; + NvMap m_map; private: Result SetupDisplayInternal(); Result SetupDisplayExternal(); @@ -156,19 +156,19 @@ namespace ams::fatal::srv { R_TRY(SetupDisplayExternal()); /* Open the default display. */ - R_TRY(viOpenDefaultDisplay(std::addressof(this->display))); + R_TRY(viOpenDefaultDisplay(std::addressof(m_display))); /* Reset the display magnification to its default value. */ s32 display_width, display_height; - R_TRY(viGetDisplayLogicalResolution(std::addressof(this->display), std::addressof(display_width), std::addressof(display_height))); + R_TRY(viGetDisplayLogicalResolution(std::addressof(m_display), std::addressof(display_width), std::addressof(display_height))); /* viSetDisplayMagnification was added in 3.0.0. */ if (hos::GetVersion() >= hos::Version_3_0_0) { - R_TRY(viSetDisplayMagnification(std::addressof(this->display), 0, 0, display_width, display_height)); + R_TRY(viSetDisplayMagnification(std::addressof(m_display), 0, 0, display_width, display_height)); } /* Create layer to draw to. */ - R_TRY(viCreateLayer(std::addressof(this->display), std::addressof(this->layer))); + R_TRY(viCreateLayer(std::addressof(m_display), std::addressof(m_layer))); /* Setup the layer. */ { @@ -183,16 +183,16 @@ namespace ams::fatal::srv { const float layer_x = static_cast((display_width - LayerWidth) / 2); const float layer_y = static_cast((display_height - LayerHeight) / 2); - R_TRY(viSetLayerSize(std::addressof(this->layer), LayerWidth, LayerHeight)); + R_TRY(viSetLayerSize(std::addressof(m_layer), LayerWidth, LayerHeight)); /* Set the layer's Z at display maximum, to be above everything else .*/ - R_TRY(viSetLayerZ(std::addressof(this->layer), FatalLayerZ)); + R_TRY(viSetLayerZ(std::addressof(m_layer), FatalLayerZ)); /* Center the layer in the screen. */ - R_TRY(viSetLayerPosition(std::addressof(this->layer), layer_x, layer_y)); + R_TRY(viSetLayerPosition(std::addressof(m_layer), layer_x, layer_y)); /* Create framebuffer. */ - R_TRY(nwindowCreateFromLayer(std::addressof(this->win), std::addressof(this->layer))); + R_TRY(nwindowCreateFromLayer(std::addressof(m_win), std::addressof(m_layer))); R_TRY(this->InitializeNativeWindow()); } @@ -229,14 +229,14 @@ namespace ams::fatal::srv { /* Draw error message and firmware. */ font::SetPosition(start_x, start_y); font::SetFontSize(16.0f); - font::PrintFormat(config.GetErrorMessage(), this->context->result.GetModule(), this->context->result.GetDescription(), this->context->result.GetValue()); + font::PrintFormat(config.GetErrorMessage(), m_context->result.GetModule(), m_context->result.GetDescription(), m_context->result.GetValue()); font::AddSpacingLines(0.5f); - font::PrintFormatLine( "Program: %016lX", static_cast(this->context->program_id)); + font::PrintFormatLine( "Program: %016lX", static_cast(m_context->program_id)); font::AddSpacingLines(0.5f); font::PrintFormatLine("Firmware: %s (Atmosphère %u.%u.%u-%s)", config.GetFirmwareVersion().display_version, ATMOSPHERE_RELEASE_VERSION, ams::GetGitRevision()); font::AddSpacingLines(1.5f); - if (!exosphere::ResultVersionMismatch::Includes(this->context->result)) { + if (!exosphere::ResultVersionMismatch::Includes(m_context->result)) { font::Print(config.GetErrorDescription()); } else { /* Print a special message for atmosphere version mismatch. */ @@ -260,7 +260,7 @@ namespace ams::fatal::srv { u32 pc_x = 0; /* Note architecutre. */ - const bool is_aarch32 = this->context->cpu_ctx.architecture == CpuContext::Architecture_Aarch32; + const bool is_aarch32 = m_context->cpu_ctx.architecture == CpuContext::Architecture_Aarch32; /* Print GPRs. */ font::SetFontSize(14.0f); @@ -273,8 +273,8 @@ namespace ams::fatal::srv { u32 x = font::GetX(); font::PrintFormat("%s:", aarch32::CpuContext::RegisterNameStrings[i]); font::SetPosition(x + 47, font::GetY()); - if (this->context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i))) { - font::PrintMonospaceU32(this->context->cpu_ctx.aarch32_ctx.r[i]); + if (m_context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i))) { + font::PrintMonospaceU32(m_context->cpu_ctx.aarch32_ctx.r[i]); font::PrintMonospaceBlank(8); } else { font::PrintMonospaceBlank(16); @@ -283,8 +283,8 @@ namespace ams::fatal::srv { pc_x = font::GetX(); font::PrintFormat("%s:", aarch32::CpuContext::RegisterNameStrings[i + (aarch32::RegisterName_GeneralPurposeCount / 2)]); font::SetPosition(pc_x + 47, font::GetY()); - if (this->context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i + (aarch32::RegisterName_GeneralPurposeCount / 2)))) { - font::PrintMonospaceU32(this->context->cpu_ctx.aarch32_ctx.r[i + (aarch32::RegisterName_GeneralPurposeCount / 2)]); + if (m_context->cpu_ctx.aarch32_ctx.HasRegisterValue(static_cast(i + (aarch32::RegisterName_GeneralPurposeCount / 2)))) { + font::PrintMonospaceU32(m_context->cpu_ctx.aarch32_ctx.r[i + (aarch32::RegisterName_GeneralPurposeCount / 2)]); font::PrintMonospaceBlank(8); } else { font::PrintMonospaceBlank(16); @@ -303,8 +303,8 @@ namespace ams::fatal::srv { u32 x = font::GetX(); font::PrintFormat("%s:", aarch64::CpuContext::RegisterNameStrings[i]); font::SetPosition(x + 47, font::GetY()); - if (this->context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i))) { - font::PrintMonospaceU64(this->context->cpu_ctx.aarch64_ctx.x[i]); + if (m_context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i))) { + font::PrintMonospaceU64(m_context->cpu_ctx.aarch64_ctx.x[i]); } else { font::PrintMonospaceBlank(16); } @@ -312,8 +312,8 @@ namespace ams::fatal::srv { pc_x = font::GetX(); font::PrintFormat("%s:", aarch64::CpuContext::RegisterNameStrings[i + (aarch64::RegisterName_GeneralPurposeCount / 2)]); font::SetPosition(pc_x + 47, font::GetY()); - if (this->context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i + (aarch64::RegisterName_GeneralPurposeCount / 2)))) { - font::PrintMonospaceU64(this->context->cpu_ctx.aarch64_ctx.x[i + (aarch64::RegisterName_GeneralPurposeCount / 2)]); + if (m_context->cpu_ctx.aarch64_ctx.HasRegisterValue(static_cast(i + (aarch64::RegisterName_GeneralPurposeCount / 2)))) { + font::PrintMonospaceU64(m_context->cpu_ctx.aarch64_ctx.x[i + (aarch64::RegisterName_GeneralPurposeCount / 2)]); } else { font::PrintMonospaceBlank(16); } @@ -336,17 +336,17 @@ namespace ams::fatal::srv { font::SetPosition(x + 47, font::GetY()); } if (is_aarch32) { - font::PrintMonospaceU32(this->context->cpu_ctx.aarch32_ctx.pc); + font::PrintMonospaceU32(m_context->cpu_ctx.aarch32_ctx.pc); } else { - font::PrintMonospaceU64(this->context->cpu_ctx.aarch64_ctx.pc); + font::PrintMonospaceU64(m_context->cpu_ctx.aarch64_ctx.pc); } /* Print Backtrace. */ u32 bt_size; if (is_aarch32) { - bt_size = this->context->cpu_ctx.aarch32_ctx.stack_trace_size; + bt_size = m_context->cpu_ctx.aarch32_ctx.stack_trace_size; } else { - bt_size = this->context->cpu_ctx.aarch64_ctx.stack_trace_size; + bt_size = m_context->cpu_ctx.aarch64_ctx.stack_trace_size; } @@ -354,29 +354,29 @@ namespace ams::fatal::srv { if (bt_size == 0) { if (is_aarch32) { font::Print("Start Address: "); - font::PrintMonospaceU32(this->context->cpu_ctx.aarch32_ctx.base_address); + font::PrintMonospaceU32(m_context->cpu_ctx.aarch32_ctx.base_address); font::PrintLine(""); } else { font::Print("Start Address: "); - font::PrintMonospaceU64(this->context->cpu_ctx.aarch64_ctx.base_address); + font::PrintMonospaceU64(m_context->cpu_ctx.aarch64_ctx.base_address); font::PrintLine(""); } } else { if (is_aarch32) { font::Print("Backtrace - Start Address: "); - font::PrintMonospaceU32(this->context->cpu_ctx.aarch32_ctx.base_address); + font::PrintMonospaceU32(m_context->cpu_ctx.aarch32_ctx.base_address); font::PrintLine(""); font::AddSpacingLines(0.5f); for (u32 i = 0; i < aarch32::CpuContext::MaxStackTraceDepth / 2; i++) { u32 bt_cur = 0, bt_next = 0; - if (i < this->context->cpu_ctx.aarch32_ctx.stack_trace_size) { - bt_cur = this->context->cpu_ctx.aarch32_ctx.stack_trace[i]; + if (i < m_context->cpu_ctx.aarch32_ctx.stack_trace_size) { + bt_cur = m_context->cpu_ctx.aarch32_ctx.stack_trace[i]; } - if (i + aarch32::CpuContext::MaxStackTraceDepth / 2 < this->context->cpu_ctx.aarch32_ctx.stack_trace_size) { - bt_next = this->context->cpu_ctx.aarch32_ctx.stack_trace[i + aarch32::CpuContext::MaxStackTraceDepth / 2]; + if (i + aarch32::CpuContext::MaxStackTraceDepth / 2 < m_context->cpu_ctx.aarch32_ctx.stack_trace_size) { + bt_next = m_context->cpu_ctx.aarch32_ctx.stack_trace[i + aarch32::CpuContext::MaxStackTraceDepth / 2]; } - if (i < this->context->cpu_ctx.aarch32_ctx.stack_trace_size) { + if (i < m_context->cpu_ctx.aarch32_ctx.stack_trace_size) { u32 x = font::GetX(); font::PrintFormat("BT[%02d]: ", i); font::SetPosition(x + 72, font::GetY()); @@ -385,7 +385,7 @@ namespace ams::fatal::srv { font::Print(" "); } - if (i + aarch32::CpuContext::MaxStackTraceDepth / 2 < this->context->cpu_ctx.aarch32_ctx.stack_trace_size) { + if (i + aarch32::CpuContext::MaxStackTraceDepth / 2 < m_context->cpu_ctx.aarch32_ctx.stack_trace_size) { u32 x = font::GetX(); font::PrintFormat("BT[%02d]: ", i + aarch32::CpuContext::MaxStackTraceDepth / 2); font::SetPosition(x + 72, font::GetY()); @@ -398,19 +398,19 @@ namespace ams::fatal::srv { } } else { font::Print("Backtrace - Start Address: "); - font::PrintMonospaceU64(this->context->cpu_ctx.aarch64_ctx.base_address); + font::PrintMonospaceU64(m_context->cpu_ctx.aarch64_ctx.base_address); font::PrintLine(""); font::AddSpacingLines(0.5f); for (u32 i = 0; i < aarch64::CpuContext::MaxStackTraceDepth / 2; i++) { u64 bt_cur = 0, bt_next = 0; - if (i < this->context->cpu_ctx.aarch64_ctx.stack_trace_size) { - bt_cur = this->context->cpu_ctx.aarch64_ctx.stack_trace[i]; + if (i < m_context->cpu_ctx.aarch64_ctx.stack_trace_size) { + bt_cur = m_context->cpu_ctx.aarch64_ctx.stack_trace[i]; } - if (i + aarch64::CpuContext::MaxStackTraceDepth / 2 < this->context->cpu_ctx.aarch64_ctx.stack_trace_size) { - bt_next = this->context->cpu_ctx.aarch64_ctx.stack_trace[i + aarch64::CpuContext::MaxStackTraceDepth / 2]; + if (i + aarch64::CpuContext::MaxStackTraceDepth / 2 < m_context->cpu_ctx.aarch64_ctx.stack_trace_size) { + bt_next = m_context->cpu_ctx.aarch64_ctx.stack_trace[i + aarch64::CpuContext::MaxStackTraceDepth / 2]; } - if (i < this->context->cpu_ctx.aarch64_ctx.stack_trace_size) { + if (i < m_context->cpu_ctx.aarch64_ctx.stack_trace_size) { u32 x = font::GetX(); font::PrintFormat("BT[%02d]: ", i); font::SetPosition(x + 72, font::GetY()); @@ -418,7 +418,7 @@ namespace ams::fatal::srv { font::Print(" "); } - if (i + aarch64::CpuContext::MaxStackTraceDepth / 2 < this->context->cpu_ctx.aarch64_ctx.stack_trace_size) { + if (i + aarch64::CpuContext::MaxStackTraceDepth / 2 < m_context->cpu_ctx.aarch64_ctx.stack_trace_size) { u32 x = font::GetX(); font::PrintFormat("BT[%02d]: ", i + aarch64::CpuContext::MaxStackTraceDepth / 2); font::SetPosition(x + 72, font::GetY()); @@ -439,7 +439,7 @@ namespace ams::fatal::srv { R_TRY(nvFenceInit()); /* Create nvmap. */ - R_TRY(nvMapCreate(std::addressof(this->map), g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true)); + R_TRY(nvMapCreate(std::addressof(m_map), g_framebuffer_memory, sizeof(g_framebuffer_memory), 0x20000, NvKind_Pitch, true)); /* Setup graphics buffer. */ { @@ -458,14 +458,14 @@ namespace ams::fatal::srv { grbuf.planes[0].layout = NvLayout_BlockLinear; grbuf.planes[0].kind = NvKind_Generic_16BX2; grbuf.planes[0].block_height_log2 = 4; - grbuf.nvmap_id = nvMapGetId(std::addressof(this->map)); + grbuf.nvmap_id = nvMapGetId(std::addressof(m_map)); grbuf.stride = FatalScreenWidthAligned; grbuf.total_size = sizeof(g_framebuffer_memory); grbuf.planes[0].pitch = FatalScreenWidthAlignedBytes; grbuf.planes[0].size = sizeof(g_framebuffer_memory); grbuf.planes[0].offset = 0; - R_TRY(nwindowConfigureBuffer(std::addressof(this->win), 0, std::addressof(grbuf))); + R_TRY(nwindowConfigureBuffer(std::addressof(m_win), 0, std::addressof(grbuf))); } return ResultSuccess(); @@ -473,9 +473,9 @@ namespace ams::fatal::srv { void ShowFatalTask::DisplayPreRenderedFrame() { s32 slot; - R_ABORT_UNLESS(nwindowDequeueBuffer(std::addressof(this->win), std::addressof(slot), nullptr)); + R_ABORT_UNLESS(nwindowDequeueBuffer(std::addressof(m_win), std::addressof(slot), nullptr)); dd::FlushDataCache(g_framebuffer_memory, sizeof(g_framebuffer_memory)); - R_ABORT_UNLESS(nwindowQueueBuffer(std::addressof(this->win), this->win.cur_slot, NULL)); + R_ABORT_UNLESS(nwindowQueueBuffer(std::addressof(m_win), m_win.cur_slot, NULL)); } Result ShowFatalTask::ShowFatal() { @@ -493,7 +493,7 @@ namespace ams::fatal::srv { Result ShowFatalTask::Run() { /* Don't show the fatal error screen until we've verified the battery is okay. */ - this->context->battery_event->Wait(); + m_context->battery_event->Wait(); return ShowFatal(); } diff --git a/stratosphere/loader/source/ldr_capabilities.cpp b/stratosphere/loader/source/ldr_capabilities.cpp index 91b4c0e82..f66db3fd8 100644 --- a/stratosphere/loader/source/ldr_capabilities.cpp +++ b/stratosphere/loader/source/ldr_capabilities.cpp @@ -59,15 +59,15 @@ namespace ams::ldr::caps { using IdBits = CapabilityField<0, static_cast(Id) + 1>; \ static constexpr u32 IdBitsValue = (static_cast(1) << static_cast(Id)) - 1; \ private: \ - util::BitPack32 value; \ + util::BitPack32 m_value; \ private: \ template \ - constexpr ALWAYS_INLINE typename FieldType::Type Get() const { return this->value.Get(); } \ + constexpr ALWAYS_INLINE typename FieldType::Type Get() const { return m_value.Get(); } \ template \ - constexpr ALWAYS_INLINE void Set(typename FieldType::Type fv) { this->value.Set(fv); } \ - constexpr ALWAYS_INLINE u32 GetValue() const { return this->value.value; } \ + constexpr ALWAYS_INLINE void Set(typename FieldType::Type fv) { m_value.Set(fv); } \ + constexpr ALWAYS_INLINE u32 GetValue() const { return m_value.value; } \ public: \ - constexpr ALWAYS_INLINE CAPABILITY_CLASS_NAME(id)(util::BitPack32 v) : value{v} { /* ... */ } \ + constexpr ALWAYS_INLINE CAPABILITY_CLASS_NAME(id)(util::BitPack32 v) : m_value{v} { /* ... */ } \ \ static constexpr CAPABILITY_CLASS_NAME(id) Decode(util::BitPack32 v) { return CAPABILITY_CLASS_NAME(id)(v); } \ \ diff --git a/stratosphere/loader/source/ldr_content_management.cpp b/stratosphere/loader/source/ldr_content_management.cpp index caab422b8..163970541 100644 --- a/stratosphere/loader/source/ldr_content_management.cpp +++ b/stratosphere/loader/source/ldr_content_management.cpp @@ -25,23 +25,23 @@ namespace ams::ldr { } /* ScopedCodeMount functionality. */ - ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc) : lk(g_scoped_code_mount_lock), has_status(false), mounted_ams(false), mounted_sd_or_code(false), mounted_code(false) { - this->result = this->Initialize(loc); + ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc) : m_lk(g_scoped_code_mount_lock), m_has_status(false), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { + m_result = this->Initialize(loc); } - ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o) : lk(g_scoped_code_mount_lock), override_status(o), has_status(true), mounted_ams(false), mounted_sd_or_code(false), mounted_code(false) { - this->result = this->Initialize(loc); + ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o) : m_lk(g_scoped_code_mount_lock), m_override_status(o), m_has_status(true), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) { + m_result = this->Initialize(loc); } ScopedCodeMount::~ScopedCodeMount() { /* Unmount filesystems. */ - if (this->mounted_ams) { + if (m_mounted_ams) { fs::Unmount(AtmosphereCodeMountName); } - if (this->mounted_sd_or_code) { + if (m_mounted_sd_or_code) { fs::Unmount(SdOrCodeMountName); } - if (this->mounted_code) { + if (m_mounted_code) { fs::Unmount(CodeMountName); } } @@ -49,7 +49,7 @@ namespace ams::ldr { Result ScopedCodeMount::Initialize(const ncm::ProgramLocation &loc) { /* Capture override status, if necessary. */ this->EnsureOverrideStatus(loc); - AMS_ABORT_UNLESS(this->has_status); + AMS_ABORT_UNLESS(m_has_status); /* Get the content path. */ char content_path[fs::EntryNameLengthMax + 1] = "/"; @@ -58,27 +58,27 @@ namespace ams::ldr { } /* Mount the atmosphere code file system. */ - R_TRY(fs::MountCodeForAtmosphereWithRedirection(std::addressof(this->ams_code_verification_data), AtmosphereCodeMountName, content_path, loc.program_id, this->override_status.IsHbl(), this->override_status.IsProgramSpecific())); - this->mounted_ams = true; + R_TRY(fs::MountCodeForAtmosphereWithRedirection(std::addressof(m_ams_code_verification_data), AtmosphereCodeMountName, content_path, loc.program_id, m_override_status.IsHbl(), m_override_status.IsProgramSpecific())); + m_mounted_ams = true; /* Mount the sd or base code file system. */ - R_TRY(fs::MountCodeForAtmosphere(std::addressof(this->sd_or_base_code_verification_data), SdOrCodeMountName, content_path, loc.program_id)); - this->mounted_sd_or_code = true; + R_TRY(fs::MountCodeForAtmosphere(std::addressof(m_sd_or_base_code_verification_data), SdOrCodeMountName, content_path, loc.program_id)); + m_mounted_sd_or_code = true; /* Mount the base code file system. */ - if (R_SUCCEEDED(fs::MountCode(std::addressof(this->base_code_verification_data), CodeMountName, content_path, loc.program_id))) { - this->mounted_code = true; + if (R_SUCCEEDED(fs::MountCode(std::addressof(m_base_code_verification_data), CodeMountName, content_path, loc.program_id))) { + m_mounted_code = true; } return ResultSuccess(); } void ScopedCodeMount::EnsureOverrideStatus(const ncm::ProgramLocation &loc) { - if (this->has_status) { + if (m_has_status) { return; } - this->override_status = cfg::CaptureOverrideStatus(loc.program_id); - this->has_status = true; + m_override_status = cfg::CaptureOverrideStatus(loc.program_id); + m_has_status = true; } /* Redirection API. */ diff --git a/stratosphere/loader/source/ldr_content_management.hpp b/stratosphere/loader/source/ldr_content_management.hpp index d6b802011..590992ff5 100644 --- a/stratosphere/loader/source/ldr_content_management.hpp +++ b/stratosphere/loader/source/ldr_content_management.hpp @@ -23,40 +23,40 @@ namespace ams::ldr { NON_COPYABLE(ScopedCodeMount); NON_MOVEABLE(ScopedCodeMount); private: - std::scoped_lock lk; - cfg::OverrideStatus override_status; - fs::CodeVerificationData ams_code_verification_data; - fs::CodeVerificationData sd_or_base_code_verification_data; - fs::CodeVerificationData base_code_verification_data; - Result result; - bool has_status; - bool mounted_ams; - bool mounted_sd_or_code; - bool mounted_code; + std::scoped_lock m_lk; + cfg::OverrideStatus m_override_status; + fs::CodeVerificationData m_ams_code_verification_data; + fs::CodeVerificationData m_sd_or_base_code_verification_data; + fs::CodeVerificationData m_base_code_verification_data; + Result m_result; + bool m_has_status; + bool m_mounted_ams; + bool m_mounted_sd_or_code; + bool m_mounted_code; public: ScopedCodeMount(const ncm::ProgramLocation &loc); ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status); ~ScopedCodeMount(); Result GetResult() const { - return this->result; + return m_result; } const cfg::OverrideStatus &GetOverrideStatus() const { - AMS_ABORT_UNLESS(this->has_status); - return this->override_status; + AMS_ABORT_UNLESS(m_has_status); + return m_override_status; } const fs::CodeVerificationData &GetAtmosphereCodeVerificationData() const { - return this->ams_code_verification_data; + return m_ams_code_verification_data; } const fs::CodeVerificationData &GetSdOrBaseCodeVerificationData() const { - return this->sd_or_base_code_verification_data; + return m_sd_or_base_code_verification_data; } const fs::CodeVerificationData &GetCodeVerificationData() const { - return this->base_code_verification_data; + return m_base_code_verification_data; } private: Result Initialize(const ncm::ProgramLocation &loc); diff --git a/stratosphere/pm/source/impl/pm_process_info.cpp b/stratosphere/pm/source/impl/pm_process_info.cpp index ec1e257e8..a867cac5b 100644 --- a/stratosphere/pm/source/impl/pm_process_info.cpp +++ b/stratosphere/pm/source/impl/pm_process_info.cpp @@ -18,9 +18,9 @@ namespace ams::pm::impl { - ProcessInfo::ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s) : process_id(pid), pin_id(pin), loc(l), status(s), handle(h), state(svc::ProcessState_Created), flags(0) { - os::InitializeMultiWaitHolder(std::addressof(this->multi_wait_holder), this->handle); - os::SetMultiWaitHolderUserData(std::addressof(this->multi_wait_holder), reinterpret_cast(this)); + ProcessInfo::ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s) : m_process_id(pid), m_pin_id(pin), m_loc(l), m_status(s), m_handle(h), m_state(svc::ProcessState_Created), m_flags(0) { + os::InitializeMultiWaitHolder(std::addressof(m_multi_wait_holder), m_handle); + os::SetMultiWaitHolderUserData(std::addressof(m_multi_wait_holder), reinterpret_cast(this)); } ProcessInfo::~ProcessInfo() { @@ -28,18 +28,18 @@ namespace ams::pm::impl { } void ProcessInfo::Cleanup() { - if (this->handle != os::InvalidNativeHandle) { + if (m_handle != os::InvalidNativeHandle) { /* Unregister the process. */ - fsprUnregisterProgram(this->process_id.value); - sm::manager::UnregisterProcess(this->process_id); - ldr::pm::UnpinProgram(this->pin_id); + fsprUnregisterProgram(m_process_id.value); + sm::manager::UnregisterProcess(m_process_id); + ldr::pm::UnpinProgram(m_pin_id); /* Close the process's handle. */ - os::CloseNativeHandle(this->handle); - this->handle = os::InvalidNativeHandle; + os::CloseNativeHandle(m_handle); + m_handle = os::InvalidNativeHandle; /* Unlink the process from its multi wait. */ - os::UnlinkMultiWaitHolder(std::addressof(this->multi_wait_holder)); + os::UnlinkMultiWaitHolder(std::addressof(m_multi_wait_holder)); } } diff --git a/stratosphere/pm/source/impl/pm_process_info.hpp b/stratosphere/pm/source/impl/pm_process_info.hpp index 527035408..f89403767 100644 --- a/stratosphere/pm/source/impl/pm_process_info.hpp +++ b/stratosphere/pm/source/impl/pm_process_info.hpp @@ -38,26 +38,26 @@ namespace ams::pm::impl { Flag_UnhandledException = (1 << 9), }; private: - util::IntrusiveListNode list_node; - const os::ProcessId process_id; - const ldr::PinId pin_id; - const ncm::ProgramLocation loc; - const cfg::OverrideStatus status; - os::NativeHandle handle; - svc::ProcessState state; - u32 flags; - os::MultiWaitHolderType multi_wait_holder; + util::IntrusiveListNode m_list_node; + const os::ProcessId m_process_id; + const ldr::PinId m_pin_id; + const ncm::ProgramLocation m_loc; + const cfg::OverrideStatus m_status; + os::NativeHandle m_handle; + svc::ProcessState m_state; + u32 m_flags; + os::MultiWaitHolderType m_multi_wait_holder; private: void SetFlag(Flag flag) { - this->flags |= flag; + m_flags |= flag; } void ClearFlag(Flag flag) { - this->flags &= ~flag; + m_flags &= ~flag; } bool HasFlag(Flag flag) const { - return (this->flags & flag); + return (m_flags & flag); } public: ProcessInfo(os::NativeHandle h, os::ProcessId pid, ldr::PinId pin, const ncm::ProgramLocation &l, const cfg::OverrideStatus &s); @@ -65,43 +65,43 @@ namespace ams::pm::impl { void Cleanup(); void LinkToMultiWait(os::MultiWaitType &multi_wait) { - os::LinkMultiWaitHolder(std::addressof(multi_wait), std::addressof(this->multi_wait_holder)); + os::LinkMultiWaitHolder(std::addressof(multi_wait), std::addressof(m_multi_wait_holder)); } os::NativeHandle GetHandle() const { - return this->handle; + return m_handle; } os::ProcessId GetProcessId() const { - return this->process_id; + return m_process_id; } ldr::PinId GetPinId() const { - return this->pin_id; + return m_pin_id; } const ncm::ProgramLocation &GetProgramLocation() const { - return this->loc; + return m_loc; } const cfg::OverrideStatus &GetOverrideStatus() const { - return this->status; + return m_status; } svc::ProcessState GetState() const { - return this->state; + return m_state; } void SetState(svc::ProcessState state) { - this->state = state; + m_state = state; } bool HasStarted() const { - return this->state != svc::ProcessState_Created && this->state != svc::ProcessState_CreatedAttached; + return m_state != svc::ProcessState_Created && m_state != svc::ProcessState_CreatedAttached; } bool HasTerminated() const { - return this->state == svc::ProcessState_Terminated; + return m_state == svc::ProcessState_Terminated; } #define DEFINE_FLAG_SET(flag) \ @@ -165,18 +165,18 @@ namespace ams::pm::impl { #undef DEFINE_FLAG_CLEAR }; - class ProcessList final : public util::IntrusiveListMemberTraits<&ProcessInfo::list_node>::ListType { + class ProcessList final : public util::IntrusiveListMemberTraits<&ProcessInfo::m_list_node>::ListType { private: - os::SdkMutex lock; + os::SdkMutex m_lock; public: - constexpr ProcessList() : lock() { /* ... */ } + constexpr ProcessList() : m_lock() { /* ... */ } void Lock() { - this->lock.Lock(); + m_lock.Lock(); } void Unlock() { - this->lock.Unlock(); + m_lock.Unlock(); } void Remove(ProcessInfo *process_info) { @@ -184,18 +184,18 @@ namespace ams::pm::impl { } ProcessInfo *Find(os::ProcessId process_id) { - for (auto it = this->begin(); it != this->end(); it++) { - if ((*it).GetProcessId() == process_id) { - return std::addressof(*it); + for (auto &info : *this) { + if (info.GetProcessId() == process_id) { + return std::addressof(info); } } return nullptr; } ProcessInfo *Find(ncm::ProgramId program_id) { - for (auto it = this->begin(); it != this->end(); it++) { - if ((*it).GetProgramLocation().program_id == program_id) { - return std::addressof(*it); + for (auto &info : *this) { + if (info.GetProgramLocation().program_id == program_id) { + return std::addressof(info); } } return nullptr; @@ -205,30 +205,30 @@ namespace ams::pm::impl { class ProcessListAccessor final { private: - ProcessList &list; + ProcessList &m_list; public: - explicit ProcessListAccessor(ProcessList &l) : list(l) { - this->list.Lock(); + explicit ProcessListAccessor(ProcessList &l) : m_list(l) { + m_list.Lock(); } ~ProcessListAccessor() { - this->list.Unlock(); + m_list.Unlock(); } ProcessList *operator->() { - return std::addressof(this->list); + return std::addressof(m_list); } const ProcessList *operator->() const { - return std::addressof(this->list); + return std::addressof(m_list); } ProcessList &operator*() { - return this->list; + return m_list; } const ProcessList &operator*() const { - return this->list; + return m_list; } }; diff --git a/stratosphere/pm/source/impl/pm_process_manager.cpp b/stratosphere/pm/source/impl/pm_process_manager.cpp index eed499c78..329ee7fcc 100644 --- a/stratosphere/pm/source/impl/pm_process_manager.cpp +++ b/stratosphere/pm/source/impl/pm_process_manager.cpp @@ -78,27 +78,27 @@ namespace ams::pm::impl { NON_MOVEABLE(ProcessInfoAllocator); static_assert(MaxProcessInfos >= 0x40, "MaxProcessInfos is too small."); private: - util::TypedStorage process_info_storages[MaxProcessInfos]{}; - bool process_info_allocated[MaxProcessInfos]{}; - os::SdkMutex lock{}; + util::TypedStorage m_process_info_storages[MaxProcessInfos]{}; + bool m_process_info_allocated[MaxProcessInfos]{}; + os::SdkMutex m_lock{}; private: constexpr inline size_t GetProcessInfoIndex(ProcessInfo *process_info) const { - return process_info - GetPointer(this->process_info_storages[0]); + return process_info - GetPointer(m_process_info_storages[0]); } public: constexpr ProcessInfoAllocator() = default; template ProcessInfo *AllocateProcessInfo(Args &&... args) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); for (size_t i = 0; i < MaxProcessInfos; i++) { - if (!this->process_info_allocated[i]) { - this->process_info_allocated[i] = true; + if (!m_process_info_allocated[i]) { + m_process_info_allocated[i] = true; - std::memset(this->process_info_storages + i, 0, sizeof(this->process_info_storages[i])); + std::memset(m_process_info_storages + i, 0, sizeof(m_process_info_storages[i])); - return util::ConstructAt(this->process_info_storages[i], std::forward(args)...); + return util::ConstructAt(m_process_info_storages[i], std::forward(args)...); } } @@ -106,14 +106,14 @@ namespace ams::pm::impl { } void FreeProcessInfo(ProcessInfo *process_info) { - std::scoped_lock lk(this->lock); + std::scoped_lock lk(m_lock); const size_t index = this->GetProcessInfoIndex(process_info); AMS_ABORT_UNLESS(index < MaxProcessInfos); - AMS_ABORT_UNLESS(this->process_info_allocated[index]); + AMS_ABORT_UNLESS(m_process_info_allocated[index]); - util::DestroyAt(this->process_info_storages[index]); - this->process_info_allocated[index] = false; + util::DestroyAt(m_process_info_storages[index]); + m_process_info_allocated[index] = false; } }; diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index 1e9c343b5..3604c51bc 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -74,206 +74,277 @@ namespace ams::ro::impl { }; struct ProcessContext { - bool nro_in_use[MaxNroInfos]; - bool nrr_in_use[MaxNrrInfos]; - NroInfo nro_infos[MaxNroInfos]; - NrrInfo nrr_infos[MaxNrrInfos]; - os::NativeHandle process_handle; - os::ProcessId process_id; - bool in_use; + private: + bool m_nro_in_use[MaxNroInfos]{}; + bool m_nrr_in_use[MaxNrrInfos]{}; + NroInfo m_nro_infos[MaxNroInfos]{}; + NrrInfo m_nrr_infos[MaxNrrInfos]{}; + os::NativeHandle m_process_handle = os::InvalidNativeHandle; + os::ProcessId m_process_id = os::InvalidProcessId; + bool m_in_use{}; + public: + constexpr ProcessContext() = default; - ncm::ProgramId GetProgramId(os::NativeHandle other_process_h) const { - /* Automatically select a handle, allowing for override. */ - if (other_process_h != os::InvalidNativeHandle) { - return os::GetProgramId(other_process_h); - } else { - return os::GetProgramId(this->process_handle); + void Initialize(os::NativeHandle process_handle, os::ProcessId process_id) { + AMS_ABORT_UNLESS(!m_in_use); + + std::memset(m_nro_in_use, 0, sizeof(m_nro_in_use)); + std::memset(m_nrr_in_use, 0, sizeof(m_nrr_in_use)); + std::memset(m_nro_infos, 0, sizeof(m_nro_infos)); + std::memset(m_nrr_infos, 0, sizeof(m_nrr_infos)); + + m_process_handle = process_handle; + m_process_id = process_id; + m_in_use = true; } - } - Result GetNrrInfoByAddress(NrrInfo **out, u64 nrr_heap_address) { - for (size_t i = 0; i < MaxNrrInfos; i++) { - if (this->nrr_in_use[i] && this->nrr_infos[i].nrr_heap_address == nrr_heap_address) { - if (out != nullptr) { - *out = this->nrr_infos + i; + void Finalize() { + AMS_ABORT_UNLESS(m_in_use); + + if (m_process_handle != os::InvalidNativeHandle) { + for (size_t i = 0; i < MaxNrrInfos; i++) { + if (m_nrr_in_use[i]) { + UnmapNrr(m_process_handle, m_nrr_infos[i].mapped_header, m_nrr_infos[i].nrr_heap_address, m_nrr_infos[i].nrr_heap_size, m_nrr_infos[i].mapped_code_address); + } } + os::CloseNativeHandle(m_process_handle); + } + + std::memset(m_nro_in_use, 0, sizeof(m_nro_in_use)); + std::memset(m_nrr_in_use, 0, sizeof(m_nrr_in_use)); + std::memset(m_nro_infos, 0, sizeof(m_nro_infos)); + std::memset(m_nrr_infos, 0, sizeof(m_nrr_infos)); + + m_process_handle = os::InvalidNativeHandle; + m_process_id = os::InvalidProcessId; + + m_in_use = false; + } + + os::NativeHandle GetProcessHandle() const { + return m_process_handle; + } + + os::ProcessId GetProcessId() const { + return m_process_id; + } + + bool IsFree() const { + return !m_in_use; + } + + ncm::ProgramId GetProgramId(os::NativeHandle other_process_h) const { + /* Automatically select a handle, allowing for override. */ + if (other_process_h != os::InvalidNativeHandle) { + return os::GetProgramId(other_process_h); + } else { + return os::GetProgramId(m_process_handle); + } + } + + Result GetNrrInfoByAddress(NrrInfo **out, u64 nrr_heap_address) { + for (size_t i = 0; i < MaxNrrInfos; i++) { + if (m_nrr_in_use[i] && m_nrr_infos[i].nrr_heap_address == nrr_heap_address) { + if (out != nullptr) { + *out = m_nrr_infos + i; + } + return ResultSuccess(); + } + } + return ro::ResultNotRegistered(); + } + + Result GetFreeNrrInfo(NrrInfo **out) { + for (size_t i = 0; i < MaxNrrInfos; i++) { + if (!m_nrr_in_use[i]) { + if (out != nullptr) { + *out = m_nrr_infos + i; + } + return ResultSuccess(); + } + } + return ro::ResultTooManyNrr(); + } + + Result GetNroInfoByAddress(NroInfo **out, u64 nro_address) { + for (size_t i = 0; i < MaxNroInfos; i++) { + if (m_nro_in_use[i] && m_nro_infos[i].base_address == nro_address) { + if (out != nullptr) { + *out = m_nro_infos + i; + } + return ResultSuccess(); + } + } + return ro::ResultNotLoaded(); + } + + Result GetNroInfoByModuleId(NroInfo **out, const ModuleId *module_id) { + for (size_t i = 0; i < MaxNroInfos; i++) { + if (m_nro_in_use[i] && std::memcmp(std::addressof(m_nro_infos[i].module_id), module_id, sizeof(*module_id)) == 0) { + if (out != nullptr) { + *out = m_nro_infos + i; + } + return ResultSuccess(); + } + } + return ro::ResultNotLoaded(); + } + + Result GetFreeNroInfo(NroInfo **out) { + for (size_t i = 0; i < MaxNroInfos; i++) { + if (!m_nro_in_use[i]) { + if (out != nullptr) { + *out = m_nro_infos + i; + } + return ResultSuccess(); + } + } + return ro::ResultTooManyNro(); + } + + Result ValidateHasNroHash(const NroHeader *nro_header) const { + /* Calculate hash. */ + Sha256Hash hash; + crypto::GenerateSha256Hash(std::addressof(hash), sizeof(hash), nro_header, nro_header->GetSize()); + + for (size_t i = 0; i < MaxNrrInfos; i++) { + /* Ensure we only check NRRs that are used. */ + if (!m_nrr_in_use[i]) { + continue; + } + + /* Get the mapped header, ensure that it has hashes. */ + const NrrHeader *mapped_nrr_header = m_nrr_infos[i].mapped_header; + const size_t mapped_num_hashes = mapped_nrr_header->GetNumHashes(); + if (mapped_num_hashes == 0) { + continue; + } + + /* Locate the hash within the mapped array. */ + const Sha256Hash *mapped_nro_hashes_start = reinterpret_cast(mapped_nrr_header->GetHashes()); + const Sha256Hash *mapped_nro_hashes_end = mapped_nro_hashes_start + mapped_nrr_header->GetNumHashes(); + + const Sha256Hash *mapped_lower_bound = std::lower_bound(mapped_nro_hashes_start, mapped_nro_hashes_end, hash); + if (mapped_lower_bound == mapped_nro_hashes_end || (*mapped_lower_bound != hash)) { + continue; + } + + /* Check that the hash entry is valid, since our heuristic passed. */ + const void *nrr_hash = std::addressof(m_nrr_infos[i].signed_area_hash); + const void *signed_area = m_nrr_infos[i].cached_signed_area; + const size_t signed_area_size = m_nrr_infos[i].cached_signed_area_size; + const size_t hashes_offset = m_nrr_infos[i].cached_hashes_offset; + const size_t num_hashes = m_nrr_infos[i].cached_num_hashes; + const u8 *hash_table = reinterpret_cast(mapped_nro_hashes_start); + if (!ValidateNrrHashTableEntry(signed_area, signed_area_size, hashes_offset, num_hashes, nrr_hash, hash_table, std::addressof(hash))) { + continue; + } + + /* The hash is valid! */ return ResultSuccess(); } + + return ro::ResultNotAuthorized(); } - return ro::ResultNotRegistered(); - } - Result GetFreeNrrInfo(NrrInfo **out) { - for (size_t i = 0; i < MaxNrrInfos; i++) { - if (!this->nrr_in_use[i]) { - if (out != nullptr) { - *out = this->nrr_infos + i; - } - return ResultSuccess(); - } - } - return ro::ResultTooManyNrr(); - } + Result ValidateNro(ModuleId *out_module_id, u64 *out_rx_size, u64 *out_ro_size, u64 *out_rw_size, u64 base_address, u64 expected_nro_size, u64 expected_bss_size) { + /* Find space to map the NRO. */ + uintptr_t map_address; + R_UNLESS(R_SUCCEEDED(SearchFreeRegion(std::addressof(map_address), expected_nro_size)), ro::ResultOutOfAddressSpace()); - Result GetNroInfoByAddress(NroInfo **out, u64 nro_address) { - for (size_t i = 0; i < MaxNroInfos; i++) { - if (this->nro_in_use[i] && this->nro_infos[i].base_address == nro_address) { - if (out != nullptr) { - *out = this->nro_infos + i; - } - return ResultSuccess(); - } - } - return ro::ResultNotLoaded(); - } + /* Actually map the NRO. */ + AutoCloseMap nro_map(map_address, m_process_handle, base_address, expected_nro_size); + R_TRY(nro_map.GetResult()); - Result GetNroInfoByModuleId(NroInfo **out, const ModuleId *module_id) { - for (size_t i = 0; i < MaxNroInfos; i++) { - if (this->nro_in_use[i] && std::memcmp(std::addressof(this->nro_infos[i].module_id), module_id, sizeof(*module_id)) == 0) { - if (out != nullptr) { - *out = this->nro_infos + i; - } - return ResultSuccess(); - } - } - return ro::ResultNotLoaded(); - } + /* Validate header. */ + const NroHeader *header = reinterpret_cast(map_address); + R_UNLESS(header->IsMagicValid(), ro::ResultInvalidNro()); - Result GetFreeNroInfo(NroInfo **out) { - for (size_t i = 0; i < MaxNroInfos; i++) { - if (!this->nro_in_use[i]) { - if (out != nullptr) { - *out = this->nro_infos + i; - } - return ResultSuccess(); - } - } - return ro::ResultTooManyNro(); - } + /* Read sizes from header. */ + const u64 nro_size = header->GetSize(); + const u64 text_ofs = header->GetTextOffset(); + const u64 text_size = header->GetTextSize(); + const u64 ro_ofs = header->GetRoOffset(); + const u64 ro_size = header->GetRoSize(); + const u64 rw_ofs = header->GetRwOffset(); + const u64 rw_size = header->GetRwSize(); + const u64 bss_size = header->GetBssSize(); - Result ValidateHasNroHash(const NroHeader *nro_header) const { - /* Calculate hash. */ - Sha256Hash hash; - crypto::GenerateSha256Hash(std::addressof(hash), sizeof(hash), nro_header, nro_header->GetSize()); + /* Validate sizes meet expected. */ + R_UNLESS(nro_size == expected_nro_size, ro::ResultInvalidNro()); + R_UNLESS(bss_size == expected_bss_size, ro::ResultInvalidNro()); - for (size_t i = 0; i < MaxNrrInfos; i++) { - /* Ensure we only check NRRs that are used. */ - if (!this->nrr_in_use[i]) { - continue; - } + /* Validate all sizes are aligned. */ + R_UNLESS(util::IsAligned(text_size, os::MemoryPageSize), ro::ResultInvalidNro()); + R_UNLESS(util::IsAligned(ro_size, os::MemoryPageSize), ro::ResultInvalidNro()); + R_UNLESS(util::IsAligned(rw_size, os::MemoryPageSize), ro::ResultInvalidNro()); + R_UNLESS(util::IsAligned(bss_size, os::MemoryPageSize), ro::ResultInvalidNro()); - /* Get the mapped header, ensure that it has hashes. */ - const NrrHeader *mapped_nrr_header = this->nrr_infos[i].mapped_header; - const size_t mapped_num_hashes = mapped_nrr_header->GetNumHashes(); - if (mapped_num_hashes == 0) { - continue; - } + /* Validate sections are in order. */ + R_UNLESS(text_ofs <= ro_ofs, ro::ResultInvalidNro()); + R_UNLESS(ro_ofs <= rw_ofs, ro::ResultInvalidNro()); - /* Locate the hash within the mapped array. */ - const Sha256Hash *mapped_nro_hashes_start = reinterpret_cast(mapped_nrr_header->GetHashes()); - const Sha256Hash *mapped_nro_hashes_end = mapped_nro_hashes_start + mapped_nrr_header->GetNumHashes(); + /* Validate sections are sequential and contiguous. */ + R_UNLESS(text_ofs == 0, ro::ResultInvalidNro()); + R_UNLESS(text_ofs + text_size == ro_ofs, ro::ResultInvalidNro()); + R_UNLESS(ro_ofs + ro_size == rw_ofs, ro::ResultInvalidNro()); + R_UNLESS(rw_ofs + rw_size == nro_size, ro::ResultInvalidNro()); - const Sha256Hash *mapped_lower_bound = std::lower_bound(mapped_nro_hashes_start, mapped_nro_hashes_end, hash); - if (mapped_lower_bound == mapped_nro_hashes_end || (*mapped_lower_bound != hash)) { - continue; - } + /* Verify NRO hash. */ + R_TRY(this->ValidateHasNroHash(header)); - /* Check that the hash entry is valid, since our heuristic passed. */ - const void *nrr_hash = std::addressof(this->nrr_infos[i].signed_area_hash); - const void *signed_area = this->nrr_infos[i].cached_signed_area; - const size_t signed_area_size = this->nrr_infos[i].cached_signed_area_size; - const size_t hashes_offset = this->nrr_infos[i].cached_hashes_offset; - const size_t num_hashes = this->nrr_infos[i].cached_num_hashes; - const u8 *hash_table = reinterpret_cast(mapped_nro_hashes_start); - if (!ValidateNrrHashTableEntry(signed_area, signed_area_size, hashes_offset, num_hashes, nrr_hash, hash_table, std::addressof(hash))) { - continue; - } + /* Check if NRO has already been loaded. */ + const ModuleId *module_id = header->GetModuleId(); + R_UNLESS(R_FAILED(this->GetNroInfoByModuleId(nullptr, module_id)), ro::ResultAlreadyLoaded()); - /* The hash is valid! */ + /* Apply patches to NRO. */ + LocateAndApplyIpsPatchesToModule(module_id, reinterpret_cast(map_address), nro_size); + + /* Copy to output. */ + *out_module_id = *module_id; + *out_rx_size = text_size; + *out_ro_size = ro_size; + *out_rw_size = rw_size; return ResultSuccess(); } - return ro::ResultNotAuthorized(); - } + void SetNrrInfoInUse(const NrrInfo *info, bool in_use) { + AMS_ASSERT(std::addressof(m_nrr_infos[0]) <= info && info <= std::addressof(m_nrr_infos[MaxNrrInfos - 1])); + const size_t index = info - std::addressof(m_nrr_infos[0]); + m_nrr_in_use[index] = in_use; + } - Result ValidateNro(ModuleId *out_module_id, u64 *out_rx_size, u64 *out_ro_size, u64 *out_rw_size, u64 base_address, u64 expected_nro_size, u64 expected_bss_size) { - /* Find space to map the NRO. */ - uintptr_t map_address; - R_UNLESS(R_SUCCEEDED(SearchFreeRegion(std::addressof(map_address), expected_nro_size)), ro::ResultOutOfAddressSpace()); + void SetNroInfoInUse(const NroInfo *info, bool in_use) { + AMS_ASSERT(std::addressof(m_nro_infos[0]) <= info && info <= std::addressof(m_nro_infos[MaxNroInfos - 1])); + const size_t index = info - std::addressof(m_nro_infos[0]); + m_nro_in_use[index] = in_use; + } - /* Actually map the NRO. */ - AutoCloseMap nro_map(map_address, this->process_handle, base_address, expected_nro_size); - R_TRY(nro_map.GetResult()); + void GetProcessModuleInfo(u32 *out_count, LoaderModuleInfo *out_infos, size_t max_out_count) const { + size_t count = 0; - /* Validate header. */ - const NroHeader *header = reinterpret_cast(map_address); - R_UNLESS(header->IsMagicValid(), ro::ResultInvalidNro()); + for (size_t i = 0; i < MaxNroInfos && count < max_out_count; i++) { + if (!m_nro_in_use[i]) { + continue; + } - /* Read sizes from header. */ - const u64 nro_size = header->GetSize(); - const u64 text_ofs = header->GetTextOffset(); - const u64 text_size = header->GetTextSize(); - const u64 ro_ofs = header->GetRoOffset(); - const u64 ro_size = header->GetRoSize(); - const u64 rw_ofs = header->GetRwOffset(); - const u64 rw_size = header->GetRwSize(); - const u64 bss_size = header->GetBssSize(); + const NroInfo *nro_info = m_nro_infos + i; - /* Validate sizes meet expected. */ - R_UNLESS(nro_size == expected_nro_size, ro::ResultInvalidNro()); - R_UNLESS(bss_size == expected_bss_size, ro::ResultInvalidNro()); + /* Just copy out the info. */ + LoaderModuleInfo *out_info = std::addressof(out_infos[count++]); + memcpy(out_info->build_id, std::addressof(nro_info->module_id), sizeof(nro_info->module_id)); + out_info->base_address = nro_info->base_address; + out_info->size = nro_info->nro_heap_size + nro_info->bss_heap_size; + } - /* Validate all sizes are aligned. */ - R_UNLESS(util::IsAligned(text_size, os::MemoryPageSize), ro::ResultInvalidNro()); - R_UNLESS(util::IsAligned(ro_size, os::MemoryPageSize), ro::ResultInvalidNro()); - R_UNLESS(util::IsAligned(rw_size, os::MemoryPageSize), ro::ResultInvalidNro()); - R_UNLESS(util::IsAligned(bss_size, os::MemoryPageSize), ro::ResultInvalidNro()); - - /* Validate sections are in order. */ - R_UNLESS(text_ofs <= ro_ofs, ro::ResultInvalidNro()); - R_UNLESS(ro_ofs <= rw_ofs, ro::ResultInvalidNro()); - - /* Validate sections are sequential and contiguous. */ - R_UNLESS(text_ofs == 0, ro::ResultInvalidNro()); - R_UNLESS(text_ofs + text_size == ro_ofs, ro::ResultInvalidNro()); - R_UNLESS(ro_ofs + ro_size == rw_ofs, ro::ResultInvalidNro()); - R_UNLESS(rw_ofs + rw_size == nro_size, ro::ResultInvalidNro()); - - /* Verify NRO hash. */ - R_TRY(this->ValidateHasNroHash(header)); - - /* Check if NRO has already been loaded. */ - const ModuleId *module_id = header->GetModuleId(); - R_UNLESS(R_FAILED(this->GetNroInfoByModuleId(nullptr, module_id)), ro::ResultAlreadyLoaded()); - - /* Apply patches to NRO. */ - LocateAndApplyIpsPatchesToModule(module_id, reinterpret_cast(map_address), nro_size); - - /* Copy to output. */ - *out_module_id = *module_id; - *out_rx_size = text_size; - *out_ro_size = ro_size; - *out_rw_size = rw_size; - return ResultSuccess(); - } - - void SetNrrInfoInUse(const NrrInfo *info, bool in_use) { - AMS_ASSERT(std::addressof(this->nrr_infos[0]) <= info && info <= std::addressof(this->nrr_infos[MaxNrrInfos - 1])); - const size_t index = info - std::addressof(this->nrr_infos[0]); - this->nrr_in_use[index] = in_use; - } - - void SetNroInfoInUse(const NroInfo *info, bool in_use) { - AMS_ASSERT(std::addressof(this->nro_infos[0]) <= info && info <= std::addressof(this->nro_infos[MaxNroInfos - 1])); - const size_t index = info - std::addressof(this->nro_infos[0]); - this->nro_in_use[index] = in_use; - } + *out_count = static_cast(count); + } }; /* Globals. */ - ProcessContext g_process_contexts[MaxSessions] = {}; - bool g_is_development_hardware = false; - bool g_is_development_function_enabled = false; + constinit ProcessContext g_process_contexts[MaxSessions] = {}; + constinit bool g_is_development_hardware = false; + constinit bool g_is_development_function_enabled = false; /* Context Helpers. */ ProcessContext *GetContextById(size_t context_id) { @@ -287,7 +358,7 @@ namespace ams::ro::impl { ProcessContext *GetContextByProcessId(os::ProcessId process_id) { for (size_t i = 0; i < MaxSessions; i++) { - if (g_process_contexts[i].process_id == process_id) { + if (g_process_contexts[i].GetProcessId() == process_id) { return g_process_contexts + i; } } @@ -299,11 +370,8 @@ namespace ams::ro::impl { for (size_t i = 0; i < MaxSessions; i++) { ProcessContext *context = g_process_contexts + i; - if (!context->in_use) { - std::memset(context, 0, sizeof(*context)); - context->process_id = process_id; - context->process_handle = process_handle; - context->in_use = true; + if (context->IsFree()) { + context->Initialize(process_handle, process_id); return i; } } @@ -312,18 +380,8 @@ namespace ams::ro::impl { } void FreeContext(size_t context_id) { - ProcessContext *context = GetContextById(context_id); - if (context != nullptr) { - if (context->process_handle != os::InvalidNativeHandle) { - for (size_t i = 0; i < MaxNrrInfos; i++) { - if (context->nrr_in_use[i]) { - UnmapNrr(context->process_handle, context->nrr_infos[i].mapped_header, context->nrr_infos[i].nrr_heap_address, context->nrr_infos[i].nrr_heap_size, context->nrr_infos[i].mapped_code_address); - } - } - os::CloseNativeHandle(context->process_handle); - } - std::memset(context, 0, sizeof(*context)); - context->in_use = false; + if (ProcessContext *context = GetContextById(context_id); context != nullptr) { + context->Finalize(); } } @@ -397,8 +455,8 @@ namespace ams::ro::impl { Result ValidateProcess(size_t context_id, os::ProcessId process_id) { const ProcessContext *ctx = GetContextById(context_id); - R_UNLESS(ctx != nullptr, ro::ResultInvalidProcess()); - R_UNLESS(ctx->process_id == process_id, ro::ResultInvalidProcess()); + R_UNLESS(ctx != nullptr, ro::ResultInvalidProcess()); + R_UNLESS(ctx->GetProcessId() == process_id, ro::ResultInvalidProcess()); return ResultSuccess(); } @@ -429,7 +487,7 @@ namespace ams::ro::impl { /* Map. */ NrrHeader *header = nullptr; u64 mapped_code_address = 0; - R_TRY(MapAndValidateNrr(std::addressof(header), std::addressof(mapped_code_address), std::addressof(signed_area_hash), sizeof(signed_area_hash), context->process_handle, program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind)); + R_TRY(MapAndValidateNrr(std::addressof(header), std::addressof(mapped_code_address), std::addressof(signed_area_hash), sizeof(signed_area_hash), context->GetProcessHandle(), program_id, nrr_address, nrr_size, nrr_kind, enforce_nrr_kind)); /* Set NRR info. */ context->SetNrrInfoInUse(nrr_info, true); @@ -467,7 +525,7 @@ namespace ams::ro::impl { context->SetNrrInfoInUse(nrr_info, false); std::memset(nrr_info, 0, sizeof(*nrr_info)); } - return UnmapNrr(context->process_handle, nrr_backup.mapped_header, nrr_backup.nrr_heap_address, nrr_backup.nrr_heap_size, nrr_backup.mapped_code_address); + return UnmapNrr(context->GetProcessHandle(), nrr_backup.mapped_header, nrr_backup.nrr_heap_address, nrr_backup.nrr_heap_size, nrr_backup.mapped_code_address); } Result MapManualLoadModuleMemory(u64 *out_address, size_t context_id, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { @@ -492,20 +550,20 @@ namespace ams::ro::impl { nro_info->bss_heap_size = bss_size; /* Map the NRO. */ - R_TRY(MapNro(std::addressof(nro_info->base_address), context->process_handle, nro_address, nro_size, bss_address, bss_size)); + R_TRY(MapNro(std::addressof(nro_info->base_address), context->GetProcessHandle(), nro_address, nro_size, bss_address, bss_size)); /* Validate the NRO (parsing region extents). */ u64 rx_size = 0, ro_size = 0, rw_size = 0; { - auto unmap_guard = SCOPE_GUARD { UnmapNro(context->process_handle, nro_info->base_address, nro_address, bss_address, bss_size, nro_size, 0); }; + auto unmap_guard = SCOPE_GUARD { UnmapNro(context->GetProcessHandle(), nro_info->base_address, nro_address, bss_address, bss_size, nro_size, 0); }; R_TRY(context->ValidateNro(std::addressof(nro_info->module_id), std::addressof(rx_size), std::addressof(ro_size), std::addressof(rw_size), nro_info->base_address, nro_size, bss_size)); unmap_guard.Cancel(); } /* Set NRO perms. */ { - auto unmap_guard = SCOPE_GUARD { UnmapNro(context->process_handle, nro_info->base_address, nro_address, bss_address, bss_size, rx_size + ro_size, rw_size); }; - R_TRY(SetNroPerms(context->process_handle, nro_info->base_address, rx_size, ro_size, rw_size + bss_size)); + auto unmap_guard = SCOPE_GUARD { UnmapNro(context->GetProcessHandle(), nro_info->base_address, nro_address, bss_address, bss_size, rx_size + ro_size, rw_size); }; + R_TRY(SetNroPerms(context->GetProcessHandle(), nro_info->base_address, rx_size, ro_size, rw_size + bss_size)); unmap_guard.Cancel(); } @@ -535,30 +593,15 @@ namespace ams::ro::impl { context->SetNroInfoInUse(nro_info, false); std::memset(nro_info, 0, sizeof(*nro_info)); } - return UnmapNro(context->process_handle, nro_backup.base_address, nro_backup.nro_heap_address, nro_backup.bss_heap_address, nro_backup.bss_heap_size, nro_backup.code_size, nro_backup.rw_size); + return UnmapNro(context->GetProcessHandle(), nro_backup.base_address, nro_backup.nro_heap_address, nro_backup.bss_heap_address, nro_backup.bss_heap_size, nro_backup.code_size, nro_backup.rw_size); } /* Debug service implementations. */ Result GetProcessModuleInfo(u32 *out_count, LoaderModuleInfo *out_infos, size_t max_out_count, os::ProcessId process_id) { - size_t count = 0; - const ProcessContext *context = GetContextByProcessId(process_id); - if (context != nullptr) { - for (size_t i = 0; i < MaxNroInfos && count < max_out_count; i++) { - if (!context->nro_in_use[i]) { - continue; - } - - const NroInfo *nro_info = context->nro_infos + i; - - /* Just copy out the info. */ - LoaderModuleInfo *out_info = std::addressof(out_infos[count++]); - memcpy(out_info->build_id, std::addressof(nro_info->module_id), sizeof(nro_info->module_id)); - out_info->base_address = nro_info->base_address; - out_info->size = nro_info->nro_heap_size + nro_info->bss_heap_size; - } + if (const ProcessContext *context = GetContextByProcessId(process_id); context != nullptr) { + context->GetProcessModuleInfo(out_count, out_infos, max_out_count); } - *out_count = static_cast(count); return ResultSuccess(); } diff --git a/stratosphere/ro/source/ro_ro_service.cpp b/stratosphere/ro/source/ro_ro_service.cpp index 52687bd36..e7d6aa546 100644 --- a/stratosphere/ro/source/ro_ro_service.cpp +++ b/stratosphere/ro/source/ro_ro_service.cpp @@ -27,45 +27,45 @@ namespace ams::ro { impl::SetDevelopmentFunctionEnabled(is_development_function_enabled); } - RoService::RoService(NrrKind k) : context_id(impl::InvalidContextId), nrr_kind(k) { + RoService::RoService(NrrKind k) : m_context_id(impl::InvalidContextId), m_nrr_kind(k) { /* ... */ } RoService::~RoService() { - impl::UnregisterProcess(this->context_id); + impl::UnregisterProcess(m_context_id); } Result RoService::MapManualLoadModuleMemory(sf::Out load_address, const sf::ClientProcessId &client_pid, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size) { - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); - return impl::MapManualLoadModuleMemory(load_address.GetPointer(), this->context_id, nro_address, nro_size, bss_address, bss_size); + R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); + return impl::MapManualLoadModuleMemory(load_address.GetPointer(), m_context_id, nro_address, nro_size, bss_address, bss_size); } Result RoService::UnmapManualLoadModuleMemory(const sf::ClientProcessId &client_pid, u64 nro_address) { - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); - return impl::UnmapManualLoadModuleMemory(this->context_id, nro_address); + R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); + return impl::UnmapManualLoadModuleMemory(m_context_id, nro_address); } Result RoService::RegisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size) { - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); - return impl::RegisterModuleInfo(this->context_id, os::InvalidNativeHandle, nrr_address, nrr_size, NrrKind_User, true); + R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); + return impl::RegisterModuleInfo(m_context_id, os::InvalidNativeHandle, nrr_address, nrr_size, NrrKind_User, true); } Result RoService::UnregisterModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address) { - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); - return impl::UnregisterModuleInfo(this->context_id, nrr_address); + R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); + return impl::UnregisterModuleInfo(m_context_id, nrr_address); } Result RoService::RegisterProcessHandle(const sf::ClientProcessId &client_pid, sf::CopyHandle &&process_h) { /* Register the process. */ - return impl::RegisterProcess(std::addressof(this->context_id), std::move(process_h), client_pid.GetValue()); + return impl::RegisterProcess(std::addressof(m_context_id), std::move(process_h), client_pid.GetValue()); } Result RoService::RegisterProcessModuleInfo(const sf::ClientProcessId &client_pid, u64 nrr_address, u64 nrr_size, sf::CopyHandle &&process_h) { /* Validate the process. */ - R_TRY(impl::ValidateProcess(this->context_id, client_pid.GetValue())); + R_TRY(impl::ValidateProcess(m_context_id, client_pid.GetValue())); /* Register the module. */ - return impl::RegisterModuleInfo(this->context_id, process_h.GetOsHandle(), nrr_address, nrr_size, this->nrr_kind, this->nrr_kind == NrrKind_JitPlugin); + return impl::RegisterModuleInfo(m_context_id, process_h.GetOsHandle(), nrr_address, nrr_size, m_nrr_kind, m_nrr_kind == NrrKind_JitPlugin); } } diff --git a/stratosphere/ro/source/ro_ro_service.hpp b/stratosphere/ro/source/ro_ro_service.hpp index 57f588ce8..a97a9fe15 100644 --- a/stratosphere/ro/source/ro_ro_service.hpp +++ b/stratosphere/ro/source/ro_ro_service.hpp @@ -25,8 +25,8 @@ namespace ams::ro { class RoService { private: - size_t context_id; - NrrKind nrr_kind; + size_t m_context_id; + NrrKind m_nrr_kind; protected: explicit RoService(NrrKind k); public: diff --git a/stratosphere/sm/source/impl/sm_service_manager.cpp b/stratosphere/sm/source/impl/sm_service_manager.cpp index 4e042ea8b..46896229d 100644 --- a/stratosphere/sm/source/impl/sm_service_manager.cpp +++ b/stratosphere/sm/source/impl/sm_service_manager.cpp @@ -122,20 +122,20 @@ namespace ams::sm::impl { class InitialProcessIdLimits { private: - os::ProcessId min; - os::ProcessId max; + os::ProcessId m_min; + os::ProcessId m_max; public: InitialProcessIdLimits() { /* Retrieve process limits. */ - cfg::GetInitialProcessRange(std::addressof(this->min), std::addressof(this->max)); + cfg::GetInitialProcessRange(std::addressof(m_min), std::addressof(m_max)); /* Ensure range is sane. */ - AMS_ABORT_UNLESS(this->min <= this->max); + AMS_ABORT_UNLESS(m_min <= m_max); } bool IsInitialProcess(os::ProcessId process_id) const { AMS_ABORT_UNLESS(process_id != os::InvalidProcessId); - return this->min <= process_id && process_id <= this->max; + return m_min <= process_id && process_id <= m_max; } }; diff --git a/stratosphere/spl/source/spl_api_impl.cpp b/stratosphere/spl/source/spl_api_impl.cpp index 70b762121..ad4b4bd5b 100644 --- a/stratosphere/spl/source/spl_api_impl.cpp +++ b/stratosphere/spl/source/spl_api_impl.cpp @@ -186,25 +186,25 @@ namespace ams::spl::impl { /* Type definitions. */ class ScopedAesKeySlot { private: - s32 slot; - bool has_slot; + s32 m_slot; + bool m_has_slot; public: - ScopedAesKeySlot() : slot(-1), has_slot(false) { + ScopedAesKeySlot() : m_slot(-1), m_has_slot(false) { /* ... */ } ~ScopedAesKeySlot() { - if (this->has_slot) { - DeallocateAesKeySlot(slot, this); + if (m_has_slot) { + DeallocateAesKeySlot(m_slot, this); } } u32 GetKeySlot() const { - return this->slot; + return m_slot; } Result Allocate() { - R_TRY(AllocateAesKeySlot(std::addressof(this->slot), this)); - this->has_slot = true; + R_TRY(AllocateAesKeySlot(std::addressof(m_slot), this)); + m_has_slot = true; return ResultSuccess(); } }; @@ -222,17 +222,17 @@ namespace ams::spl::impl { class DeviceAddressSpaceMapHelper { private: - os::NativeHandle das_hnd; - u64 dst_addr; - u64 src_addr; - size_t size; - svc::MemoryPermission perm; + os::NativeHandle m_handle; + u64 m_dst_addr; + u64 m_src_addr; + size_t m_size; + svc::MemoryPermission m_perm; public: - DeviceAddressSpaceMapHelper(os::NativeHandle h, u64 dst, u64 src, size_t sz, svc::MemoryPermission p) : das_hnd(h), dst_addr(dst), src_addr(src), size(sz), perm(p) { - R_ABORT_UNLESS(svc::MapDeviceAddressSpaceAligned(this->das_hnd, dd::GetCurrentProcessHandle(), this->src_addr, this->size, this->dst_addr, this->perm)); + DeviceAddressSpaceMapHelper(os::NativeHandle h, u64 dst, u64 src, size_t sz, svc::MemoryPermission p) : m_handle(h), m_dst_addr(dst), m_src_addr(src), m_size(sz), m_perm(p) { + R_ABORT_UNLESS(svc::MapDeviceAddressSpaceAligned(m_handle, dd::GetCurrentProcessHandle(), m_src_addr, m_size, m_dst_addr, m_perm)); } ~DeviceAddressSpaceMapHelper() { - R_ABORT_UNLESS(svc::UnmapDeviceAddressSpace(this->das_hnd, dd::GetCurrentProcessHandle(), this->src_addr, this->size, this->dst_addr)); + R_ABORT_UNLESS(svc::UnmapDeviceAddressSpace(m_handle, dd::GetCurrentProcessHandle(), m_src_addr, m_size, m_dst_addr)); } }; diff --git a/stratosphere/spl/source/spl_ctr_drbg.cpp b/stratosphere/spl/source/spl_ctr_drbg.cpp index 845c79c59..c5f35494b 100644 --- a/stratosphere/spl/source/spl_ctr_drbg.cpp +++ b/stratosphere/spl/source/spl_ctr_drbg.cpp @@ -19,30 +19,30 @@ namespace ams::spl { void CtrDrbg::Update(const void *data) { - aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true); - for (size_t offset = 0; offset < sizeof(this->work[1]); offset += BlockSize) { - IncrementCounter(this->counter); - aes128EncryptBlock(std::addressof(this->aes_ctx), std::addressof(this->work[1][offset]), this->counter); + aes128ContextCreate(std::addressof(m_aes_ctx), m_key, true); + for (size_t offset = 0; offset < sizeof(m_work[1]); offset += BlockSize) { + IncrementCounter(m_counter); + aes128EncryptBlock(std::addressof(m_aes_ctx), std::addressof(m_work[1][offset]), m_counter); } - Xor(this->work[1], data, sizeof(this->work[1])); + Xor(m_work[1], data, sizeof(m_work[1])); - std::memcpy(this->key, std::addressof(this->work[1][0]), sizeof(this->key)); - std::memcpy(this->counter, std::addressof(this->work[1][BlockSize]), sizeof(this->key)); + std::memcpy(m_key, std::addressof(m_work[1][0]), sizeof(m_key)); + std::memcpy(m_counter, std::addressof(m_work[1][BlockSize]), sizeof(m_key)); } void CtrDrbg::Initialize(const void *seed) { - std::memcpy(this->work[0], seed, sizeof(this->work[0])); - std::memset(this->key, 0, sizeof(this->key)); - std::memset(this->counter, 0, sizeof(this->counter)); - this->Update(this->work[0]); - this->reseed_counter = 1; + std::memcpy(m_work[0], seed, sizeof(m_work[0])); + std::memset(m_key, 0, sizeof(m_key)); + std::memset(m_counter, 0, sizeof(m_counter)); + this->Update(m_work[0]); + m_reseed_counter = 1; } void CtrDrbg::Reseed(const void *seed) { - std::memcpy(this->work[0], seed, sizeof(this->work[0])); - this->Update(this->work[0]); - this->reseed_counter = 1; + std::memcpy(m_work[0], seed, sizeof(m_work[0])); + this->Update(m_work[0]); + m_reseed_counter = 1; } bool CtrDrbg::GenerateRandomBytes(void *out, size_t size) { @@ -50,30 +50,30 @@ namespace ams::spl { return false; } - if (this->reseed_counter > ReseedInterval) { + if (m_reseed_counter > ReseedInterval) { return false; } - aes128ContextCreate(std::addressof(this->aes_ctx), this->key, true); + aes128ContextCreate(std::addressof(m_aes_ctx), m_key, true); u8 *cur_dst = reinterpret_cast(out); size_t aligned_size = (size & ~(BlockSize - 1)); for (size_t offset = 0; offset < aligned_size; offset += BlockSize) { - IncrementCounter(this->counter); - aes128EncryptBlock(std::addressof(this->aes_ctx), cur_dst, this->counter); + IncrementCounter(m_counter); + aes128EncryptBlock(std::addressof(m_aes_ctx), cur_dst, m_counter); cur_dst += BlockSize; } if (size > aligned_size) { - IncrementCounter(this->counter); - aes128EncryptBlock(std::addressof(this->aes_ctx), this->work[1], this->counter); - std::memcpy(cur_dst, this->work[1], size - aligned_size); + IncrementCounter(m_counter); + aes128EncryptBlock(std::addressof(m_aes_ctx), m_work[1], m_counter); + std::memcpy(cur_dst, m_work[1], size - aligned_size); } - std::memset(this->work[0], 0, sizeof(this->work[0])); - this->Update(this->work[0]); + std::memset(m_work[0], 0, sizeof(m_work[0])); + this->Update(m_work[0]); - this->reseed_counter++; + m_reseed_counter++; return true; } diff --git a/stratosphere/spl/source/spl_ctr_drbg.hpp b/stratosphere/spl/source/spl_ctr_drbg.hpp index e86b4ae85..eb5f012c0 100644 --- a/stratosphere/spl/source/spl_ctr_drbg.hpp +++ b/stratosphere/spl/source/spl_ctr_drbg.hpp @@ -26,11 +26,11 @@ namespace ams::spl { static constexpr size_t BlockSize = AES_BLOCK_SIZE; static constexpr size_t SeedSize = 2 * AES_BLOCK_SIZE; private: - Aes128Context aes_ctx; - u8 counter[BlockSize]; - u8 key[BlockSize]; - u8 work[2][SeedSize]; - u32 reseed_counter; + Aes128Context m_aes_ctx; + u8 m_counter[BlockSize]; + u8 m_key[BlockSize]; + u8 m_work[2][SeedSize]; + u32 m_reseed_counter; private: static void Xor(void *dst, const void *src, size_t size) { const u8 *src_u8 = reinterpret_cast(src); diff --git a/stratosphere/spl/source/spl_key_slot_cache.hpp b/stratosphere/spl/source/spl_key_slot_cache.hpp index e4be26bb3..9de0c8071 100644 --- a/stratosphere/spl/source/spl_key_slot_cache.hpp +++ b/stratosphere/spl/source/spl_key_slot_cache.hpp @@ -26,25 +26,25 @@ namespace ams::spl { public: static constexpr size_t KeySize = crypto::AesDecryptor128::KeySize; private: - const s32 slot_index; - s32 virtual_slot; + const s32 m_slot_index; + s32 m_virtual_slot; public: - explicit KeySlotCacheEntry(s32 idx) : slot_index(idx), virtual_slot(-1) { /* ... */ } + explicit KeySlotCacheEntry(s32 idx) : m_slot_index(idx), m_virtual_slot(-1) { /* ... */ } bool Contains(s32 virtual_slot) const { - return virtual_slot == this->virtual_slot; + return virtual_slot == m_virtual_slot; } - s32 GetPhysicalKeySlotIndex() const { return this->slot_index; } + s32 GetPhysicalKeySlotIndex() const { return m_slot_index; } - s32 GetVirtualKeySlotIndex() const { return this->virtual_slot; } + s32 GetVirtualKeySlotIndex() const { return m_virtual_slot; } void SetVirtualSlot(s32 virtual_slot) { - this->virtual_slot = virtual_slot; + m_virtual_slot = virtual_slot; } void ClearVirtualSlot() { - this->virtual_slot = -1; + m_virtual_slot = -1; } }; @@ -54,16 +54,16 @@ namespace ams::spl { private: using KeySlotCacheEntryList = util::IntrusiveListBaseTraits::ListType; private: - KeySlotCacheEntryList mru_list; + KeySlotCacheEntryList m_mru_list; public: - constexpr KeySlotCache() : mru_list() { /* ... */ } + constexpr KeySlotCache() : m_mru_list() { /* ... */ } s32 Allocate(s32 virtual_slot) { return this->AllocateFromLru(virtual_slot); } bool Find(s32 *out, s32 virtual_slot) { - for (auto it = this->mru_list.begin(); it != this->mru_list.end(); ++it) { + for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) { if (it->Contains(virtual_slot)) { *out = it->GetPhysicalKeySlotIndex(); @@ -76,7 +76,7 @@ namespace ams::spl { } bool Release(s32 *out, s32 virtual_slot) { - for (auto it = this->mru_list.begin(); it != this->mru_list.end(); ++it) { + for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) { if (it->Contains(virtual_slot)) { *out = it->GetPhysicalKeySlotIndex(); it->ClearVirtualSlot(); @@ -90,7 +90,7 @@ namespace ams::spl { } bool FindPhysical(s32 physical_slot) { - for (auto it = this->mru_list.begin(); it != this->mru_list.end(); ++it) { + for (auto it = m_mru_list.begin(); it != m_mru_list.end(); ++it) { if (it->GetPhysicalKeySlotIndex() == physical_slot) { this->UpdateMru(it); @@ -106,32 +106,32 @@ namespace ams::spl { } void AddEntry(KeySlotCacheEntry *entry) { - this->mru_list.push_front(*entry); + m_mru_list.push_front(*entry); } private: s32 AllocateFromLru(s32 virtual_slot) { - AMS_ASSERT(!this->mru_list.empty()); + AMS_ASSERT(!m_mru_list.empty()); - auto it = this->mru_list.rbegin(); + auto it = m_mru_list.rbegin(); it->SetVirtualSlot(virtual_slot); auto *entry = std::addressof(*it); - this->mru_list.pop_back(); - this->mru_list.push_front(*entry); + m_mru_list.pop_back(); + m_mru_list.push_front(*entry); return entry->GetPhysicalKeySlotIndex(); } void UpdateMru(KeySlotCacheEntryList::iterator it) { auto *entry = std::addressof(*it); - this->mru_list.erase(it); - this->mru_list.push_front(*entry); + m_mru_list.erase(it); + m_mru_list.push_front(*entry); } void UpdateLru(KeySlotCacheEntryList::iterator it) { auto *entry = std::addressof(*it); - this->mru_list.erase(it); - this->mru_list.push_back(*entry); + m_mru_list.erase(it); + m_mru_list.push_back(*entry); } };