mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 22:57:22 +00:00
kernel/handle_table: Remove usages of the global system instance
Removes even more usages of the global system instance, trimming away more dependencies on global variables and making them explicit in the interface.
This commit is contained in:
parent
4ad69ca96e
commit
52e83f0d5c
4 changed files with 15 additions and 8 deletions
|
@ -8,8 +8,9 @@
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/errors.h"
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/handle_table.h"
|
#include "core/hle/kernel/handle_table.h"
|
||||||
#include "core/hle/kernel/scheduler.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
#include "core/hle/kernel/scheduler.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -23,7 +24,7 @@ constexpr u16 GetGeneration(Handle handle) {
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
HandleTable::HandleTable() {
|
HandleTable::HandleTable(KernelCore& kernel) : kernel{kernel} {
|
||||||
Clear();
|
Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,9 +105,9 @@ bool HandleTable::IsValid(Handle handle) const {
|
||||||
|
|
||||||
std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const {
|
std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const {
|
||||||
if (handle == CurrentThread) {
|
if (handle == CurrentThread) {
|
||||||
return SharedFrom(Core::System::GetInstance().CurrentScheduler().GetCurrentThread());
|
return SharedFrom(kernel.CurrentScheduler().GetCurrentThread());
|
||||||
} else if (handle == CurrentProcess) {
|
} else if (handle == CurrentProcess) {
|
||||||
return SharedFrom(Core::System::GetInstance().CurrentProcess());
|
return SharedFrom(kernel.CurrentProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsValid(handle)) {
|
if (!IsValid(handle)) {
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
class KernelCore;
|
||||||
|
|
||||||
enum KernelHandle : Handle {
|
enum KernelHandle : Handle {
|
||||||
InvalidHandle = 0,
|
InvalidHandle = 0,
|
||||||
CurrentThread = 0xFFFF8000,
|
CurrentThread = 0xFFFF8000,
|
||||||
|
@ -48,7 +50,7 @@ public:
|
||||||
/// This is the maximum limit of handles allowed per process in Horizon
|
/// This is the maximum limit of handles allowed per process in Horizon
|
||||||
static constexpr std::size_t MAX_COUNT = 1024;
|
static constexpr std::size_t MAX_COUNT = 1024;
|
||||||
|
|
||||||
HandleTable();
|
explicit HandleTable(KernelCore& kernel);
|
||||||
~HandleTable();
|
~HandleTable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +136,9 @@ private:
|
||||||
|
|
||||||
/// Head of the free slots linked list.
|
/// Head of the free slots linked list.
|
||||||
u16 next_free_slot = 0;
|
u16 next_free_slot = 0;
|
||||||
|
|
||||||
|
/// Underlying kernel instance that this handle table operates under.
|
||||||
|
KernelCore& kernel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -50,7 +50,8 @@ namespace Kernel {
|
||||||
|
|
||||||
struct KernelCore::Impl {
|
struct KernelCore::Impl {
|
||||||
explicit Impl(Core::System& system, KernelCore& kernel)
|
explicit Impl(Core::System& system, KernelCore& kernel)
|
||||||
: global_scheduler{kernel}, synchronization{system}, time_manager{system}, system{system} {}
|
: global_scheduler{kernel}, synchronization{system}, time_manager{system},
|
||||||
|
global_handle_table{kernel}, system{system} {}
|
||||||
|
|
||||||
void SetMulticore(bool is_multicore) {
|
void SetMulticore(bool is_multicore) {
|
||||||
this->is_multicore = is_multicore;
|
this->is_multicore = is_multicore;
|
||||||
|
@ -307,7 +308,7 @@ struct KernelCore::Impl {
|
||||||
|
|
||||||
// This is the kernel's handle table or supervisor handle table which
|
// This is the kernel's handle table or supervisor handle table which
|
||||||
// stores all the objects in place.
|
// stores all the objects in place.
|
||||||
Kernel::HandleTable global_handle_table;
|
HandleTable global_handle_table;
|
||||||
|
|
||||||
/// Map of named ports managed by the kernel, which can be retrieved using
|
/// Map of named ports managed by the kernel, which can be retrieved using
|
||||||
/// the ConnectToPort SVC.
|
/// the ConnectToPort SVC.
|
||||||
|
|
|
@ -408,7 +408,7 @@ void Process::LoadModule(CodeSet code_set, VAddr base_addr) {
|
||||||
Process::Process(Core::System& system)
|
Process::Process(Core::System& system)
|
||||||
: SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>(
|
: SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>(
|
||||||
system)},
|
system)},
|
||||||
address_arbiter{system}, mutex{system}, system{system} {}
|
handle_table{system.Kernel()}, address_arbiter{system}, mutex{system}, system{system} {}
|
||||||
|
|
||||||
Process::~Process() = default;
|
Process::~Process() = default;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue