mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 23:24:26 -04:00
kern: add KProcess members
This commit is contained in:
parent
772e1f1c4f
commit
fba8fb539d
15 changed files with 460 additions and 96 deletions
|
@ -21,21 +21,134 @@
|
|||
#include <mesosphere/kern_k_handle_table.hpp>
|
||||
#include <mesosphere/kern_k_thread.hpp>
|
||||
#include <mesosphere/kern_k_thread_local_page.hpp>
|
||||
#include <mesosphere/kern_k_shared_memory_info.hpp>
|
||||
#include <mesosphere/kern_k_worker_task.hpp>
|
||||
#include <mesosphere/kern_select_page_table.hpp>
|
||||
#include <mesosphere/kern_k_condition_variable.hpp>
|
||||
#include <mesosphere/kern_k_address_arbiter.hpp>
|
||||
#include <mesosphere/kern_k_capabilities.hpp>
|
||||
#include <mesosphere/kern_k_wait_object.hpp>
|
||||
#include <mesosphere/kern_k_dynamic_slab_heap.hpp>
|
||||
#include <mesosphere/kern_k_page_table_manager.hpp>
|
||||
|
||||
namespace ams::kern {
|
||||
|
||||
class KProcess final : public KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject> {
|
||||
class KProcess final : public KAutoObjectWithSlabHeapAndContainer<KProcess, KSynchronizationObject>, public KWorkerTask {
|
||||
MESOSPHERE_AUTOOBJECT_TRAITS(KProcess, KSynchronizationObject);
|
||||
/* TODO: This is a placeholder definition. */
|
||||
public:
|
||||
u64 GetCoreMask() const { MESOSPHERE_TODO_IMPLEMENT(); }
|
||||
u64 GetPriorityMask() const { MESOSPHERE_TODO_IMPLEMENT();}
|
||||
enum State {
|
||||
State_Created = ams::svc::ProcessState_Created,
|
||||
State_CreatedAttached = ams::svc::ProcessState_CreatedAttached,
|
||||
State_Running = ams::svc::ProcessState_Running,
|
||||
State_Crashed = ams::svc::ProcessState_Crashed,
|
||||
State_RunningAttached = ams::svc::ProcessState_RunningAttached,
|
||||
State_Terminating = ams::svc::ProcessState_Terminating,
|
||||
State_Terminated = ams::svc::ProcessState_Terminated,
|
||||
State_DebugBreak = ams::svc::ProcessState_DebugBreak,
|
||||
};
|
||||
|
||||
bool Is64Bit() const { MESOSPHERE_TODO_IMPLEMENT(); }
|
||||
using ThreadList = util::IntrusiveListMemberTraits<&KThread::process_list_node>::ListType;
|
||||
private:
|
||||
using SharedMemoryInfoList = util::IntrusiveListBaseTraits<KSharedMemoryInfo>::ListType;
|
||||
using TLPTree = util::IntrusiveRedBlackTreeBaseTraits<KThreadLocalPage>::TreeType<KThreadLocalPage>;
|
||||
using TLPIterator = TLPTree::iterator;
|
||||
private:
|
||||
KProcessPageTable page_table{};
|
||||
std::atomic<size_t> used_kernel_memory_size{};
|
||||
TLPTree fully_used_tlp_tree{};
|
||||
TLPTree partially_used_tlp_tree{};
|
||||
s32 ideal_core_id{};
|
||||
void *attached_object{};
|
||||
KResourceLimit *resource_limit{};
|
||||
KVirtualAddress system_resource_address{};
|
||||
size_t system_resource_num_pages{};
|
||||
size_t memory_release_hint{};
|
||||
State state{};
|
||||
KLightLock lock{};
|
||||
KLightLock list_lock{};
|
||||
KConditionVariable cond_var{};
|
||||
KAddressArbiter address_arbiter{};
|
||||
u64 entropy[4]{};
|
||||
bool is_signaled{};
|
||||
bool is_initialized{};
|
||||
bool is_application{};
|
||||
char name[13]{};
|
||||
std::atomic<u16> num_threads{};
|
||||
u16 peak_num_threads{};
|
||||
u32 flags{};
|
||||
KMemoryManager::Pool memory_pool{};
|
||||
s64 schedule_count{};
|
||||
KCapabilities capabilities{};
|
||||
ams::svc::ProgramId program_id{};
|
||||
u64 process_id{};
|
||||
s64 creation_time{};
|
||||
KProcessAddress code_address{};
|
||||
size_t code_size{};
|
||||
size_t main_thread_stack_size{};
|
||||
size_t max_process_memory{};
|
||||
u32 version{};
|
||||
KHandleTable handle_table{};
|
||||
KProcessAddress plr_address{};
|
||||
KThread *exception_thread{};
|
||||
ThreadList thread_list{};
|
||||
SharedMemoryInfoList shared_memory_list{};
|
||||
bool is_suspended{};
|
||||
bool is_jit_debug{};
|
||||
ams::svc::DebugEvent jit_debug_event_type{};
|
||||
ams::svc::DebugException jit_debug_exception_type{};
|
||||
uintptr_t jit_debug_params[4]{};
|
||||
u64 jit_debug_thread_id{};
|
||||
KWaitObject wait_object{};
|
||||
KThread *running_threads[cpu::NumCores]{};
|
||||
u64 running_thread_idle_counts[cpu::NumCores]{};
|
||||
KThread *pinned_threads[cpu::NumCores]{};
|
||||
std::atomic<s32> num_created_threads{};
|
||||
std::atomic<s64> cpu_time{};
|
||||
std::atomic<s64> num_process_switches{};
|
||||
std::atomic<s64> num_thread_switches{};
|
||||
std::atomic<s64> num_fpu_switches{};
|
||||
std::atomic<s64> num_supervisor_calls{};
|
||||
std::atomic<s64> num_ipc_messages{};
|
||||
std::atomic<s64> num_ipc_replies{};
|
||||
std::atomic<s64> num_ipc_receives{};
|
||||
KDynamicPageManager dynamic_page_manager{};
|
||||
KMemoryBlockSlabManager memory_block_slab_manager{};
|
||||
KBlockInfoManager block_info_manager{};
|
||||
KPageTableManager page_table_manager{};
|
||||
public:
|
||||
constexpr KProcess() { /* ... */ }
|
||||
virtual ~KProcess() { /* ... */ }
|
||||
|
||||
KThread *GetPreemptionStatePinnedThread(s32 core_id) { MESOSPHERE_TODO_IMPLEMENT(); }
|
||||
constexpr u64 GetProcessId() const { return this->process_id; }
|
||||
|
||||
constexpr u64 GetCoreMask() const { return this->capabilities.GetCoreMask(); }
|
||||
constexpr u64 GetPriorityMask() const { return this->capabilities.GetPriorityMask(); }
|
||||
|
||||
constexpr bool Is64Bit() const { return this->flags & ams::svc::CreateProcessFlag_Is64Bit; }
|
||||
|
||||
KThread *GetPreemptionStatePinnedThread(s32 core_id) const {
|
||||
MESOSPHERE_ASSERT(0 <= core_id && core_id < static_cast<s32>(cpu::NumCores));
|
||||
return this->pinned_threads[core_id];
|
||||
}
|
||||
|
||||
void SetPreemptionState();
|
||||
public:
|
||||
/* Overridden parent functions. */
|
||||
virtual bool IsInitialized() const override { return this->is_initialized; }
|
||||
|
||||
static void PostDestroy(uintptr_t arg) { /* ... */ }
|
||||
|
||||
virtual void Finalize() override;
|
||||
|
||||
virtual u64 GetId() const override { return this->GetProcessId(); }
|
||||
|
||||
virtual bool IsSignaled() const override {
|
||||
MESOSPHERE_ASSERT_THIS();
|
||||
MESOSPHERE_ASSERT(KScheduler::IsSchedulerLockedByCurrentThread());
|
||||
return this->is_signaled;
|
||||
}
|
||||
|
||||
virtual void DoWorkerTask() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue