kern: implement process exit

This commit is contained in:
Michael Scire 2020-07-22 23:52:29 -07:00 committed by SciresM
parent 3917ecad46
commit 28aab09b5d
10 changed files with 466 additions and 9 deletions

View file

@ -50,7 +50,13 @@ namespace ams::kern {
public:
virtual void OnFinalizeSynchronizationObject() override;
virtual bool IsSignaled() const override;
private:
static Result ProcessDebugEvent(ams::svc::DebugEvent event, uintptr_t param0, uintptr_t param1, uintptr_t param2, uintptr_t param3, uintptr_t param4);
public:
static Result OnDebugEvent(ams::svc::DebugEvent event, uintptr_t param0 = 0, uintptr_t param1 = 0, uintptr_t param2 = 0, uintptr_t param3 = 0, uintptr_t param4 = 0);
static Result OnExitProcess(KProcess *process);
static Result OnTerminateProcess(KProcess *process);
static Result OnExitThread(KThread *thread);
static KEventInfo *CreateDebugEvent(ams::svc::DebugEvent event, uintptr_t param0, uintptr_t param1, uintptr_t param2, uintptr_t param3, uintptr_t param4, u64 thread_id);
};

View file

@ -211,6 +211,12 @@ namespace ams::kern {
return KMemoryLayout::IsHeapPhysicalAddress(std::addressof(this->cached_physical_heap_region), phys_addr, this->cached_physical_heap_region);
}
bool IsHeapPhysicalAddressForFinalize(KPhysicalAddress phys_addr) {
MESOSPHERE_ASSERT(!this->IsLockedByCurrentThread());
return KMemoryLayout::IsHeapPhysicalAddress(std::addressof(this->cached_physical_heap_region), phys_addr, this->cached_physical_heap_region);
}
bool IsHeapPhysicalAddress(KPhysicalAddress phys_addr, size_t size) {
MESOSPHERE_ASSERT(this->IsLockedByCurrentThread());

View file

@ -120,6 +120,9 @@ namespace ams::kern {
KPageTableManager page_table_manager{};
private:
Result Initialize(const ams::svc::CreateProcessParameter &params);
void StartTermination();
void FinishTermination();
public:
KProcess() { /* ... */ }
virtual ~KProcess() { /* ... */ }
@ -182,6 +185,7 @@ namespace ams::kern {
ThreadList &GetThreadList() { return this->thread_list; }
const ThreadList &GetThreadList() const { return this->thread_list; }
constexpr void *GetDebugObject() const { return this->attached_object; }
KProcess::State SetDebugObject(void *debug_object);
void ClearDebugObject(KProcess::State state);

View file

@ -448,6 +448,9 @@ namespace ams::kern {
Result Run();
void Exit();
void Terminate();
ThreadState RequestTerminate();
Result Sleep(s64 timeout);
ALWAYS_INLINE void *GetStackTop() const { return reinterpret_cast<StackParameters *>(this->kernel_stack_top) - 1; }