sm: reimplement using tipc instead of cmif (probably broken, untested)

This commit is contained in:
Michael Scire 2021-04-10 01:58:26 -07:00 committed by SciresM
parent 58776f5ba8
commit 57c8bc432d
27 changed files with 904 additions and 735 deletions

View file

@ -280,7 +280,7 @@ namespace ams::tipc::impl {
static constexpr size_t OutDataSize = util::AlignUp(OutDataOffsets[NumOutDatas], alignof(u32));
/* Useful because reasons. */
static constexpr size_t OutDataAlign = [] {
static constexpr size_t OutDataAlign = []() -> size_t {
if constexpr (std::tuple_size<OutDatas>::value) {
return alignof(typename std::tuple_element<0, OutDatas>::type);
}

View file

@ -132,6 +132,8 @@ namespace ams::tipc {
public:
constexpr ALWAYS_INLINE InArrayImpl() : BaseType() { /* ... */ }
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<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
constexpr ALWAYS_INLINE const T *GetPointer() const {
@ -163,6 +165,8 @@ namespace ams::tipc {
public:
constexpr ALWAYS_INLINE OutArrayImpl() : BaseType() { /* ... */ }
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<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
constexpr ALWAYS_INLINE T *GetPointer() const {

View file

@ -57,7 +57,7 @@ namespace ams::tipc {
public:
constexpr ObjectManagerBase() = default;
void Initialize(os::WaitableManagerType *manager, Entry *entries, size_t max_objects) {
void InitializeImpl(os::WaitableManagerType *manager, Entry *entries, size_t max_objects) {
/* Set our waitable manager. */
m_waitable_manager = manager;
@ -179,7 +179,7 @@ namespace ams::tipc {
constexpr ObjectManager() = default;
void Initialize(os::WaitableManagerType *manager) {
this->Initialize(manager, m_entries_storage, MaxObjects);
this->InitializeImpl(manager, m_entries_storage, MaxObjects);
}
};

View file

@ -237,13 +237,15 @@ namespace ams::tipc {
--m_num_sessions;
}
void StartRegisterRetry(ResumeKey key) {
Result StartRegisterRetry(ResumeKey key) {
if constexpr (IsDeferralSupported) {
/* Acquire exclusive server manager access. */
std::scoped_lock lk(m_server_manager->GetMutex());
/* Begin the retry. */
m_deferral_manager.StartRegisterRetry(key);
return m_deferral_manager.StartRegisterRetry(key);
} else {
return ResultSuccess();
}
}
@ -329,7 +331,7 @@ namespace ams::tipc {
this->InitializeBase(id, sm, std::addressof(m_object_manager_impl));
/* Initialize our object manager. */
m_object_manager_impl->Initialize(std::addressof(this->m_waitable_manager));
m_object_manager_impl.Initialize(std::addressof(this->m_waitable_manager));
}
};
@ -430,6 +432,16 @@ namespace ams::tipc {
AMS_ABORT_UNLESS(allocated != nullptr);
return allocated;
}
void TriggerResume(ResumeKey resume_key) {
/* Acquire exclusive access to ourselves. */
std::scoped_lock lk(m_mutex);
/* Check/trigger resume on each of our ports. */
[this, resume_key]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
(this->TriggerResumeImpl<Ix>(resume_key), ...);
}(std::make_index_sequence<NumPorts>());
}
private:
template<size_t Ix> requires (Ix < NumPorts)
void TryAllocateObject(size_t port_index, tipc::ServiceObjectBase *&allocated) {
@ -570,6 +582,17 @@ namespace ams::tipc {
}
}
}
template<size_t Ix>
void TriggerResumeImpl(ResumeKey resume_key) {
/* Get the port manager. */
auto &port_manager = this->GetPortManager<Ix>();
/* If we should, trigger a resume. */
if (port_manager.TestResume(resume_key)) {
port_manager.TriggerResume(resume_key);
}
}
};
template<typename DeferralManagerType, typename... PortInfos>