summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/k_affinity_mask.h20
-rw-r--r--src/core/hle/kernel/k_auto_object.h9
-rw-r--r--src/core/hle/kernel/k_capabilities.cpp2
-rw-r--r--src/core/hle/kernel/k_capabilities.h2
-rw-r--r--src/core/hle/kernel/k_client_port.cpp73
-rw-r--r--src/core/hle/kernel/k_client_port.h23
-rw-r--r--src/core/hle/kernel/k_client_session.cpp6
-rw-r--r--src/core/hle/kernel/k_client_session.h11
-rw-r--r--src/core/hle/kernel/k_port.cpp37
-rw-r--r--src/core/hle/kernel/k_port.h26
-rw-r--r--src/core/hle/kernel/k_process.h6
-rw-r--r--src/core/hle/kernel/k_server_port.cpp27
-rw-r--r--src/core/hle/kernel/k_server_port.h10
-rw-r--r--src/core/hle/kernel/k_server_session.cpp18
-rw-r--r--src/core/hle/kernel/k_server_session.h12
-rw-r--r--src/core/hle/kernel/k_session.cpp54
-rw-r--r--src/core/hle/kernel/k_session.h39
-rw-r--r--src/core/hle/kernel/k_shared_memory.cpp12
-rw-r--r--src/core/hle/kernel/k_shared_memory.h2
-rw-r--r--src/core/hle/kernel/k_thread.h1
-rw-r--r--src/core/hle/kernel/kernel.cpp11
-rw-r--r--src/core/hle/kernel/svc/svc_port.cpp2
-rw-r--r--src/core/hle/kernel/svc/svc_session.cpp4
-rw-r--r--src/core/hle/service/ipc_helpers.h2
-rw-r--r--src/core/hle/service/server_manager.cpp2
-rw-r--r--src/core/hle/service/sm/sm.cpp4
-rw-r--r--src/core/hle/service/sm/sm_controller.cpp2
-rw-r--r--src/yuzu/debugger/wait_tree.cpp5
28 files changed, 196 insertions, 226 deletions
diff --git a/src/core/hle/kernel/k_affinity_mask.h b/src/core/hle/kernel/k_affinity_mask.h
index b58716e90..07a5a822c 100644
--- a/src/core/hle/kernel/k_affinity_mask.h
+++ b/src/core/hle/kernel/k_affinity_mask.h
@@ -13,40 +13,40 @@ class KAffinityMask {
public:
constexpr KAffinityMask() = default;
- [[nodiscard]] constexpr u64 GetAffinityMask() const {
- return this->mask;
+ constexpr u64 GetAffinityMask() const {
+ return m_mask;
}
constexpr void SetAffinityMask(u64 new_mask) {
ASSERT((new_mask & ~AllowedAffinityMask) == 0);
- this->mask = new_mask;
+ m_mask = new_mask;
}
- [[nodiscard]] constexpr bool GetAffinity(s32 core) const {
- return (this->mask & GetCoreBit(core)) != 0;
+ constexpr bool GetAffinity(s32 core) const {
+ return (m_mask & GetCoreBit(core)) != 0;
}
constexpr void SetAffinity(s32 core, bool set) {
if (set) {
- this->mask |= GetCoreBit(core);
+ m_mask |= GetCoreBit(core);
} else {
- this->mask &= ~GetCoreBit(core);
+ m_mask &= ~GetCoreBit(core);
}
}
constexpr void SetAll() {
- this->mask = AllowedAffinityMask;
+ m_mask = AllowedAffinityMask;
}
private:
- [[nodiscard]] static constexpr u64 GetCoreBit(s32 core) {
+ static constexpr u64 GetCoreBit(s32 core) {
ASSERT(0 <= core && core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
return (1ULL << core);
}
static constexpr u64 AllowedAffinityMask = (1ULL << Core::Hardware::NUM_CPU_CORES) - 1;
- u64 mask{};
+ u64 m_mask{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h
index e8118c2b8..2443ab2a5 100644
--- a/src/core/hle/kernel/k_auto_object.h
+++ b/src/core/hle/kernel/k_auto_object.h
@@ -164,17 +164,12 @@ public:
}
}
- const std::string& GetName() const {
- return name;
- }
-
private:
void RegisterWithKernel();
void UnregisterWithKernel();
protected:
KernelCore& kernel;
- std::string name;
private:
std::atomic<u32> m_ref_count{};
@@ -208,10 +203,6 @@ public:
return reinterpret_cast<u64>(this);
}
- virtual const std::string& GetName() const {
- return name;
- }
-
private:
friend class KAutoObjectWithListContainer;
};
diff --git a/src/core/hle/kernel/k_capabilities.cpp b/src/core/hle/kernel/k_capabilities.cpp
index 2907cc6e3..90e4e8fb0 100644
--- a/src/core/hle/kernel/k_capabilities.cpp
+++ b/src/core/hle/kernel/k_capabilities.cpp
@@ -11,7 +11,7 @@
namespace Kernel {
-Result KCapabilities::InitializeForKIP(std::span<const u32> kern_caps, KPageTable* page_table) {
+Result KCapabilities::InitializeForKip(std::span<const u32> kern_caps, KPageTable* page_table) {
// We're initializing an initial process.
m_svc_access_flags.reset();
m_irq_access_flags.reset();
diff --git a/src/core/hle/kernel/k_capabilities.h b/src/core/hle/kernel/k_capabilities.h
index cd96f8d23..de766c811 100644
--- a/src/core/hle/kernel/k_capabilities.h
+++ b/src/core/hle/kernel/k_capabilities.h
@@ -22,7 +22,7 @@ class KCapabilities {
public:
constexpr explicit KCapabilities() = default;
- Result InitializeForKIP(std::span<const u32> kern_caps, KPageTable* page_table);
+ Result InitializeForKip(std::span<const u32> kern_caps, KPageTable* page_table);
Result InitializeForUser(std::span<const u32> user_caps, KPageTable* page_table);
static Result CheckCapabilities(KernelCore& kernel, std::span<const u32> user_caps);
diff --git a/src/core/hle/kernel/k_client_port.cpp b/src/core/hle/kernel/k_client_port.cpp
index 700ae71e3..7a3d650fd 100644
--- a/src/core/hle/kernel/k_client_port.cpp
+++ b/src/core/hle/kernel/k_client_port.cpp
@@ -14,23 +14,18 @@ namespace Kernel {
KClientPort::KClientPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KClientPort::~KClientPort() = default;
-void KClientPort::Initialize(KPort* parent_port_, s32 max_sessions_, std::string&& name_) {
+void KClientPort::Initialize(KPort* parent, s32 max_sessions) {
// Set member variables.
- num_sessions = 0;
- peak_sessions = 0;
- parent = parent_port_;
- max_sessions = max_sessions_;
- name = std::move(name_);
+ m_num_sessions = 0;
+ m_peak_sessions = 0;
+ m_parent = parent;
+ m_max_sessions = max_sessions;
}
void KClientPort::OnSessionFinalized() {
KScopedSchedulerLock sl{kernel};
- // This might happen if a session was improperly used with this port.
- ASSERT_MSG(num_sessions > 0, "num_sessions is invalid");
-
- const auto prev = num_sessions--;
- if (prev == max_sessions) {
+ if (const auto prev = m_num_sessions--; prev == m_max_sessions) {
this->NotifyAvailable();
}
}
@@ -47,81 +42,81 @@ bool KClientPort::IsServerClosed() const {
void KClientPort::Destroy() {
// Note with our parent that we're closed.
- parent->OnClientClosed();
+ m_parent->OnClientClosed();
// Close our reference to our parent.
- parent->Close();
+ m_parent->Close();
}
bool KClientPort::IsSignaled() const {
- return num_sessions < max_sessions;
+ return m_num_sessions.load() < m_max_sessions;
}
Result KClientPort::CreateSession(KClientSession** out) {
+ // Declare the session we're going to allocate.
+ KSession* session{};
+
// Reserve a new session from the resource limit.
//! FIXME: we are reserving this from the wrong resource limit!
KScopedResourceReservation session_reservation(kernel.ApplicationProcess()->GetResourceLimit(),
LimitableResource::SessionCountMax);
R_UNLESS(session_reservation.Succeeded(), ResultLimitReached);
+ // Allocate a session normally.
+ session = KSession::Create(kernel);
+
+ // Check that we successfully created a session.
+ R_UNLESS(session != nullptr, ResultOutOfResource);
+
// Update the session counts.
{
+ ON_RESULT_FAILURE {
+ session->Close();
+ };
+
// Atomically increment the number of sessions.
s32 new_sessions{};
{
- const auto max = max_sessions;
- auto cur_sessions = num_sessions.load(std::memory_order_acquire);
+ const auto max = m_max_sessions;
+ auto cur_sessions = m_num_sessions.load(std::memory_order_acquire);
do {
R_UNLESS(cur_sessions < max, ResultOutOfSessions);
new_sessions = cur_sessions + 1;
- } while (!num_sessions.compare_exchange_weak(cur_sessions, new_sessions,
- std::memory_order_relaxed));
+ } while (!m_num_sessions.compare_exchange_weak(cur_sessions, new_sessions,
+ std::memory_order_relaxed));
}
// Atomically update the peak session tracking.
{
- auto peak = peak_sessions.load(std::memory_order_acquire);
+ auto peak = m_peak_sessions.load(std::memory_order_acquire);
do {
if (peak >= new_sessions) {
break;
}
- } while (!peak_sessions.compare_exchange_weak(peak, new_sessions,
- std::memory_order_relaxed));
+ } while (!m_peak_sessions.compare_exchange_weak(peak, new_sessions,
+ std::memory_order_relaxed));
}
}
- // Create a new session.
- KSession* session = KSession::Create(kernel);
- if (session == nullptr) {
- // Decrement the session count.
- const auto prev = num_sessions--;
- if (prev == max_sessions) {
- this->NotifyAvailable();
- }
-
- return ResultOutOfResource;
- }
-
// Initialize the session.
- session->Initialize(this, parent->GetName());
+ session->Initialize(this, m_parent->GetName());
// Commit the session reservation.
session_reservation.Commit();
// Register the session.
KSession::Register(kernel, session);
- auto session_guard = SCOPE_GUARD({
+ ON_RESULT_FAILURE {
session->GetClientSession().Close();
session->GetServerSession().Close();
- });
+ };
// Enqueue the session with our parent.
- R_TRY(parent->EnqueueSession(std::addressof(session->GetServerSession())));
+ R_TRY(m_parent->EnqueueSession(std::addressof(session->GetServerSession())));
// We succeeded, so set the output.
- session_guard.Cancel();
*out = std::addressof(session->GetClientSession());
- return ResultSuccess;
+ R_SUCCEED();
}
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_client_port.h b/src/core/hle/kernel/k_client_port.h
index a757cf9cd..23db06ddf 100644
--- a/src/core/hle/kernel/k_client_port.h
+++ b/src/core/hle/kernel/k_client_port.h
@@ -4,7 +4,6 @@
#pragma once
#include <memory>
-#include <string>
#include "common/common_types.h"
#include "core/hle/kernel/k_synchronization_object.h"
@@ -20,28 +19,28 @@ class KClientPort final : public KSynchronizationObject {
KERNEL_AUTOOBJECT_TRAITS(KClientPort, KSynchronizationObject);
public:
- explicit KClientPort(KernelCore& kernel_);
+ explicit KClientPort(KernelCore& kernel);
~KClientPort() override;
- void Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_);
+ void Initialize(KPort* parent, s32 max_sessions);
void OnSessionFinalized();
void OnServerClosed();
const KPort* GetParent() const {
- return parent;
+ return m_parent;
}
KPort* GetParent() {
- return parent;
+ return m_parent;
}
s32 GetNumSessions() const {
- return num_sessions;
+ return m_num_sessions;
}
s32 GetPeakSessions() const {
- return peak_sessions;
+ return m_peak_sessions;
}
s32 GetMaxSessions() const {
- return max_sessions;
+ return m_max_sessions;
}
bool IsLight() const;
@@ -54,10 +53,10 @@ public:
Result CreateSession(KClientSession** out);
private:
- std::atomic<s32> num_sessions{};
- std::atomic<s32> peak_sessions{};
- s32 max_sessions{};
- KPort* parent{};
+ std::atomic<s32> m_num_sessions{};
+ std::atomic<s32> m_peak_sessions{};
+ s32 m_max_sessions{};
+ KPort* m_parent{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_client_session.cpp b/src/core/hle/kernel/k_client_session.cpp
index da0c9ac8c..c9196d04b 100644
--- a/src/core/hle/kernel/k_client_session.cpp
+++ b/src/core/hle/kernel/k_client_session.cpp
@@ -17,8 +17,8 @@ KClientSession::KClientSession(KernelCore& kernel_)
KClientSession::~KClientSession() = default;
void KClientSession::Destroy() {
- parent->OnClientClosed();
- parent->Close();
+ m_parent->OnClientClosed();
+ m_parent->Close();
}
void KClientSession::OnServerClosed() {}
@@ -33,7 +33,7 @@ Result KClientSession::SendSyncRequest() {
request->Initialize(nullptr, GetCurrentThread(kernel).GetTLSAddress(), MessageBufferSize);
// Send the request.
- return parent->GetServerSession().OnRequest(request);
+ R_RETURN(m_parent->GetServerSession().OnRequest(request));
}
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_client_session.h b/src/core/hle/kernel/k_client_session.h
index b4a19c546..ecde2549c 100644
--- a/src/core/hle/kernel/k_client_session.h
+++ b/src/core/hle/kernel/k_client_session.h
@@ -33,17 +33,16 @@ public:
explicit KClientSession(KernelCore& kernel_);
~KClientSession() override;
- void Initialize(KSession* parent_session_, std::string&& name_) {
+ void Initialize(KSession* parent) {
// Set member variables.
- parent = parent_session_;
- name = std::move(name_);
+ m_parent = parent;
}
void Destroy() override;
- static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
+ static void PostDestroy(uintptr_t arg) {}
KSession* GetParent() const {
- return parent;
+ return m_parent;
}
Result SendSyncRequest();
@@ -51,7 +50,7 @@ public:
void OnServerClosed();
private:
- KSession* parent{};
+ KSession* m_parent{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_port.cpp b/src/core/hle/kernel/k_port.cpp
index 0a45ffd57..f73bc34d4 100644
--- a/src/core/hle/kernel/k_port.cpp
+++ b/src/core/hle/kernel/k_port.cpp
@@ -8,55 +8,54 @@
namespace Kernel {
KPort::KPort(KernelCore& kernel_)
- : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {}
+ : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_server{kernel_}, m_client{kernel_} {}
KPort::~KPort() = default;
-void KPort::Initialize(s32 max_sessions_, bool is_light_, const std::string& name_) {
+void KPort::Initialize(s32 max_sessions, bool is_light, uintptr_t name) {
// Open a new reference count to the initialized port.
- Open();
+ this->Open();
// Create and initialize our server/client pair.
- KAutoObject::Create(std::addressof(server));
- KAutoObject::Create(std::addressof(client));
- server.Initialize(this, name_ + ":Server");
- client.Initialize(this, max_sessions_, name_ + ":Client");
+ KAutoObject::Create(std::addressof(m_server));
+ KAutoObject::Create(std::addressof(m_client));
+ m_server.Initialize(this);
+ m_client.Initialize(this, max_sessions);
// Set our member variables.
- is_light = is_light_;
- name = name_;
- state = State::Normal;
+ m_is_light = is_light;
+ m_name = name;
+ m_state = State::Normal;
}
void KPort::OnClientClosed() {
KScopedSchedulerLock sl{kernel};
- if (state == State::Normal) {
- state = State::ClientClosed;
+ if (m_state == State::Normal) {
+ m_state = State::ClientClosed;
}
}
void KPort::OnServerClosed() {
KScopedSchedulerLock sl{kernel};
- if (state == State::Normal) {
- state = State::ServerClosed;
+ if (m_state == State::Normal) {
+ m_state = State::ServerClosed;
}
}
bool KPort::IsServerClosed() const {
KScopedSchedulerLock sl{kernel};
- return state == State::ServerClosed;
+ return m_state == State::ServerClosed;
}
Result KPort::EnqueueSession(KServerSession* session) {
KScopedSchedulerLock sl{kernel};
- R_UNLESS(state == State::Normal, ResultPortClosed);
+ R_UNLESS(m_state == State::Normal, ResultPortClosed);
- server.EnqueueSession(session);
-
- return ResultSuccess;
+ m_server.EnqueueSession(session);
+ R_SUCCEED();
}
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_port.h b/src/core/hle/kernel/k_port.h
index 0cfc16dab..f2a08547c 100644
--- a/src/core/hle/kernel/k_port.h
+++ b/src/core/hle/kernel/k_port.h
@@ -22,14 +22,17 @@ public:
explicit KPort(KernelCore& kernel_);
~KPort() override;
- static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
+ static void PostDestroy(uintptr_t arg) {}
- void Initialize(s32 max_sessions_, bool is_light_, const std::string& name_);
+ void Initialize(s32 max_sessions, bool is_light, uintptr_t name);
void OnClientClosed();
void OnServerClosed();
+ uintptr_t GetName() const {
+ return m_name;
+ }
bool IsLight() const {
- return is_light;
+ return m_is_light;
}
bool IsServerClosed() const;
@@ -37,16 +40,16 @@ public:
Result EnqueueSession(KServerSession* session);
KClientPort& GetClientPort() {
- return client;
+ return m_client;
}
KServerPort& GetServerPort() {
- return server;
+ return m_server;
}
const KClientPort& GetClientPort() const {
- return client;
+ return m_client;
}
const KServerPort& GetServerPort() const {
- return server;
+ return m_server;
}
private:
@@ -57,10 +60,11 @@ private:
ServerClosed = 3,
};
- KServerPort server;
- KClientPort client;
- State state{State::Invalid};
- bool is_light{};
+ KServerPort m_server;
+ KClientPort m_client;
+ uintptr_t m_name;
+ State m_state{State::Invalid};
+ bool m_is_light{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h
index bd9b9f876..8d65be17a 100644
--- a/src/core/hle/kernel/k_process.h
+++ b/src/core/hle/kernel/k_process.h
@@ -395,6 +395,10 @@ public:
return watchpoints;
}
+ const std::string& GetName() {
+ return name;
+ }
+
private:
void PinThread(s32 core_id, KThread* thread) {
ASSERT(0 <= core_id && core_id < static_cast<s32>(Core::Hardware::NUM_CPU_CORES));
@@ -499,6 +503,8 @@ private:
size_t memory_release_hint{};
+ std::string name{};
+
bool is_signaled{};
bool is_suspended{};
bool is_immortal{};
diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp
index 16968ba97..dc70ee848 100644
--- a/src/core/hle/kernel/k_server_port.cpp
+++ b/src/core/hle/kernel/k_server_port.cpp
@@ -15,10 +15,9 @@ namespace Kernel {
KServerPort::KServerPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KServerPort::~KServerPort() = default;
-void KServerPort::Initialize(KPort* parent_port_, std::string&& name_) {
+void KServerPort::Initialize(KPort* parent) {
// Set member variables.
- parent = parent_port_;
- name = std::move(name_);
+ m_parent = parent;
}
bool KServerPort::IsLight() const {
@@ -37,9 +36,9 @@ void KServerPort::CleanupSessions() {
KServerSession* session = nullptr;
{
KScopedSchedulerLock sl{kernel};
- if (!session_list.empty()) {
- session = std::addressof(session_list.front());
- session_list.pop_front();
+ if (!m_session_list.empty()) {
+ session = std::addressof(m_session_list.front());
+ m_session_list.pop_front();
}
}
@@ -54,13 +53,13 @@ void KServerPort::CleanupSessions() {
void KServerPort::Destroy() {
// Note with our parent that we're closed.
- parent->OnServerClosed();
+ m_parent->OnServerClosed();
// Perform necessary cleanup of our session lists.
this->CleanupSessions();
// Close our reference to our parent.
- parent->Close();
+ m_parent->Close();
}
bool KServerPort::IsSignaled() const {
@@ -68,7 +67,7 @@ bool KServerPort::IsSignaled() const {
UNIMPLEMENTED();
return false;
} else {
- return !session_list.empty();
+ return !m_session_list.empty();
}
}
@@ -78,8 +77,8 @@ void KServerPort::EnqueueSession(KServerSession* session) {
KScopedSchedulerLock sl{kernel};
// Add the session to our queue.
- session_list.push_back(*session);
- if (session_list.size() == 1) {
+ m_session_list.push_back(*session);
+ if (m_session_list.size() == 1) {
this->NotifyAvailable();
}
}
@@ -90,12 +89,12 @@ KServerSession* KServerPort::AcceptSession() {
KScopedSchedulerLock sl{kernel};
// Return the first session in the list.
- if (session_list.empty()) {
+ if (m_session_list.empty()) {
return nullptr;
}
- KServerSession* session = std::addressof(session_list.front());
- session_list.pop_front();
+ KServerSession* session = std::addressof(m_session_list.front());
+ m_session_list.pop_front();
return session;
}
diff --git a/src/core/hle/kernel/k_server_port.h b/src/core/hle/kernel/k_server_port.h
index 5fc7ee683..964767156 100644
--- a/src/core/hle/kernel/k_server_port.h
+++ b/src/core/hle/kernel/k_server_port.h
@@ -25,14 +25,14 @@ public:
explicit KServerPort(KernelCore& kernel_);
~KServerPort() override;
- void Initialize(KPort* parent_port_, std::string&& name_);
+ void Initialize(KPort* parent);
- void EnqueueSession(KServerSession* pending_session);
+ void EnqueueSession(KServerSession* session);
KServerSession* AcceptSession();
const KPort* GetParent() const {
- return parent;
+ return m_parent;
}
bool IsLight() const;
@@ -46,8 +46,8 @@ private:
void CleanupSessions();
- SessionList session_list;
- KPort* parent{};
+ SessionList m_session_list{};
+ KPort* m_parent{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp
index 01591af5b..6831243b5 100644
--- a/src/core/hle/kernel/k_server_session.cpp
+++ b/src/core/hle/kernel/k_server_session.cpp
@@ -33,18 +33,12 @@ KServerSession::KServerSession(KernelCore& kernel_)
KServerSession::~KServerSession() = default;
-void KServerSession::Initialize(KSession* parent_session_, std::string&& name_) {
- // Set member variables.
- parent = parent_session_;
- name = std::move(name_);
-}
-
void KServerSession::Destroy() {
- parent->OnServerClosed();
+ m_parent->OnServerClosed();
this->CleanupRequests();
- parent->Close();
+ m_parent->Close();
}
void KServerSession::OnClientClosed() {
@@ -144,7 +138,7 @@ bool KServerSession::IsSignaled() const {
ASSERT(KScheduler::IsSchedulerLockedByCurrentThread(kernel));
// If the client is closed, we're always signaled.
- if (parent->IsClientClosed()) {
+ if (m_parent->IsClientClosed()) {
return true;
}
@@ -161,7 +155,7 @@ Result KServerSession::OnRequest(KSessionRequest* request) {
KScopedSchedulerLock sl{kernel};
// Ensure that we can handle new requests.
- R_UNLESS(!parent->IsServerClosed(), ResultSessionClosed);
+ R_UNLESS(!m_parent->IsServerClosed(), ResultSessionClosed);
// Check that we're not terminating.
R_UNLESS(!GetCurrentThread(kernel).IsTerminationRequested(), ResultTerminationRequested);
@@ -219,7 +213,7 @@ Result KServerSession::SendReply(bool is_hle) {
KEvent* event = request->GetEvent();
// Check whether we're closed.
- const bool closed = (client_thread == nullptr || parent->IsClientClosed());
+ const bool closed = (client_thread == nullptr || m_parent->IsClientClosed());
Result result = ResultSuccess;
if (!closed) {
@@ -294,7 +288,7 @@ Result KServerSession::ReceiveRequest(std::shared_ptr<Service::HLERequestContext
KScopedSchedulerLock sl{kernel};
// Ensure that we can service the request.
- R_UNLESS(!parent->IsClientClosed(), ResultSessionClosed);
+ R_UNLESS(!m_parent->IsClientClosed(), ResultSessionClosed);
// Ensure we aren't already servicing a request.
R_UNLESS(m_current_request == nullptr, ResultNotFound);
diff --git a/src/core/hle/kernel/k_server_session.h b/src/core/hle/kernel/k_server_session.h
index 33f380352..e340e4dd8 100644
--- a/src/core/hle/kernel/k_server_session.h
+++ b/src/core/hle/kernel/k_server_session.h
@@ -38,14 +38,12 @@ public:
void Destroy() override;
- void Initialize(KSession* parent_session_, std::string&& name_);
-
- KSession* GetParent() {
- return parent;
+ void Initialize(KSession* p) {
+ m_parent = p;
}
const KSession* GetParent() const {
- return parent;
+ return m_parent;
}
bool IsSignaled() const override;
@@ -66,10 +64,10 @@ private:
void CleanupRequests();
/// KSession that owns this KServerSession
- KSession* parent{};
+ KSession* m_parent{};
/// List of threads which are pending a reply.
- boost::intrusive::list<KSessionRequest> m_request_list;
+ boost::intrusive::list<KSessionRequest> m_request_list{};
KSessionRequest* m_current_request{};
KLightLock m_lock;
diff --git a/src/core/hle/kernel/k_session.cpp b/src/core/hle/kernel/k_session.cpp
index 7e677c028..771ad68bf 100644
--- a/src/core/hle/kernel/k_session.cpp
+++ b/src/core/hle/kernel/k_session.cpp
@@ -10,68 +10,62 @@
namespace Kernel {
KSession::KSession(KernelCore& kernel_)
- : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {}
+ : KAutoObjectWithSlabHeapAndContainer{kernel_}, m_server{kernel_}, m_client{kernel_} {}
KSession::~KSession() = default;
-void KSession::Initialize(KClientPort* port_, const std::string& name_) {
+void KSession::Initialize(KClientPort* client_port, uintptr_t name) {
// Increment reference count.
// Because reference count is one on creation, this will result
// in a reference count of two. Thus, when both server and client are closed
// this object will be destroyed.
- Open();
+ this->Open();
// Create our sub sessions.
- KAutoObject::Create(std::addressof(server));
- KAutoObject::Create(std::addressof(client));
+ KAutoObject::Create(std::addressof(m_server));
+ KAutoObject::Create(std::addressof(m_client));
// Initialize our sub sessions.
- server.Initialize(this, name_ + ":Server");
- client.Initialize(this, name_ + ":Client");
+ m_server.Initialize(this);
+ m_client.Initialize(this);
// Set state and name.
- SetState(State::Normal);
- name = name_;
+ this->SetState(State::Normal);
+ m_name = name;
// Set our owner process.
//! FIXME: this is the wrong process!
- process = kernel.ApplicationProcess();
- process->Open();
+ m_process = kernel.ApplicationProcess();
+ m_process->Open();
// Set our port.
- port = port_;
- if (port != nullptr) {
- port->Open();
+ m_port = client_port;
+ if (m_port != nullptr) {
+ m_port->Open();
}
// Mark initialized.
- initialized = true;
+ m_initialized = true;
}
void KSession::Finalize() {
- if (port == nullptr) {
- return;
+ if (m_port != nullptr) {
+ m_port->OnSessionFinalized();
+ m_port->Close();
}
-
- port->OnSessionFinalized();
- port->Close();
}
void KSession::OnServerClosed() {
- if (GetState() != State::Normal) {
- return;
+ if (this->GetState() == State::Normal) {
+ this->SetState(State::ServerClosed);
+ m_client.OnServerClosed();
}
-
- SetState(State::ServerClosed);
- client.OnServerClosed();
}
void KSession::OnClientClosed() {
- if (GetState() != State::Normal) {
- return;
+ if (this->GetState() == State::Normal) {
+ SetState(State::ClientClosed);
+ m_server.OnClientClosed();
}
-
- SetState(State::ClientClosed);
- server.OnClientClosed();
}
void KSession::PostDestroy(uintptr_t arg) {
diff --git a/src/core/hle/kernel/k_session.h b/src/core/hle/kernel/k_session.h
index 93e5e6f71..ab553a04c 100644
--- a/src/core/hle/kernel/k_session.h
+++ b/src/core/hle/kernel/k_session.h
@@ -21,16 +21,15 @@ public:
explicit KSession(KernelCore& kernel_);
~KSession() override;
- void Initialize(KClientPort* port_, const std::string& name_);
-
+ void Initialize(KClientPort* port, uintptr_t name);
void Finalize() override;
bool IsInitialized() const override {
- return initialized;
+ return m_initialized;
}
uintptr_t GetPostDestroyArgument() const override {
- return reinterpret_cast<uintptr_t>(process);
+ return reinterpret_cast<uintptr_t>(m_process);
}
static void PostDestroy(uintptr_t arg);
@@ -48,27 +47,23 @@ public:
}
KClientSession& GetClientSession() {
- return client;
+ return m_client;
}
KServerSession& GetServerSession() {
- return server;
+ return m_server;
}
const KClientSession& GetClientSession() const {
- return client;
+ return m_client;
}
const KServerSession& GetServerSession() const {
- return server;
+ return m_server;
}
const KClientPort* GetParent() const {
- return port;
- }
-
- KClientPort* GetParent() {
- return port;
+ return m_port;
}
private:
@@ -80,20 +75,20 @@ private:
};
void SetState(State state) {
- atomic_state = static_cast<u8>(state);
+ m_atomic_state = static_cast<u8>(state);
}
State GetState() const {
- return static_cast<State>(atomic_state.load(std::memory_order_relaxed));
+ return static_cast<State>(m_atomic_state.load());
}
- KServerSession server;
- KClientSession client;
- std::atomic<std::underlying_type_t<State>> atomic_state{
- static_cast<std::underlying_type_t<State>>(State::Invalid)};
- KClientPort* port{};
- KProcess* process{};
- bool initialized{};
+ KServerSession m_server;
+ KClientSession m_client;
+ KClientPort* m_port{};
+ uintptr_t m_name{};
+ KProcess* m_process{};
+ std::atomic<u8> m_atomic_state{static_cast<u8>(State::Invalid)};
+ bool m_initialized{};
};
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_shared_memory.cpp b/src/core/hle/kernel/k_shared_memory.cpp
index df505edfe..42cb7ac77 100644
--- a/src/core/hle/kernel/k_shared_memory.cpp
+++ b/src/core/hle/kernel/k_shared_memory.cpp
@@ -17,15 +17,13 @@ KSharedMemory::~KSharedMemory() = default;
Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
Svc::MemoryPermission owner_permission_,
- Svc::MemoryPermission user_permission_, std::size_t size_,
- std::string name_) {
+ Svc::MemoryPermission user_permission_, std::size_t size_) {
// Set members.
owner_process = owner_process_;
device_memory = &device_memory_;
owner_permission = owner_permission_;
user_permission = user_permission_;
size = Common::AlignUp(size_, PageSize);
- name = std::move(name_);
const size_t num_pages = Common::DivideUp(size, PageSize);
@@ -64,7 +62,7 @@ Result KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* o
std::memset(device_memory_.GetPointer<void>(block.GetAddress()), 0, block.GetSize());
}
- return ResultSuccess;
+ R_SUCCEED();
}
void KSharedMemory::Finalize() {
@@ -94,15 +92,15 @@ Result KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t m
R_UNLESS(map_perm == test_perm, ResultInvalidNewMemoryPermission);
}
- return target_process.PageTable().MapPageGroup(address, *page_group, KMemoryState::Shared,
- ConvertToKMemoryPermission(map_perm));
+ R_RETURN(target_process.PageTable().MapPageGroup(address, *page_group, KMemoryState::Shared,
+ ConvertToKMemoryPermission(map_perm)));
}
Result KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) {
// Validate the size.
R_UNLESS(size == unmap_size, ResultInvalidSize);
- return target_process.PageTable().UnmapPageGroup(address, *page_group, KMemoryState::Shared);
+ R_RETURN(target_process.PageTable().UnmapPageGroup(address, *page_group, KMemoryState::Shared));
}
} // namespace Kernel
diff --git a/src/core/hle/kernel/k_shared_memory.h b/src/core/hle/kernel/k_shared_memory.h
index 8b29f0b4a..bfd01b619 100644
--- a/src/core/hle/kernel/k_shared_memory.h
+++ b/src/core/hle/kernel/k_shared_memory.h
@@ -28,7 +28,7 @@ public:
Result Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
Svc::MemoryPermission owner_permission_,
- Svc::MemoryPermission user_permission_, std::size_t size_, std::string name_);
+ Svc::MemoryPermission user_permission_, std::size_t size_);
/**
* Maps a shared memory block to an address in the target process' address space
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h
index 9423f08ca..f4cb861a9 100644
--- a/src/core/hle/kernel/k_thread.h
+++ b/src/core/hle/kernel/k_thread.h
@@ -926,6 +926,7 @@ private:
ThreadWaitReasonForDebugging wait_reason_for_debugging{};
uintptr_t argument{};
VAddr stack_top{};
+ std::string name{};
public:
using ConditionVariableThreadTreeType = ConditionVariableThreadTree;
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index ef7057ff7..59f832a3d 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -742,16 +742,15 @@ struct KernelCore::Impl {
hidbus_shared_mem = KSharedMemory::Create(system.Kernel());
hid_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None,
- Svc::MemoryPermission::Read, hid_size, "HID:SharedMemory");
+ Svc::MemoryPermission::Read, hid_size);
font_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None,
- Svc::MemoryPermission::Read, font_size, "Font:SharedMemory");
+ Svc::MemoryPermission::Read, font_size);
irs_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None,
- Svc::MemoryPermission::Read, irs_size, "IRS:SharedMemory");
+ Svc::MemoryPermission::Read, irs_size);
time_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None,
- Svc::MemoryPermission::Read, time_size, "Time:SharedMemory");
+ Svc::MemoryPermission::Read, time_size);
hidbus_shared_mem->Initialize(system.DeviceMemory(), nullptr, Svc::MemoryPermission::None,
- Svc::MemoryPermission::Read, hidbus_size,
- "HidBus:SharedMemory");
+ Svc::MemoryPermission::Read, hidbus_size);
}
std::mutex registered_objects_lock;
diff --git a/src/core/hle/kernel/svc/svc_port.cpp b/src/core/hle/kernel/svc/svc_port.cpp
index 78c2a8d17..0b5556bc4 100644
--- a/src/core/hle/kernel/svc/svc_port.cpp
+++ b/src/core/hle/kernel/svc/svc_port.cpp
@@ -81,7 +81,7 @@ Result ManageNamedPort(Core::System& system, Handle* out_server_handle, uint64_t
R_UNLESS(port != nullptr, ResultOutOfResource);
// Initialize the new port.
- port->Initialize(max_sessions, false, "");
+ port->Initialize(max_sessions, false, 0);
// Register the port.
KPort::Register(system.Kernel(), port);
diff --git a/src/core/hle/kernel/svc/svc_session.cpp b/src/core/hle/kernel/svc/svc_session.cpp
index 6dd242dcf..90d680540 100644
--- a/src/core/hle/kernel/svc/svc_session.cpp
+++ b/src/core/hle/kernel/svc/svc_session.cpp
@@ -12,7 +12,7 @@ namespace Kernel::Svc {
namespace {
template <typename T>
-Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, u64 name) {
+Result CreateSession(Core::System& system, Handle* out_server, Handle* out_client, uint64_t name) {
auto& process = GetCurrentProcess(system.Kernel());
auto& handle_table = process.GetHandleTable();
@@ -59,7 +59,7 @@ Result CreateSession(Core::System& system, Handle* out_server, Handle* out_clien
R_UNLESS(session != nullptr, ResultOutOfResource);
// Initialize the session.
- session->Initialize(nullptr, fmt::format("{}", name));
+ session->Initialize(nullptr, name);
// Commit the session reservation.
session_reservation.Commit();
diff --git a/src/core/hle/service/ipc_helpers.h b/src/core/hle/service/ipc_helpers.h
index 8703b57ca..e4cb4e1f2 100644
--- a/src/core/hle/service/ipc_helpers.h
+++ b/src/core/hle/service/ipc_helpers.h
@@ -155,7 +155,7 @@ public:
Kernel::LimitableResource::SessionCountMax, 1);
auto* session = Kernel::KSession::Create(kernel);
- session->Initialize(nullptr, iface->GetServiceName());
+ session->Initialize(nullptr, 0);
auto next_manager = std::make_shared<Service::SessionRequestManager>(
kernel, manager->GetServerManager());
diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp
index bd04cd023..6b4a1291e 100644
--- a/src/core/hle/service/server_manager.cpp
+++ b/src/core/hle/service/server_manager.cpp
@@ -124,7 +124,7 @@ Result ServerManager::ManageNamedPort(const std::string& service_name,
// Create a new port.
auto* port = Kernel::KPort::Create(m_system.Kernel());
- port->Initialize(max_sessions, false, service_name);
+ port->Initialize(max_sessions, false, 0);
// Register the port.
Kernel::KPort::Register(m_system.Kernel(), port);
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index b4046d3ce..c45be5726 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -62,7 +62,7 @@ Result ServiceManager::RegisterService(std::string name, u32 max_sessions,
}
auto* port = Kernel::KPort::Create(kernel);
- port->Initialize(ServerSessionCountMax, false, name);
+ port->Initialize(ServerSessionCountMax, false, 0);
service_ports.emplace(name, port);
registered_services.emplace(name, handler);
@@ -211,7 +211,7 @@ void SM::RegisterService(HLERequestContext& ctx) {
}
auto* port = Kernel::KPort::Create(kernel);
- port->Initialize(ServerSessionCountMax, is_light, name);
+ port->Initialize(ServerSessionCountMax, is_light, 0);
SCOPE_EXIT({ port->GetClientPort().Close(); });
IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles};
diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp
index 0111c8d7f..419c1df2b 100644
--- a/src/core/hle/service/sm/sm_controller.cpp
+++ b/src/core/hle/service/sm/sm_controller.cpp
@@ -44,7 +44,7 @@ void Controller::CloneCurrentObject(HLERequestContext& ctx) {
ASSERT(session != nullptr);
// Initialize the session.
- session->Initialize(nullptr, "");
+ session->Initialize(nullptr, 0);
// Commit the session reservation.
session_reservation.Commit();
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index 7f7c5fc42..219912128 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -182,10 +182,9 @@ bool WaitTreeExpandableItem::IsExpandable() const {
}
QString WaitTreeSynchronizationObject::GetText() const {
- return tr("[%1] %2 %3")
+ return tr("[%1] %2")
.arg(object.GetId())
- .arg(QString::fromStdString(object.GetTypeObj().GetName()),
- QString::fromStdString(object.GetName()));
+ .arg(QString::fromStdString(object.GetTypeObj().GetName()));
}
std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::make(