diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp index 61fda2ec9..0babf545b 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_handle_table.hpp @@ -312,7 +312,7 @@ namespace ams::kern { return true; } - constexpr ALWAYS_INLINE KAutoObject *GetObjectImpl(ams::svc::Handle handle) const { + constexpr NOINLINE KAutoObject *GetObjectImpl(ams::svc::Handle handle) const { MESOSPHERE_ASSERT_THIS(); /* Handles must not have reserved bits set. */ diff --git a/libraries/libmesosphere/include/mesosphere/kern_k_memory_region_type.hpp b/libraries/libmesosphere/include/mesosphere/kern_k_memory_region_type.hpp index e80e246ad..5ffe4ca05 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_k_memory_region_type.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_k_memory_region_type.hpp @@ -66,11 +66,41 @@ namespace ams::kern { consteval operator KMemoryRegionType() const { return static_cast(m_value); } consteval ValueType GetValue() const { return m_value; } - consteval const KMemoryRegionTypeValue &Finalize() { m_finalized = true; return *this; } - consteval const KMemoryRegionTypeValue &SetSparseOnly() { m_sparse_only = true; return *this; } - consteval const KMemoryRegionTypeValue &SetDenseOnly() { m_dense_only = true; return *this; } + consteval const KMemoryRegionTypeValue Finalize() { + AMS_ASSUME(!m_finalized); - consteval KMemoryRegionTypeValue &SetAttribute(KMemoryRegionAttr attr) { AMS_ASSUME(!m_finalized); m_value |= attr; return *this; } + KMemoryRegionTypeValue new_type = *this; + new_type.m_finalized = true; + return new_type; + } + + consteval const KMemoryRegionTypeValue SetSparseOnly() { + AMS_ASSUME(!m_finalized); + AMS_ASSUME(!m_sparse_only); + AMS_ASSUME(!m_dense_only); + + KMemoryRegionTypeValue new_type = *this; + new_type.m_sparse_only = true; + return new_type; + } + + consteval const KMemoryRegionTypeValue SetDenseOnly() { + AMS_ASSUME(!m_finalized); + AMS_ASSUME(!m_sparse_only); + AMS_ASSUME(!m_dense_only); + + KMemoryRegionTypeValue new_type = *this; + new_type.m_dense_only = true; + return new_type; + } + + consteval KMemoryRegionTypeValue SetAttribute(KMemoryRegionAttr attr) { + AMS_ASSUME(!m_finalized); + + KMemoryRegionTypeValue new_type = *this; + new_type.m_value |= attr; + return new_type; + } consteval KMemoryRegionTypeValue DeriveInitial(size_t i, size_t next = BITSIZEOF(ValueType)) const { AMS_ASSUME(!m_finalized);