forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #6291 from lioncash/kern-shadow

kernel: Eliminate variable shadowing
This commit is contained in:
bunnei 2021-05-09 20:15:00 -07:00 committed by GitHub
commit ec50a9b5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 138 additions and 140 deletions

View File

@ -69,16 +69,16 @@ public:
AlwaysMoveHandles = 1, AlwaysMoveHandles = 1,
}; };
explicit ResponseBuilder(Kernel::HLERequestContext& context, u32 normal_params_size, explicit ResponseBuilder(Kernel::HLERequestContext& ctx, u32 normal_params_size,
u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0, u32 num_handles_to_copy = 0, u32 num_objects_to_move = 0,
Flags flags = Flags::None) Flags flags = Flags::None)
: RequestHelperBase(context), normal_params_size(normal_params_size), : RequestHelperBase(ctx), normal_params_size(normal_params_size),
num_handles_to_copy(num_handles_to_copy), num_handles_to_copy(num_handles_to_copy),
num_objects_to_move(num_objects_to_move), kernel{context.kernel} { num_objects_to_move(num_objects_to_move), kernel{ctx.kernel} {
memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH); memset(cmdbuf, 0, sizeof(u32) * IPC::COMMAND_BUFFER_LENGTH);
context.ClearIncomingObjects(); ctx.ClearIncomingObjects();
IPC::CommandHeader header{}; IPC::CommandHeader header{};
@ -90,13 +90,13 @@ public:
u32 num_domain_objects{}; u32 num_domain_objects{};
const bool always_move_handles{ const bool always_move_handles{
(static_cast<u32>(flags) & static_cast<u32>(Flags::AlwaysMoveHandles)) != 0}; (static_cast<u32>(flags) & static_cast<u32>(Flags::AlwaysMoveHandles)) != 0};
if (!context.Session()->IsDomain() || always_move_handles) { if (!ctx.Session()->IsDomain() || always_move_handles) {
num_handles_to_move = num_objects_to_move; num_handles_to_move = num_objects_to_move;
} else { } else {
num_domain_objects = num_objects_to_move; num_domain_objects = num_objects_to_move;
} }
if (context.Session()->IsDomain()) { if (ctx.Session()->IsDomain()) {
raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects; raw_data_size += sizeof(DomainMessageHeader) / 4 + num_domain_objects;
} }
@ -116,7 +116,7 @@ public:
AlignWithPadding(); AlignWithPadding();
if (context.Session()->IsDomain() && context.HasDomainMessageHeader()) { if (ctx.Session()->IsDomain() && ctx.HasDomainMessageHeader()) {
IPC::DomainMessageHeader domain_header{}; IPC::DomainMessageHeader domain_header{};
domain_header.num_objects = num_domain_objects; domain_header.num_objects = num_domain_objects;
PushRaw(domain_header); PushRaw(domain_header);
@ -341,9 +341,9 @@ class RequestParser : public RequestHelperBase {
public: public:
explicit RequestParser(u32* command_buffer) : RequestHelperBase(command_buffer) {} explicit RequestParser(u32* command_buffer) : RequestHelperBase(command_buffer) {}
explicit RequestParser(Kernel::HLERequestContext& context) : RequestHelperBase(context) { explicit RequestParser(Kernel::HLERequestContext& ctx) : RequestHelperBase(ctx) {
ASSERT_MSG(context.GetDataPayloadOffset(), "context is incomplete"); ASSERT_MSG(ctx.GetDataPayloadOffset(), "context is incomplete");
Skip(context.GetDataPayloadOffset(), false); Skip(ctx.GetDataPayloadOffset(), false);
// Skip the u64 command id, it's already stored in the context // Skip the u64 command id, it's already stored in the context
static constexpr u32 CommandIdSize = 2; static constexpr u32 CommandIdSize = 2;
Skip(CommandIdSize, false); Skip(CommandIdSize, false);

View File

@ -180,12 +180,12 @@ ResultCode HLERequestContext::PopulateFromIncomingCommandBuffer(const KHandleTab
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& thread) { ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& requesting_thread) {
auto& owner_process = *thread.GetOwnerProcess(); auto& owner_process = *requesting_thread.GetOwnerProcess();
auto& handle_table = owner_process.GetHandleTable(); auto& handle_table = owner_process.GetHandleTable();
std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf; std::array<u32, IPC::COMMAND_BUFFER_LENGTH> dst_cmdbuf;
memory.ReadBlock(owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(), memory.ReadBlock(owner_process, requesting_thread.GetTLSAddress(), dst_cmdbuf.data(),
dst_cmdbuf.size() * sizeof(u32)); dst_cmdbuf.size() * sizeof(u32));
// The header was already built in the internal command buffer. Attempt to parse it to verify // The header was already built in the internal command buffer. Attempt to parse it to verify
@ -242,7 +242,7 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(KThread& thread) {
} }
// Copy the translated command buffer back into the thread's command buffer area. // Copy the translated command buffer back into the thread's command buffer area.
memory.WriteBlock(owner_process, thread.GetTLSAddress(), dst_cmdbuf.data(), memory.WriteBlock(owner_process, requesting_thread.GetTLSAddress(), dst_cmdbuf.data(),
dst_cmdbuf.size() * sizeof(u32)); dst_cmdbuf.size() * sizeof(u32));
return RESULT_SUCCESS; return RESULT_SUCCESS;

View File

@ -126,7 +126,7 @@ public:
u32_le* src_cmdbuf); u32_le* src_cmdbuf);
/// Writes data from this context back to the requesting process/thread. /// Writes data from this context back to the requesting process/thread.
ResultCode WriteToOutgoingCommandBuffer(KThread& thread); ResultCode WriteToOutgoingCommandBuffer(KThread& requesting_thread);
u32_le GetCommand() const { u32_le GetCommand() const {
return command; return command;

View File

@ -177,7 +177,7 @@ class KAutoObjectWithListContainer;
class KAutoObjectWithList : public KAutoObject { class KAutoObjectWithList : public KAutoObject {
public: public:
explicit KAutoObjectWithList(KernelCore& kernel_) : KAutoObject(kernel_), kernel(kernel_) {} explicit KAutoObjectWithList(KernelCore& kernel_) : KAutoObject(kernel_) {}
static int Compare(const KAutoObjectWithList& lhs, const KAutoObjectWithList& rhs) { static int Compare(const KAutoObjectWithList& lhs, const KAutoObjectWithList& rhs) {
const u64 lid = lhs.GetId(); const u64 lid = lhs.GetId();
@ -204,11 +204,7 @@ public:
private: private:
friend class KAutoObjectWithListContainer; friend class KAutoObjectWithListContainer;
private:
Common::IntrusiveRedBlackTreeNode list_node; Common::IntrusiveRedBlackTreeNode list_node;
protected:
KernelCore& kernel;
}; };
template <typename T> template <typename T>

View File

@ -13,7 +13,7 @@
namespace Kernel { namespace Kernel {
KClientPort::KClientPort(KernelCore& kernel) : KSynchronizationObject{kernel} {} KClientPort::KClientPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KClientPort::~KClientPort() = default; KClientPort::~KClientPort() = default;
void KClientPort::Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_) { void KClientPort::Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_) {

View File

@ -21,7 +21,7 @@ class KClientPort final : public KSynchronizationObject {
KERNEL_AUTOOBJECT_TRAITS(KClientPort, KSynchronizationObject); KERNEL_AUTOOBJECT_TRAITS(KClientPort, KSynchronizationObject);
public: public:
explicit KClientPort(KernelCore& kernel); explicit KClientPort(KernelCore& kernel_);
virtual ~KClientPort() override; virtual ~KClientPort() override;
void Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_); void Initialize(KPort* parent_, s32 max_sessions_, std::string&& name_);

View File

@ -12,7 +12,8 @@
namespace Kernel { namespace Kernel {
KClientSession::KClientSession(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} KClientSession::KClientSession(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel_} {}
KClientSession::~KClientSession() = default; KClientSession::~KClientSession() = default;
void KClientSession::Destroy() { void KClientSession::Destroy() {

View File

@ -33,7 +33,7 @@ class KClientSession final
KERNEL_AUTOOBJECT_TRAITS(KClientSession, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KClientSession, KAutoObject);
public: public:
explicit KClientSession(KernelCore& kernel); explicit KClientSession(KernelCore& kernel_);
virtual ~KClientSession(); virtual ~KClientSession();
void Initialize(KSession* parent_, std::string&& name_) { void Initialize(KSession* parent_, std::string&& name_) {

View File

@ -254,8 +254,7 @@ void KConditionVariable::Signal(u64 cv_key, s32 count) {
} }
// Close threads in the list. // Close threads in the list.
for (auto it = thread_list.begin(); it != thread_list.end(); for (auto it = thread_list.begin(); it != thread_list.end(); it = thread_list.erase(it)) {
it = thread_list.erase(kernel, it)) {
(*it).Close(); (*it).Close();
} }
} }

View File

@ -8,8 +8,9 @@
namespace Kernel { namespace Kernel {
KEvent::KEvent(KernelCore& kernel) KEvent::KEvent(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, readable_event{kernel}, writable_event{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, readable_event{kernel_}, writable_event{
kernel_} {}
KEvent::~KEvent() = default; KEvent::~KEvent() = default;

View File

@ -19,7 +19,7 @@ class KEvent final : public KAutoObjectWithSlabHeapAndContainer<KEvent, KAutoObj
KERNEL_AUTOOBJECT_TRAITS(KEvent, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KEvent, KAutoObject);
public: public:
explicit KEvent(KernelCore& kernel); explicit KEvent(KernelCore& kernel_);
virtual ~KEvent(); virtual ~KEvent();
void Initialize(std::string&& name); void Initialize(std::string&& name);

View File

@ -124,7 +124,7 @@ public:
~KLinkedList() { ~KLinkedList() {
// Erase all elements. // Erase all elements.
for (auto it = this->begin(); it != this->end(); it = this->erase(kernel, it)) { for (auto it = begin(); it != end(); it = erase(it)) {
} }
// Ensure we succeeded. // Ensure we succeeded.
@ -223,7 +223,7 @@ public:
this->erase(this->begin()); this->erase(this->begin());
} }
iterator erase(KernelCore& kernel, const iterator pos) { iterator erase(const iterator pos) {
KLinkedListNode* freed_node = std::addressof(*pos.m_base_it); KLinkedListNode* freed_node = std::addressof(*pos.m_base_it);
iterator ret = iterator(BaseList::erase(pos.m_base_it)); iterator ret = iterator(BaseList::erase(pos.m_base_it));
KLinkedListNode::Free(kernel, freed_node); KLinkedListNode::Free(kernel, freed_node);

View File

@ -17,8 +17,8 @@ KMemoryBlockManager::KMemoryBlockManager(VAddr start_addr, VAddr end_addr)
KMemoryBlockManager::iterator KMemoryBlockManager::FindIterator(VAddr addr) { KMemoryBlockManager::iterator KMemoryBlockManager::FindIterator(VAddr addr) {
auto node{memory_block_tree.begin()}; auto node{memory_block_tree.begin()};
while (node != end()) { while (node != end()) {
const VAddr end_addr{node->GetNumPages() * PageSize + node->GetAddress()}; const VAddr node_end_addr{node->GetNumPages() * PageSize + node->GetAddress()};
if (node->GetAddress() <= addr && end_addr - 1 >= addr) { if (node->GetAddress() <= addr && node_end_addr - 1 >= addr) {
return node; return node;
} }
node = std::next(node); node = std::next(node);
@ -67,7 +67,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
KMemoryPermission prev_perm, KMemoryAttribute prev_attribute, KMemoryPermission prev_perm, KMemoryAttribute prev_attribute,
KMemoryState state, KMemoryPermission perm, KMemoryState state, KMemoryPermission perm,
KMemoryAttribute attribute) { KMemoryAttribute attribute) {
const VAddr end_addr{addr + num_pages * PageSize}; const VAddr update_end_addr{addr + num_pages * PageSize};
iterator node{memory_block_tree.begin()}; iterator node{memory_block_tree.begin()};
prev_attribute |= KMemoryAttribute::IpcAndDeviceMapped; prev_attribute |= KMemoryAttribute::IpcAndDeviceMapped;
@ -78,7 +78,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
const VAddr cur_addr{block->GetAddress()}; const VAddr cur_addr{block->GetAddress()};
const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr}; const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr};
if (addr < cur_end_addr && cur_addr < end_addr) { if (addr < cur_end_addr && cur_addr < update_end_addr) {
if (!block->HasProperties(prev_state, prev_perm, prev_attribute)) { if (!block->HasProperties(prev_state, prev_perm, prev_attribute)) {
node = next_node; node = next_node;
continue; continue;
@ -89,8 +89,8 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
memory_block_tree.insert(node, block->Split(addr)); memory_block_tree.insert(node, block->Split(addr));
} }
if (end_addr < cur_end_addr) { if (update_end_addr < cur_end_addr) {
new_node = memory_block_tree.insert(node, block->Split(end_addr)); new_node = memory_block_tree.insert(node, block->Split(update_end_addr));
} }
new_node->Update(state, perm, attribute); new_node->Update(state, perm, attribute);
@ -98,7 +98,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
MergeAdjacent(new_node, next_node); MergeAdjacent(new_node, next_node);
} }
if (cur_end_addr - 1 >= end_addr - 1) { if (cur_end_addr - 1 >= update_end_addr - 1) {
break; break;
} }
@ -108,7 +108,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState state, void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState state,
KMemoryPermission perm, KMemoryAttribute attribute) { KMemoryPermission perm, KMemoryAttribute attribute) {
const VAddr end_addr{addr + num_pages * PageSize}; const VAddr update_end_addr{addr + num_pages * PageSize};
iterator node{memory_block_tree.begin()}; iterator node{memory_block_tree.begin()};
while (node != memory_block_tree.end()) { while (node != memory_block_tree.end()) {
@ -117,15 +117,15 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
const VAddr cur_addr{block->GetAddress()}; const VAddr cur_addr{block->GetAddress()};
const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr}; const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr};
if (addr < cur_end_addr && cur_addr < end_addr) { if (addr < cur_end_addr && cur_addr < update_end_addr) {
iterator new_node{node}; iterator new_node{node};
if (addr > cur_addr) { if (addr > cur_addr) {
memory_block_tree.insert(node, block->Split(addr)); memory_block_tree.insert(node, block->Split(addr));
} }
if (end_addr < cur_end_addr) { if (update_end_addr < cur_end_addr) {
new_node = memory_block_tree.insert(node, block->Split(end_addr)); new_node = memory_block_tree.insert(node, block->Split(update_end_addr));
} }
new_node->Update(state, perm, attribute); new_node->Update(state, perm, attribute);
@ -133,7 +133,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
MergeAdjacent(new_node, next_node); MergeAdjacent(new_node, next_node);
} }
if (cur_end_addr - 1 >= end_addr - 1) { if (cur_end_addr - 1 >= update_end_addr - 1) {
break; break;
} }
@ -143,7 +143,7 @@ void KMemoryBlockManager::Update(VAddr addr, std::size_t num_pages, KMemoryState
void KMemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func, void KMemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc&& lock_func,
KMemoryPermission perm) { KMemoryPermission perm) {
const VAddr end_addr{addr + num_pages * PageSize}; const VAddr update_end_addr{addr + num_pages * PageSize};
iterator node{memory_block_tree.begin()}; iterator node{memory_block_tree.begin()};
while (node != memory_block_tree.end()) { while (node != memory_block_tree.end()) {
@ -152,15 +152,15 @@ void KMemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc
const VAddr cur_addr{block->GetAddress()}; const VAddr cur_addr{block->GetAddress()};
const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr}; const VAddr cur_end_addr{block->GetNumPages() * PageSize + cur_addr};
if (addr < cur_end_addr && cur_addr < end_addr) { if (addr < cur_end_addr && cur_addr < update_end_addr) {
iterator new_node{node}; iterator new_node{node};
if (addr > cur_addr) { if (addr > cur_addr) {
memory_block_tree.insert(node, block->Split(addr)); memory_block_tree.insert(node, block->Split(addr));
} }
if (end_addr < cur_end_addr) { if (update_end_addr < cur_end_addr) {
new_node = memory_block_tree.insert(node, block->Split(end_addr)); new_node = memory_block_tree.insert(node, block->Split(update_end_addr));
} }
lock_func(new_node, perm); lock_func(new_node, perm);
@ -168,7 +168,7 @@ void KMemoryBlockManager::UpdateLock(VAddr addr, std::size_t num_pages, LockFunc
MergeAdjacent(new_node, next_node); MergeAdjacent(new_node, next_node);
} }
if (cur_end_addr - 1 >= end_addr - 1) { if (cur_end_addr - 1 >= update_end_addr - 1) {
break; break;
} }

View File

@ -82,9 +82,9 @@ public:
type_id = type; type_id = type;
} }
constexpr bool Contains(u64 address) const { constexpr bool Contains(u64 addr) const {
ASSERT(this->GetEndAddress() != 0); ASSERT(this->GetEndAddress() != 0);
return this->GetAddress() <= address && address <= this->GetLastAddress(); return this->GetAddress() <= addr && addr <= this->GetLastAddress();
} }
constexpr bool IsDerivedFrom(u32 type) const { constexpr bool IsDerivedFrom(u32 type) const {

View File

@ -9,8 +9,8 @@
namespace Kernel { namespace Kernel {
KPort::KPort(KernelCore& kernel) KPort::KPort(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, server{kernel}, client{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {}
KPort::~KPort() = default; KPort::~KPort() = default;

View File

@ -21,7 +21,7 @@ class KPort final : public KAutoObjectWithSlabHeapAndContainer<KPort, KAutoObjec
KERNEL_AUTOOBJECT_TRAITS(KPort, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KPort, KAutoObject);
public: public:
explicit KPort(KernelCore& kernel); explicit KPort(KernelCore& kernel_);
virtual ~KPort(); virtual ~KPort();
static void PostDestroy([[maybe_unused]] uintptr_t arg) {} static void PostDestroy([[maybe_unused]] uintptr_t arg) {}

View File

@ -118,11 +118,11 @@ private:
std::bitset<num_slot_entries> is_slot_used; std::bitset<num_slot_entries> is_slot_used;
}; };
ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string name, ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::string process_name,
ProcessType type) { ProcessType type) {
auto& kernel = system.Kernel(); auto& kernel = system.Kernel();
process->name = std::move(name); process->name = std::move(process_name);
process->resource_limit = kernel.GetSystemResourceLimit(); process->resource_limit = kernel.GetSystemResourceLimit();
process->status = ProcessStatus::Created; process->status = ProcessStatus::Created;
@ -373,8 +373,8 @@ void KProcess::Run(s32 main_thread_priority, u64 stack_size) {
void KProcess::PrepareForTermination() { void KProcess::PrepareForTermination() {
ChangeStatus(ProcessStatus::Exiting); ChangeStatus(ProcessStatus::Exiting);
const auto stop_threads = [this](const std::vector<KThread*>& thread_list) { const auto stop_threads = [this](const std::vector<KThread*>& in_thread_list) {
for (auto& thread : thread_list) { for (auto& thread : in_thread_list) {
if (thread->GetOwnerProcess() != this) if (thread->GetOwnerProcess() != this)
continue; continue;
@ -491,10 +491,10 @@ bool KProcess::IsSignaled() const {
return is_signaled; return is_signaled;
} }
KProcess::KProcess(KernelCore& kernel) KProcess::KProcess(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, : KAutoObjectWithSlabHeapAndContainer{kernel_},
page_table{std::make_unique<KPageTable>(kernel.System())}, handle_table{kernel}, page_table{std::make_unique<KPageTable>(kernel_.System())}, handle_table{kernel_},
address_arbiter{kernel.System()}, condition_var{kernel.System()}, state_lock{kernel} {} address_arbiter{kernel_.System()}, condition_var{kernel_.System()}, state_lock{kernel_} {}
KProcess::~KProcess() = default; KProcess::~KProcess() = default;

View File

@ -67,7 +67,7 @@ class KProcess final
KERNEL_AUTOOBJECT_TRAITS(KProcess, KSynchronizationObject); KERNEL_AUTOOBJECT_TRAITS(KProcess, KSynchronizationObject);
public: public:
explicit KProcess(KernelCore& kernel); explicit KProcess(KernelCore& kernel_);
~KProcess() override; ~KProcess() override;
enum : u64 { enum : u64 {
@ -90,7 +90,7 @@ public:
static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4;
static ResultCode Initialize(KProcess* process, Core::System& system, std::string name, static ResultCode Initialize(KProcess* process, Core::System& system, std::string process_name,
ProcessType type); ProcessType type);
/// Gets a reference to the process' page table. /// Gets a reference to the process' page table.

View File

@ -12,7 +12,7 @@
namespace Kernel { namespace Kernel {
KReadableEvent::KReadableEvent(KernelCore& kernel) : KSynchronizationObject{kernel} {} KReadableEvent::KReadableEvent(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KReadableEvent::~KReadableEvent() = default; KReadableEvent::~KReadableEvent() = default;

View File

@ -18,7 +18,7 @@ class KReadableEvent : public KSynchronizationObject {
KERNEL_AUTOOBJECT_TRAITS(KReadableEvent, KSynchronizationObject); KERNEL_AUTOOBJECT_TRAITS(KReadableEvent, KSynchronizationObject);
public: public:
explicit KReadableEvent(KernelCore& kernel); explicit KReadableEvent(KernelCore& kernel_);
~KReadableEvent() override; ~KReadableEvent() override;
void Initialize(KEvent* parent_, std::string&& name_) { void Initialize(KEvent* parent_, std::string&& name_) {

View File

@ -10,8 +10,8 @@
namespace Kernel { namespace Kernel {
constexpr s64 DefaultTimeout = 10000000000; // 10 seconds constexpr s64 DefaultTimeout = 10000000000; // 10 seconds
KResourceLimit::KResourceLimit(KernelCore& kernel) KResourceLimit::KResourceLimit(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, lock{kernel}, cond_var{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, lock{kernel_}, cond_var{kernel_} {}
KResourceLimit::~KResourceLimit() = default; KResourceLimit::~KResourceLimit() = default;
void KResourceLimit::Initialize(const Core::Timing::CoreTiming* core_timing_) { void KResourceLimit::Initialize(const Core::Timing::CoreTiming* core_timing_) {

View File

@ -36,7 +36,7 @@ class KResourceLimit final
KERNEL_AUTOOBJECT_TRAITS(KResourceLimit, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KResourceLimit, KAutoObject);
public: public:
explicit KResourceLimit(KernelCore& kernel); explicit KResourceLimit(KernelCore& kernel_);
virtual ~KResourceLimit(); virtual ~KResourceLimit();
void Initialize(const Core::Timing::CoreTiming* core_timing_); void Initialize(const Core::Timing::CoreTiming* core_timing_);

View File

@ -259,7 +259,7 @@ void KScheduler::OnThreadAffinityMaskChanged(KernelCore& kernel, KThread* thread
} }
} }
void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) { void KScheduler::RotateScheduledQueue(s32 cpu_core_id, s32 priority) {
ASSERT(system.GlobalSchedulerContext().IsLocked()); ASSERT(system.GlobalSchedulerContext().IsLocked());
// Get a reference to the priority queue. // Get a reference to the priority queue.
@ -267,7 +267,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
auto& priority_queue = GetPriorityQueue(kernel); auto& priority_queue = GetPriorityQueue(kernel);
// Rotate the front of the queue to the end. // Rotate the front of the queue to the end.
KThread* top_thread = priority_queue.GetScheduledFront(core_id, priority); KThread* top_thread = priority_queue.GetScheduledFront(cpu_core_id, priority);
KThread* next_thread = nullptr; KThread* next_thread = nullptr;
if (top_thread != nullptr) { if (top_thread != nullptr) {
next_thread = priority_queue.MoveToScheduledBack(top_thread); next_thread = priority_queue.MoveToScheduledBack(top_thread);
@ -279,7 +279,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
// While we have a suggested thread, try to migrate it! // While we have a suggested thread, try to migrate it!
{ {
KThread* suggested = priority_queue.GetSuggestedFront(core_id, priority); KThread* suggested = priority_queue.GetSuggestedFront(cpu_core_id, priority);
while (suggested != nullptr) { while (suggested != nullptr) {
// Check if the suggested thread is the top thread on its core. // Check if the suggested thread is the top thread on its core.
const s32 suggested_core = suggested->GetActiveCore(); const s32 suggested_core = suggested->GetActiveCore();
@ -300,7 +300,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
// to the front of the queue. // to the front of the queue.
if (top_on_suggested_core == nullptr || if (top_on_suggested_core == nullptr ||
top_on_suggested_core->GetPriority() >= HighestCoreMigrationAllowedPriority) { top_on_suggested_core->GetPriority() >= HighestCoreMigrationAllowedPriority) {
suggested->SetActiveCore(core_id); suggested->SetActiveCore(cpu_core_id);
priority_queue.ChangeCore(suggested_core, suggested, true); priority_queue.ChangeCore(suggested_core, suggested, true);
IncrementScheduledCount(suggested); IncrementScheduledCount(suggested);
break; break;
@ -308,22 +308,22 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
} }
// Get the next suggestion. // Get the next suggestion.
suggested = priority_queue.GetSamePriorityNext(core_id, suggested); suggested = priority_queue.GetSamePriorityNext(cpu_core_id, suggested);
} }
} }
// Now that we might have migrated a thread with the same priority, check if we can do better. // Now that we might have migrated a thread with the same priority, check if we can do better.
{ {
KThread* best_thread = priority_queue.GetScheduledFront(core_id); KThread* best_thread = priority_queue.GetScheduledFront(cpu_core_id);
if (best_thread == GetCurrentThread()) { if (best_thread == GetCurrentThread()) {
best_thread = priority_queue.GetScheduledNext(core_id, best_thread); best_thread = priority_queue.GetScheduledNext(cpu_core_id, best_thread);
} }
// If the best thread we can choose has a priority the same or worse than ours, try to // If the best thread we can choose has a priority the same or worse than ours, try to
// migrate a higher priority thread. // migrate a higher priority thread.
if (best_thread != nullptr && best_thread->GetPriority() >= priority) { if (best_thread != nullptr && best_thread->GetPriority() >= priority) {
KThread* suggested = priority_queue.GetSuggestedFront(core_id); KThread* suggested = priority_queue.GetSuggestedFront(cpu_core_id);
while (suggested != nullptr) { while (suggested != nullptr) {
// If the suggestion's priority is the same as ours, don't bother. // If the suggestion's priority is the same as ours, don't bother.
if (suggested->GetPriority() >= best_thread->GetPriority()) { if (suggested->GetPriority() >= best_thread->GetPriority()) {
@ -342,7 +342,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
if (top_on_suggested_core == nullptr || if (top_on_suggested_core == nullptr ||
top_on_suggested_core->GetPriority() >= top_on_suggested_core->GetPriority() >=
HighestCoreMigrationAllowedPriority) { HighestCoreMigrationAllowedPriority) {
suggested->SetActiveCore(core_id); suggested->SetActiveCore(cpu_core_id);
priority_queue.ChangeCore(suggested_core, suggested, true); priority_queue.ChangeCore(suggested_core, suggested, true);
IncrementScheduledCount(suggested); IncrementScheduledCount(suggested);
break; break;
@ -350,7 +350,7 @@ void KScheduler::RotateScheduledQueue(s32 core_id, s32 priority) {
} }
// Get the next suggestion. // Get the next suggestion.
suggested = priority_queue.GetSuggestedNext(core_id, suggested); suggested = priority_queue.GetSuggestedNext(cpu_core_id, suggested);
} }
} }
} }

View File

@ -141,7 +141,7 @@ private:
[[nodiscard]] static KSchedulerPriorityQueue& GetPriorityQueue(KernelCore& kernel); [[nodiscard]] static KSchedulerPriorityQueue& GetPriorityQueue(KernelCore& kernel);
void RotateScheduledQueue(s32 core_id, s32 priority); void RotateScheduledQueue(s32 cpu_core_id, s32 priority);
void Schedule() { void Schedule() {
ASSERT(GetCurrentThread()->GetDisableDispatchCount() == 1); ASSERT(GetCurrentThread()->GetDisableDispatchCount() == 1);

View File

@ -14,7 +14,7 @@
namespace Kernel { namespace Kernel {
KServerPort::KServerPort(KernelCore& kernel) : KSynchronizationObject{kernel} {} KServerPort::KServerPort(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KServerPort::~KServerPort() = default; KServerPort::~KServerPort() = default;
void KServerPort::Initialize(KPort* parent_, std::string&& name_) { void KServerPort::Initialize(KPort* parent_, std::string&& name_) {

View File

@ -29,7 +29,7 @@ private:
using SessionList = boost::intrusive::list<KServerSession>; using SessionList = boost::intrusive::list<KServerSession>;
public: public:
explicit KServerPort(KernelCore& kernel); explicit KServerPort(KernelCore& kernel_);
virtual ~KServerPort() override; virtual ~KServerPort() override;
using HLEHandler = std::shared_ptr<SessionRequestHandler>; using HLEHandler = std::shared_ptr<SessionRequestHandler>;

View File

@ -23,7 +23,7 @@
namespace Kernel { namespace Kernel {
KServerSession::KServerSession(KernelCore& kernel) : KSynchronizationObject{kernel} {} KServerSession::KServerSession(KernelCore& kernel_) : KSynchronizationObject{kernel_} {}
KServerSession::~KServerSession() { KServerSession::~KServerSession() {
kernel.ReleaseServiceThread(service_thread); kernel.ReleaseServiceThread(service_thread);

View File

@ -40,7 +40,7 @@ class KServerSession final : public KSynchronizationObject,
friend class ServiceThread; friend class ServiceThread;
public: public:
explicit KServerSession(KernelCore& kernel); explicit KServerSession(KernelCore& kernel_);
virtual ~KServerSession() override; virtual ~KServerSession() override;
virtual void Destroy() override; virtual void Destroy() override;

View File

@ -11,8 +11,8 @@
namespace Kernel { namespace Kernel {
KSession::KSession(KernelCore& kernel) KSession::KSession(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, server{kernel}, client{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, server{kernel_}, client{kernel_} {}
KSession::~KSession() = default; KSession::~KSession() = default;
void KSession::Initialize(KClientPort* port_, const std::string& name_) { void KSession::Initialize(KClientPort* port_, const std::string& name_) {

View File

@ -17,7 +17,7 @@ class KSession final : public KAutoObjectWithSlabHeapAndContainer<KSession, KAut
KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KSession, KAutoObject);
public: public:
explicit KSession(KernelCore& kernel); explicit KSession(KernelCore& kernel_);
virtual ~KSession() override; virtual ~KSession() override;
void Initialize(KClientPort* port_, const std::string& name_); void Initialize(KClientPort* port_, const std::string& name_);

View File

@ -12,14 +12,14 @@
namespace Kernel { namespace Kernel {
KSharedMemory::KSharedMemory(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} KSharedMemory::KSharedMemory(KernelCore& kernel_) : KAutoObjectWithSlabHeapAndContainer{kernel_} {}
KSharedMemory::~KSharedMemory() { KSharedMemory::~KSharedMemory() {
kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size); kernel.GetSystemResourceLimit()->Release(LimitableResource::PhysicalMemory, size);
} }
ResultCode KSharedMemory::Initialize(KernelCore& kernel_, Core::DeviceMemory& device_memory_, ResultCode KSharedMemory::Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
KProcess* owner_process_, KPageLinkedList&& page_list_, KPageLinkedList&& page_list_,
Svc::MemoryPermission owner_permission_, Svc::MemoryPermission owner_permission_,
Svc::MemoryPermission user_permission_, Svc::MemoryPermission user_permission_,
PAddr physical_address_, std::size_t size_, PAddr physical_address_, std::size_t size_,
@ -32,7 +32,7 @@ ResultCode KSharedMemory::Initialize(KernelCore& kernel_, Core::DeviceMemory& de
user_permission = user_permission_; user_permission = user_permission_;
physical_address = physical_address_; physical_address = physical_address_;
size = size_; size = size_;
name = name_; name = std::move(name_);
// Get the resource limit. // Get the resource limit.
KResourceLimit* reslimit = kernel.GetSystemResourceLimit(); KResourceLimit* reslimit = kernel.GetSystemResourceLimit();
@ -67,9 +67,9 @@ void KSharedMemory::Finalize() {
KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize(); KAutoObjectWithSlabHeapAndContainer<KSharedMemory, KAutoObjectWithList>::Finalize();
} }
ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t size, ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size_t map_size,
Svc::MemoryPermission permissions) { Svc::MemoryPermission permissions) {
const u64 page_count{(size + PageSize - 1) / PageSize}; const u64 page_count{(map_size + PageSize - 1) / PageSize};
if (page_list.GetNumPages() != page_count) { if (page_list.GetNumPages() != page_count) {
UNIMPLEMENTED_MSG("Page count does not match"); UNIMPLEMENTED_MSG("Page count does not match");
@ -86,8 +86,8 @@ ResultCode KSharedMemory::Map(KProcess& target_process, VAddr address, std::size
ConvertToKMemoryPermission(permissions)); ConvertToKMemoryPermission(permissions));
} }
ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t size) { ResultCode KSharedMemory::Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size) {
const u64 page_count{(size + PageSize - 1) / PageSize}; const u64 page_count{(unmap_size + PageSize - 1) / PageSize};
if (page_list.GetNumPages() != page_count) { if (page_list.GetNumPages() != page_count) {
UNIMPLEMENTED_MSG("Page count does not match"); UNIMPLEMENTED_MSG("Page count does not match");

View File

@ -24,12 +24,11 @@ class KSharedMemory final
KERNEL_AUTOOBJECT_TRAITS(KSharedMemory, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KSharedMemory, KAutoObject);
public: public:
explicit KSharedMemory(KernelCore& kernel); explicit KSharedMemory(KernelCore& kernel_);
~KSharedMemory() override; ~KSharedMemory() override;
ResultCode Initialize(KernelCore& kernel_, Core::DeviceMemory& device_memory_, ResultCode Initialize(Core::DeviceMemory& device_memory_, KProcess* owner_process_,
KProcess* owner_process_, KPageLinkedList&& page_list_, KPageLinkedList&& page_list_, Svc::MemoryPermission owner_permission_,
Svc::MemoryPermission owner_permission_,
Svc::MemoryPermission user_permission_, PAddr physical_address_, Svc::MemoryPermission user_permission_, PAddr physical_address_,
std::size_t size_, std::string name_); std::size_t size_, std::string name_);
@ -37,19 +36,19 @@ public:
* Maps a shared memory block to an address in the target process' address space * Maps a shared memory block to an address in the target process' address space
* @param target_process Process on which to map the memory block * @param target_process Process on which to map the memory block
* @param address Address in system memory to map shared memory block to * @param address Address in system memory to map shared memory block to
* @param size Size of the shared memory block to map * @param map_size Size of the shared memory block to map
* @param permissions Memory block map permissions (specified by SVC field) * @param permissions Memory block map permissions (specified by SVC field)
*/ */
ResultCode Map(KProcess& target_process, VAddr address, std::size_t size, ResultCode Map(KProcess& target_process, VAddr address, std::size_t map_size,
Svc::MemoryPermission permissions); Svc::MemoryPermission permissions);
/** /**
* Unmaps a shared memory block from an address in the target process' address space * Unmaps a shared memory block from an address in the target process' address space
* @param target_process Process on which to unmap the memory block * @param target_process Process on which to unmap the memory block
* @param address Address in system memory to unmap shared memory block * @param address Address in system memory to unmap shared memory block
* @param size Size of the shared memory block to unmap * @param unmap_size Size of the shared memory block to unmap
*/ */
ResultCode Unmap(KProcess& target_process, VAddr address, std::size_t size); ResultCode Unmap(KProcess& target_process, VAddr address, std::size_t unmap_size);
/** /**
* Gets a pointer to the shared memory block * Gets a pointer to the shared memory block

View File

@ -18,18 +18,18 @@ void KSynchronizationObject::Finalize() {
KAutoObject::Finalize(); KAutoObject::Finalize();
} }
ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index, ResultCode KSynchronizationObject::Wait(KernelCore& kernel_ctx, s32* out_index,
KSynchronizationObject** objects, const s32 num_objects, KSynchronizationObject** objects, const s32 num_objects,
s64 timeout) { s64 timeout) {
// Allocate space on stack for thread nodes. // Allocate space on stack for thread nodes.
std::vector<ThreadListNode> thread_nodes(num_objects); std::vector<ThreadListNode> thread_nodes(num_objects);
// Prepare for wait. // Prepare for wait.
KThread* thread = kernel.CurrentScheduler()->GetCurrentThread(); KThread* thread = kernel_ctx.CurrentScheduler()->GetCurrentThread();
{ {
// Setup the scheduling lock and sleep. // Setup the scheduling lock and sleep.
KScopedSchedulerLockAndSleep slp{kernel, thread, timeout}; KScopedSchedulerLockAndSleep slp{kernel_ctx, thread, timeout};
// Check if any of the objects are already signaled. // Check if any of the objects are already signaled.
for (auto i = 0; i < num_objects; ++i) { for (auto i = 0; i < num_objects; ++i) {
@ -94,13 +94,13 @@ ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index,
thread->SetWaitObjectsForDebugging({}); thread->SetWaitObjectsForDebugging({});
// Cancel the timer as needed. // Cancel the timer as needed.
kernel.TimeManager().UnscheduleTimeEvent(thread); kernel_ctx.TimeManager().UnscheduleTimeEvent(thread);
// Get the wait result. // Get the wait result.
ResultCode wait_result{RESULT_SUCCESS}; ResultCode wait_result{RESULT_SUCCESS};
s32 sync_index = -1; s32 sync_index = -1;
{ {
KScopedSchedulerLock lock(kernel); KScopedSchedulerLock lock(kernel_ctx);
KSynchronizationObject* synced_obj; KSynchronizationObject* synced_obj;
wait_result = thread->GetWaitResult(std::addressof(synced_obj)); wait_result = thread->GetWaitResult(std::addressof(synced_obj));
@ -135,7 +135,8 @@ ResultCode KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index,
return wait_result; return wait_result;
} }
KSynchronizationObject::KSynchronizationObject(KernelCore& kernel) : KAutoObjectWithList{kernel} {} KSynchronizationObject::KSynchronizationObject(KernelCore& kernel_)
: KAutoObjectWithList{kernel_} {}
KSynchronizationObject::~KSynchronizationObject() = default; KSynchronizationObject::~KSynchronizationObject() = default;

View File

@ -60,8 +60,8 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context,
namespace Kernel { namespace Kernel {
KThread::KThread(KernelCore& kernel) KThread::KThread(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel}, activity_pause_lock{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_}, activity_pause_lock{kernel_} {}
KThread::~KThread() = default; KThread::~KThread() = default;
ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio, ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_stack_top, s32 prio,
@ -479,7 +479,7 @@ ResultCode KThread::GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_m
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
ResultCode KThread::SetCoreMask(s32 core_id, u64 v_affinity_mask) { ResultCode KThread::SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask) {
ASSERT(parent != nullptr); ASSERT(parent != nullptr);
ASSERT(v_affinity_mask != 0); ASSERT(v_affinity_mask != 0);
KScopedLightLock lk{activity_pause_lock}; KScopedLightLock lk{activity_pause_lock};
@ -491,18 +491,18 @@ ResultCode KThread::SetCoreMask(s32 core_id, u64 v_affinity_mask) {
ASSERT(num_core_migration_disables >= 0); ASSERT(num_core_migration_disables >= 0);
// If the core id is no-update magic, preserve the ideal core id. // If the core id is no-update magic, preserve the ideal core id.
if (core_id == Svc::IdealCoreNoUpdate) { if (cpu_core_id == Svc::IdealCoreNoUpdate) {
core_id = virtual_ideal_core_id; cpu_core_id = virtual_ideal_core_id;
R_UNLESS(((1ULL << core_id) & v_affinity_mask) != 0, ResultInvalidCombination); R_UNLESS(((1ULL << cpu_core_id) & v_affinity_mask) != 0, ResultInvalidCombination);
} }
// Set the virtual core/affinity mask. // Set the virtual core/affinity mask.
virtual_ideal_core_id = core_id; virtual_ideal_core_id = cpu_core_id;
virtual_affinity_mask = v_affinity_mask; virtual_affinity_mask = v_affinity_mask;
// Translate the virtual core to a physical core. // Translate the virtual core to a physical core.
if (core_id >= 0) { if (cpu_core_id >= 0) {
core_id = Core::Hardware::VirtualToPhysicalCoreMap[core_id]; cpu_core_id = Core::Hardware::VirtualToPhysicalCoreMap[cpu_core_id];
} }
// Translate the virtual affinity mask to a physical one. // Translate the virtual affinity mask to a physical one.
@ -517,7 +517,7 @@ ResultCode KThread::SetCoreMask(s32 core_id, u64 v_affinity_mask) {
const KAffinityMask old_mask = physical_affinity_mask; const KAffinityMask old_mask = physical_affinity_mask;
// Set our new ideals. // Set our new ideals.
physical_ideal_core_id = core_id; physical_ideal_core_id = cpu_core_id;
physical_affinity_mask.SetAffinityMask(p_affinity_mask); physical_affinity_mask.SetAffinityMask(p_affinity_mask);
if (physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) { if (physical_affinity_mask.GetAffinityMask() != old_mask.GetAffinityMask()) {
@ -535,7 +535,7 @@ ResultCode KThread::SetCoreMask(s32 core_id, u64 v_affinity_mask) {
} }
} else { } else {
// Otherwise, we edit the original affinity for restoration later. // Otherwise, we edit the original affinity for restoration later.
original_physical_ideal_core_id = core_id; original_physical_ideal_core_id = cpu_core_id;
original_physical_affinity_mask.SetAffinityMask(p_affinity_mask); original_physical_affinity_mask.SetAffinityMask(p_affinity_mask);
} }
} }
@ -851,8 +851,8 @@ void KThread::RemoveWaiterImpl(KThread* thread) {
thread->SetLockOwner(nullptr); thread->SetLockOwner(nullptr);
} }
void KThread::RestorePriority(KernelCore& kernel, KThread* thread) { void KThread::RestorePriority(KernelCore& kernel_ctx, KThread* thread) {
ASSERT(kernel.GlobalSchedulerContext().IsLocked()); ASSERT(kernel_ctx.GlobalSchedulerContext().IsLocked());
while (true) { while (true) {
// We want to inherit priority where possible. // We want to inherit priority where possible.
@ -868,7 +868,7 @@ void KThread::RestorePriority(KernelCore& kernel, KThread* thread) {
// Ensure we don't violate condition variable red black tree invariants. // Ensure we don't violate condition variable red black tree invariants.
if (auto* cv_tree = thread->GetConditionVariableTree(); cv_tree != nullptr) { if (auto* cv_tree = thread->GetConditionVariableTree(); cv_tree != nullptr) {
BeforeUpdatePriority(kernel, cv_tree, thread); BeforeUpdatePriority(kernel_ctx, cv_tree, thread);
} }
// Change the priority. // Change the priority.
@ -877,11 +877,11 @@ void KThread::RestorePriority(KernelCore& kernel, KThread* thread) {
// Restore the condition variable, if relevant. // Restore the condition variable, if relevant.
if (auto* cv_tree = thread->GetConditionVariableTree(); cv_tree != nullptr) { if (auto* cv_tree = thread->GetConditionVariableTree(); cv_tree != nullptr) {
AfterUpdatePriority(kernel, cv_tree, thread); AfterUpdatePriority(kernel_ctx, cv_tree, thread);
} }
// Update the scheduler. // Update the scheduler.
KScheduler::OnThreadPriorityChanged(kernel, thread, old_priority); KScheduler::OnThreadPriorityChanged(kernel_ctx, thread, old_priority);
// Keep the lock owner up to date. // Keep the lock owner up to date.
KThread* lock_owner = thread->GetLockOwner(); KThread* lock_owner = thread->GetLockOwner();

View File

@ -111,7 +111,7 @@ public:
static constexpr s32 DefaultThreadPriority = 44; static constexpr s32 DefaultThreadPriority = 44;
static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1; static constexpr s32 IdleThreadPriority = Svc::LowestThreadPriority + 1;
explicit KThread(KernelCore& kernel); explicit KThread(KernelCore& kernel_);
~KThread() override; ~KThread() override;
public: public:
@ -318,7 +318,7 @@ public:
[[nodiscard]] ResultCode GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask); [[nodiscard]] ResultCode GetPhysicalCoreMask(s32* out_ideal_core, u64* out_affinity_mask);
[[nodiscard]] ResultCode SetCoreMask(s32 core_id, u64 v_affinity_mask); [[nodiscard]] ResultCode SetCoreMask(s32 cpu_core_id, u64 v_affinity_mask);
[[nodiscard]] ResultCode SetActivity(Svc::ThreadActivity activity); [[nodiscard]] ResultCode SetActivity(Svc::ThreadActivity activity);
@ -649,7 +649,7 @@ private:
std::function<void(void*)>&& init_func, std::function<void(void*)>&& init_func,
void* init_func_parameter); void* init_func_parameter);
static void RestorePriority(KernelCore& kernel, KThread* thread); static void RestorePriority(KernelCore& kernel_ctx, KThread* thread);
// For core KThread implementation // For core KThread implementation
ThreadContext32 thread_context_32{}; ThreadContext32 thread_context_32{};

View File

@ -9,8 +9,8 @@
namespace Kernel { namespace Kernel {
KTransferMemory::KTransferMemory(KernelCore& kernel) KTransferMemory::KTransferMemory(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel} {} : KAutoObjectWithSlabHeapAndContainer{kernel_} {}
KTransferMemory::~KTransferMemory() = default; KTransferMemory::~KTransferMemory() = default;

View File

@ -26,7 +26,7 @@ class KTransferMemory final
KERNEL_AUTOOBJECT_TRAITS(KTransferMemory, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KTransferMemory, KAutoObject);
public: public:
explicit KTransferMemory(KernelCore& kernel); explicit KTransferMemory(KernelCore& kernel_);
virtual ~KTransferMemory() override; virtual ~KTransferMemory() override;
ResultCode Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_); ResultCode Initialize(VAddr address_, std::size_t size_, Svc::MemoryPermission owner_perm_);

View File

@ -8,7 +8,8 @@
namespace Kernel { namespace Kernel {
KWritableEvent::KWritableEvent(KernelCore& kernel) : KAutoObjectWithSlabHeapAndContainer{kernel} {} KWritableEvent::KWritableEvent(KernelCore& kernel_)
: KAutoObjectWithSlabHeapAndContainer{kernel_} {}
KWritableEvent::~KWritableEvent() = default; KWritableEvent::~KWritableEvent() = default;

View File

@ -18,7 +18,7 @@ class KWritableEvent final
KERNEL_AUTOOBJECT_TRAITS(KWritableEvent, KAutoObject); KERNEL_AUTOOBJECT_TRAITS(KWritableEvent, KAutoObject);
public: public:
explicit KWritableEvent(KernelCore& kernel); explicit KWritableEvent(KernelCore& kernel_);
~KWritableEvent() override; ~KWritableEvent() override;
virtual void Destroy() override; virtual void Destroy() override;

View File

@ -51,11 +51,11 @@ MICROPROFILE_DEFINE(Kernel_SVC, "Kernel", "SVC", MP_RGB(70, 200, 70));
namespace Kernel { namespace Kernel {
struct KernelCore::Impl { struct KernelCore::Impl {
explicit Impl(Core::System& system, KernelCore& kernel) explicit Impl(Core::System& system_, KernelCore& kernel_)
: time_manager{system}, object_list_container{kernel}, system{system} {} : time_manager{system_}, object_list_container{kernel_}, system{system_} {}
void SetMulticore(bool is_multicore) { void SetMulticore(bool is_multi) {
this->is_multicore = is_multicore; is_multicore = is_multi;
} }
void Initialize(KernelCore& kernel) { void Initialize(KernelCore& kernel) {
@ -599,19 +599,19 @@ struct KernelCore::Impl {
irs_shared_mem = KSharedMemory::Create(system.Kernel()); irs_shared_mem = KSharedMemory::Create(system.Kernel());
time_shared_mem = KSharedMemory::Create(system.Kernel()); time_shared_mem = KSharedMemory::Create(system.Kernel());
hid_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, hid_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{hid_phys_addr, hid_size / PageSize}, {hid_phys_addr, hid_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read, Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
hid_phys_addr, hid_size, "HID:SharedMemory"); hid_phys_addr, hid_size, "HID:SharedMemory");
font_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, font_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{font_phys_addr, font_size / PageSize}, {font_phys_addr, font_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read, Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
font_phys_addr, font_size, "Font:SharedMemory"); font_phys_addr, font_size, "Font:SharedMemory");
irs_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, irs_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{irs_phys_addr, irs_size / PageSize}, {irs_phys_addr, irs_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read, Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
irs_phys_addr, irs_size, "IRS:SharedMemory"); irs_phys_addr, irs_size, "IRS:SharedMemory");
time_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, time_shared_mem->Initialize(system.DeviceMemory(), nullptr,
{time_phys_addr, time_size / PageSize}, {time_phys_addr, time_size / PageSize},
Svc::MemoryPermission::None, Svc::MemoryPermission::Read, Svc::MemoryPermission::None, Svc::MemoryPermission::Read,
time_phys_addr, time_size, "Time:SharedMemory"); time_phys_addr, time_size, "Time:SharedMemory");