mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-04 16:53:48 -04:00
strat: use m_ for member variables
This commit is contained in:
parent
ce28591ab2
commit
a595c232b9
425 changed files with 8531 additions and 8484 deletions
|
@ -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();
|
||||
|
|
|
@ -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<u16>(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)),
|
||||
|
|
|
@ -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); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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<uintptr_t>(ptr), sz) { /* ... */ }
|
||||
|
||||
constexpr void *GetPointer() const {
|
||||
return reinterpret_cast<void *>(this->pointer);
|
||||
return reinterpret_cast<void *>(m_pointer);
|
||||
}
|
||||
|
||||
constexpr uintptr_t GetAddress() const {
|
||||
return this->pointer;
|
||||
return m_pointer;
|
||||
}
|
||||
|
||||
constexpr size_t GetSize() const {
|
||||
return this->size;
|
||||
return m_size;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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<size_t>(this->in_data_size);
|
||||
}
|
||||
|
||||
constexpr size_t GetOutDataSize() const {
|
||||
return size_t(this->out_data_size);
|
||||
return static_cast<size_t>(this->out_data_size);
|
||||
}
|
||||
|
||||
constexpr size_t GetInHeadersSize() const {
|
||||
return size_t(this->in_headers_size);
|
||||
return static_cast<size_t>(this->in_headers_size);
|
||||
}
|
||||
|
||||
constexpr size_t GetOutHeadersSize() const {
|
||||
return size_t(this->out_headers_size);
|
||||
return static_cast<size_t>(this->out_headers_size);
|
||||
}
|
||||
|
||||
constexpr size_t GetInObjectCount() const {
|
||||
return size_t(this->in_object_count);
|
||||
return static_cast<size_t>(this->in_object_count);
|
||||
}
|
||||
|
||||
constexpr size_t GetOutObjectCount() const {
|
||||
return size_t(this->out_object_count);
|
||||
return static_cast<size_t>(this->out_object_count);
|
||||
}
|
||||
|
||||
constexpr size_t GetUnfixedOutPointerSizeOffset() const {
|
||||
|
|
|
@ -92,20 +92,20 @@ namespace ams::sf::cmif {
|
|||
public:
|
||||
static constexpr size_t NumEntries = N;
|
||||
private:
|
||||
const std::array<ServiceCommandMeta, N> entries;
|
||||
const std::array<ServiceCommandMeta, N> m_entries;
|
||||
public:
|
||||
explicit constexpr ServiceDispatchTableImpl(const std::array<ServiceCommandMeta, N> &e) : entries{e} { /* ... */ }
|
||||
explicit constexpr ServiceDispatchTableImpl(const std::array<ServiceCommandMeta, N> &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<ServiceCommandMeta, N> &GetEntries() const {
|
||||
return this->entries;
|
||||
return m_entries;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -22,29 +22,29 @@ namespace ams::sf::cmif {
|
|||
|
||||
class ServiceObjectHolder {
|
||||
private:
|
||||
SharedPointer<IServiceObject> srv;
|
||||
const ServiceDispatchMeta *dispatch_meta;
|
||||
SharedPointer<IServiceObject> 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<typename ServiceImpl>
|
||||
constexpr explicit ServiceObjectHolder(SharedPointer<ServiceImpl> &&s) : srv(std::move(s)), dispatch_meta(GetServiceDispatchMeta<ServiceImpl>()) {
|
||||
constexpr explicit ServiceObjectHolder(SharedPointer<ServiceImpl> &&s) : m_srv(std::move(s)), m_dispatch_meta(GetServiceDispatchMeta<ServiceImpl>()) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* 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<typename Interface>
|
||||
inline Interface *GetServiceObject() const {
|
||||
if (this->GetServiceId() == GetServiceDispatchMeta<Interface>()->GetServiceId()) {
|
||||
return static_cast<Interface *>(this->srv.Get());
|
||||
return static_cast<Interface *>(m_srv.Get());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline sf::IServiceObject *GetServiceObjectUnsafe() const {
|
||||
return static_cast<sf::IServiceObject *>(this->srv.Get());
|
||||
return static_cast<sf::IServiceObject *>(m_srv.Get());
|
||||
}
|
||||
|
||||
/* Processing. */
|
||||
|
|
|
@ -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<uintptr_t>(UserDataTag::MitmServer));
|
||||
|
@ -108,19 +108,19 @@ namespace ams::sf::hipc {
|
|||
os::SetMultiWaitHolderUserData(server, static_cast<uintptr_t>(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<typename Interface>
|
||||
Result AcceptImpl(Server *server, SharedPointer<Interface> p) {
|
||||
return ServerSessionManager::AcceptSession(server->port_handle, std::move(p));
|
||||
return ServerSessionManager::AcceptSession(server->m_port_handle, std::move(p));
|
||||
}
|
||||
|
||||
template<typename Interface>
|
||||
Result AcceptMitmImpl(Server *server, SharedPointer<Interface> 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<typename Interface>
|
||||
|
@ -261,29 +261,29 @@ namespace ams::sf::hipc {
|
|||
using ServerManagerBase::DomainStorage;
|
||||
private:
|
||||
/* Resource storage. */
|
||||
os::SdkMutex resource_mutex;
|
||||
util::TypedStorage<Server> server_storages[MaxServers];
|
||||
bool server_allocated[MaxServers];
|
||||
util::TypedStorage<ServerSession> 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<Server> m_server_storages[MaxServers];
|
||||
bool m_server_allocated[MaxServers];
|
||||
util::TypedStorage<ServerSession> 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<DomainStorage *>(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<uintptr_t>(this->pointer_buffer_storage), 0x10);
|
||||
this->saved_messages_start = util::AlignUp(reinterpret_cast<uintptr_t>(this->saved_message_storage), 0x10);
|
||||
m_pointer_buffers_start = util::AlignUp(reinterpret_cast<uintptr_t>(m_pointer_buffer_storage), 0x10);
|
||||
m_saved_messages_start = util::AlignUp(reinterpret_cast<uintptr_t>(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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -476,7 +476,7 @@ namespace ams::sf::impl {
|
|||
if constexpr (std::tuple_size<OutDatas>::value) {
|
||||
return alignof(typename std::tuple_element<0, OutDatas>::type);
|
||||
}
|
||||
return size_t();
|
||||
return static_cast<size_t>(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<size_t Offset, size_t TypeSize>
|
||||
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<uintptr_t>(std::addressof(data[Offset]));
|
||||
return reinterpret_cast<uintptr_t>(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<size_t Index>
|
||||
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<size_t Index>
|
||||
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<size_t Index>
|
||||
constexpr inline NativeHandle *GetMoveHandlePointer() {
|
||||
static_assert(Index < NumMove, "Index < NumMove");
|
||||
return move_handles + Index;
|
||||
return m_move_handles + Index;
|
||||
}
|
||||
|
||||
template<size_t Index>
|
||||
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<size_t NumInObjects, size_t NumOutObjects>
|
||||
class InOutObjectHolder {
|
||||
private:
|
||||
std::array<cmif::ServiceObjectHolder, NumInObjects> in_object_holders;
|
||||
std::array<cmif::ServiceObjectHolder, NumOutObjects> out_object_holders;
|
||||
std::array<util::TypedStorage<SharedPointer<sf::IServiceObject>>, NumOutObjects> out_shared_pointers;
|
||||
std::array<cmif::DomainObjectId, NumOutObjects> out_object_ids;
|
||||
std::array<cmif::ServiceObjectHolder, NumInObjects> m_in_object_holders;
|
||||
std::array<cmif::ServiceObjectHolder, NumOutObjects> m_out_object_holders;
|
||||
std::array<util::TypedStorage<SharedPointer<sf::IServiceObject>>, NumOutObjects> m_out_shared_pointers;
|
||||
std::array<cmif::DomainObjectId, NumOutObjects> 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<n, ServiceImplTuple>::type; \
|
||||
using ServiceImplType = typename SharedPointerType::Interface; \
|
||||
R_UNLESS((this->in_object_holders[n].template IsServiceObjectValid<ServiceImplType>()), sf::cmif::ResultInvalidInObject()); \
|
||||
R_UNLESS((m_in_object_holders[n].template IsServiceObjectValid<ServiceImplType>()), sf::cmif::ResultInvalidInObject()); \
|
||||
} \
|
||||
} while (0)
|
||||
_SF_IN_OUT_HOLDER_VALIDATE_IN_OBJECT(0);
|
||||
|
@ -754,23 +754,23 @@ namespace ams::sf::impl {
|
|||
template<size_t Index, typename Interface>
|
||||
SharedPointer<Interface> *GetOutObjectSharedPointer() {
|
||||
static_assert(sizeof(SharedPointer<Interface>) == sizeof(SharedPointer<sf::IServiceObject>));
|
||||
return static_cast<SharedPointer<Interface> *>(static_cast<void *>(GetPointer(out_shared_pointers[Index])));
|
||||
return static_cast<SharedPointer<Interface> *>(static_cast<void *>(GetPointer(m_out_shared_pointers[Index])));
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
Out<SharedPointer<Interface>> GetOutObject() {
|
||||
auto sp = std::construct_at(GetOutObjectSharedPointer<Index, Interface>());
|
||||
return Out<SharedPointer<Interface>>(sp, std::addressof(this->out_object_ids[Index]));
|
||||
return Out<SharedPointer<Interface>>(sp, std::addressof(m_out_object_ids[Index]));
|
||||
}
|
||||
|
||||
template<size_t Index, typename Interface>
|
||||
void SetOutObject() {
|
||||
this->out_object_holders[Index] = cmif::ServiceObjectHolder(std::move(*GetOutObjectSharedPointer<Index, Interface>()));
|
||||
m_out_object_holders[Index] = cmif::ServiceObjectHolder(std::move(*GetOutObjectSharedPointer<Index, Interface>()));
|
||||
}
|
||||
|
||||
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<const u16 *>(reinterpret_cast<uintptr_t>(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<size_t>(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<const u16 *>(reinterpret_cast<uintptr_t>(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<size_t>(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);
|
||||
}
|
||||
|
|
|
@ -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<typename Entry>
|
||||
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<uintptr_t>(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<uintptr_t>(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<uintptr_t>(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<uintptr_t>(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<uintptr_t>(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<uintptr_t>(ptr), num_elements * sizeof(T)) { /* ... */ }
|
||||
|
||||
constexpr T *GetPointer() const {
|
||||
|
|
|
@ -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<int>(alignment));
|
||||
return lmem::AllocateFromExpHeap(m_handle, size, static_cast<int>(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<size_t>(lmem::GetUnitHeapAlignment(this->handle)));
|
||||
AMS_ASSERT(size <= lmem::GetUnitHeapUnitSize(m_handle));
|
||||
AMS_ASSERT(alignment <= static_cast<size_t>(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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<T *>(p)) { /* ... */ }
|
||||
constexpr Out(T *p) : ptr(p) { /* ... */ }
|
||||
constexpr Out(const cmif::PointerAndSize &pas) : ptr(reinterpret_cast<T *>(pas.GetAddress())) { /* TODO: Is AMS_ABORT_UNLESS(pas.GetSize() >= sizeof(T)); necessary? */ }
|
||||
constexpr Out(uintptr_t p) : m_ptr(reinterpret_cast<T *>(p)) { /* ... */ }
|
||||
constexpr Out(T *p) : m_ptr(p) { /* ... */ }
|
||||
constexpr Out(const cmif::PointerAndSize &pas) : m_ptr(reinterpret_cast<T *>(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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue