diff options
| -rw-r--r-- | src/core/hle/kernel/handle_table.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/handle_table.h | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/process.h | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 22 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 5 |
7 files changed, 26 insertions, 35 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index 35448b576..fb30b6f8b 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp | |||
| @@ -8,7 +8,9 @@ | |||
| 8 | #include "core/core.h" | 8 | #include "core/core.h" |
| 9 | #include "core/hle/kernel/errors.h" | 9 | #include "core/hle/kernel/errors.h" |
| 10 | #include "core/hle/kernel/handle_table.h" | 10 | #include "core/hle/kernel/handle_table.h" |
| 11 | #include "core/hle/kernel/kernel.h" | ||
| 11 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/hle/kernel/scheduler.h" | ||
| 12 | #include "core/hle/kernel/thread.h" | 14 | #include "core/hle/kernel/thread.h" |
| 13 | 15 | ||
| 14 | namespace Kernel { | 16 | namespace Kernel { |
| @@ -22,7 +24,7 @@ constexpr u16 GetGeneration(Handle handle) { | |||
| 22 | } | 24 | } |
| 23 | } // Anonymous namespace | 25 | } // Anonymous namespace |
| 24 | 26 | ||
| 25 | HandleTable::HandleTable() { | 27 | HandleTable::HandleTable(KernelCore& kernel) : kernel{kernel} { |
| 26 | Clear(); | 28 | Clear(); |
| 27 | } | 29 | } |
| 28 | 30 | ||
| @@ -103,9 +105,9 @@ bool HandleTable::IsValid(Handle handle) const { | |||
| 103 | 105 | ||
| 104 | std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const { | 106 | std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const { |
| 105 | if (handle == CurrentThread) { | 107 | if (handle == CurrentThread) { |
| 106 | return SharedFrom(GetCurrentThread()); | 108 | return SharedFrom(kernel.CurrentScheduler().GetCurrentThread()); |
| 107 | } else if (handle == CurrentProcess) { | 109 | } else if (handle == CurrentProcess) { |
| 108 | return SharedFrom(Core::System::GetInstance().CurrentProcess()); | 110 | return SharedFrom(kernel.CurrentProcess()); |
| 109 | } | 111 | } |
| 110 | 112 | ||
| 111 | if (!IsValid(handle)) { | 113 | if (!IsValid(handle)) { |
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 8029660ed..c9dab8cdd 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| 16 | 16 | ||
| 17 | class KernelCore; | ||
| 18 | |||
| 17 | enum KernelHandle : Handle { | 19 | enum KernelHandle : Handle { |
| 18 | InvalidHandle = 0, | 20 | InvalidHandle = 0, |
| 19 | CurrentThread = 0xFFFF8000, | 21 | CurrentThread = 0xFFFF8000, |
| @@ -48,7 +50,7 @@ public: | |||
| 48 | /// This is the maximum limit of handles allowed per process in Horizon | 50 | /// This is the maximum limit of handles allowed per process in Horizon |
| 49 | static constexpr std::size_t MAX_COUNT = 1024; | 51 | static constexpr std::size_t MAX_COUNT = 1024; |
| 50 | 52 | ||
| 51 | HandleTable(); | 53 | explicit HandleTable(KernelCore& kernel); |
| 52 | ~HandleTable(); | 54 | ~HandleTable(); |
| 53 | 55 | ||
| 54 | /** | 56 | /** |
| @@ -134,6 +136,9 @@ private: | |||
| 134 | 136 | ||
| 135 | /// Head of the free slots linked list. | 137 | /// Head of the free slots linked list. |
| 136 | u16 next_free_slot = 0; | 138 | u16 next_free_slot = 0; |
| 139 | |||
| 140 | /// Underlying kernel instance that this handle table operates under. | ||
| 141 | KernelCore& kernel; | ||
| 137 | }; | 142 | }; |
| 138 | 143 | ||
| 139 | } // namespace Kernel | 144 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 1f2af7a1b..6e2014e08 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -50,7 +50,8 @@ namespace Kernel { | |||
| 50 | 50 | ||
| 51 | struct KernelCore::Impl { | 51 | struct KernelCore::Impl { |
| 52 | explicit Impl(Core::System& system, KernelCore& kernel) | 52 | explicit Impl(Core::System& system, KernelCore& kernel) |
| 53 | : global_scheduler{kernel}, synchronization{system}, time_manager{system}, system{system} {} | 53 | : global_scheduler{kernel}, synchronization{system}, time_manager{system}, |
| 54 | global_handle_table{kernel}, system{system} {} | ||
| 54 | 55 | ||
| 55 | void SetMulticore(bool is_multicore) { | 56 | void SetMulticore(bool is_multicore) { |
| 56 | this->is_multicore = is_multicore; | 57 | this->is_multicore = is_multicore; |
| @@ -307,7 +308,7 @@ struct KernelCore::Impl { | |||
| 307 | 308 | ||
| 308 | // This is the kernel's handle table or supervisor handle table which | 309 | // This is the kernel's handle table or supervisor handle table which |
| 309 | // stores all the objects in place. | 310 | // stores all the objects in place. |
| 310 | Kernel::HandleTable global_handle_table; | 311 | HandleTable global_handle_table; |
| 311 | 312 | ||
| 312 | /// Map of named ports managed by the kernel, which can be retrieved using | 313 | /// Map of named ports managed by the kernel, which can be retrieved using |
| 313 | /// the ConnectToPort SVC. | 314 | /// the ConnectToPort SVC. |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index c6fcb56ad..ff9d9248b 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -408,7 +408,7 @@ void Process::LoadModule(CodeSet code_set, VAddr base_addr) { | |||
| 408 | Process::Process(Core::System& system) | 408 | Process::Process(Core::System& system) |
| 409 | : SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>( | 409 | : SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>( |
| 410 | system)}, | 410 | system)}, |
| 411 | address_arbiter{system}, mutex{system}, system{system} {} | 411 | handle_table{system.Kernel()}, address_arbiter{system}, mutex{system}, system{system} {} |
| 412 | 412 | ||
| 413 | Process::~Process() = default; | 413 | Process::~Process() = default; |
| 414 | 414 | ||
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 9dabe3568..f45cb5674 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -382,12 +382,6 @@ private: | |||
| 382 | /// List of threads waiting for a condition variable | 382 | /// List of threads waiting for a condition variable |
| 383 | std::unordered_map<VAddr, std::list<std::shared_ptr<Thread>>> cond_var_threads; | 383 | std::unordered_map<VAddr, std::list<std::shared_ptr<Thread>>> cond_var_threads; |
| 384 | 384 | ||
| 385 | /// System context | ||
| 386 | Core::System& system; | ||
| 387 | |||
| 388 | /// Name of this process | ||
| 389 | std::string name; | ||
| 390 | |||
| 391 | /// Address of the top of the main thread's stack | 385 | /// Address of the top of the main thread's stack |
| 392 | VAddr main_thread_stack_top{}; | 386 | VAddr main_thread_stack_top{}; |
| 393 | 387 | ||
| @@ -399,6 +393,12 @@ private: | |||
| 399 | 393 | ||
| 400 | /// Process total image size | 394 | /// Process total image size |
| 401 | std::size_t image_size{}; | 395 | std::size_t image_size{}; |
| 396 | |||
| 397 | /// Name of this process | ||
| 398 | std::string name; | ||
| 399 | |||
| 400 | /// System context | ||
| 401 | Core::System& system; | ||
| 402 | }; | 402 | }; |
| 403 | 403 | ||
| 404 | } // namespace Kernel | 404 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 2b1092697..67148fa6d 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -13,16 +13,8 @@ | |||
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | #include "common/thread_queue_list.h" | 14 | #include "common/thread_queue_list.h" |
| 15 | #include "core/arm/arm_interface.h" | 15 | #include "core/arm/arm_interface.h" |
| 16 | #ifdef ARCHITECTURE_x86_64 | ||
| 17 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | ||
| 18 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | ||
| 19 | #endif | ||
| 20 | #include "core/arm/cpu_interrupt_handler.h" | ||
| 21 | #include "core/arm/exclusive_monitor.h" | ||
| 22 | #include "core/arm/unicorn/arm_unicorn.h" | 16 | #include "core/arm/unicorn/arm_unicorn.h" |
| 23 | #include "core/core.h" | 17 | #include "core/core.h" |
| 24 | #include "core/core_timing.h" | ||
| 25 | #include "core/core_timing_util.h" | ||
| 26 | #include "core/cpu_manager.h" | 18 | #include "core/cpu_manager.h" |
| 27 | #include "core/hardware_properties.h" | 19 | #include "core/hardware_properties.h" |
| 28 | #include "core/hle/kernel/errors.h" | 20 | #include "core/hle/kernel/errors.h" |
| @@ -36,6 +28,11 @@ | |||
| 36 | #include "core/hle/result.h" | 28 | #include "core/hle/result.h" |
| 37 | #include "core/memory.h" | 29 | #include "core/memory.h" |
| 38 | 30 | ||
| 31 | #ifdef ARCHITECTURE_x86_64 | ||
| 32 | #include "core/arm/dynarmic/arm_dynarmic_32.h" | ||
| 33 | #include "core/arm/dynarmic/arm_dynarmic_64.h" | ||
| 34 | #endif | ||
| 35 | |||
| 39 | namespace Kernel { | 36 | namespace Kernel { |
| 40 | 37 | ||
| 41 | bool Thread::ShouldWait(const Thread* thread) const { | 38 | bool Thread::ShouldWait(const Thread* thread) const { |
| @@ -540,13 +537,4 @@ ResultCode Thread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) { | |||
| 540 | return RESULT_SUCCESS; | 537 | return RESULT_SUCCESS; |
| 541 | } | 538 | } |
| 542 | 539 | ||
| 543 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 544 | |||
| 545 | /** | ||
| 546 | * Gets the current thread | ||
| 547 | */ | ||
| 548 | Thread* GetCurrentThread() { | ||
| 549 | return Core::System::GetInstance().CurrentScheduler().GetCurrentThread(); | ||
| 550 | } | ||
| 551 | |||
| 552 | } // namespace Kernel | 540 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index c0342c462..9808767e5 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -680,9 +680,4 @@ private: | |||
| 680 | std::string name; | 680 | std::string name; |
| 681 | }; | 681 | }; |
| 682 | 682 | ||
| 683 | /** | ||
| 684 | * Gets the current thread | ||
| 685 | */ | ||
| 686 | Thread* GetCurrentThread(); | ||
| 687 | |||
| 688 | } // namespace Kernel | 683 | } // namespace Kernel |