From 4fdebd530f338d36d83b36653d6fbbb86d042a31 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Sun, 5 Jul 2015 13:37:10 -0500 Subject: [PATCH] XThread bool guest thread --- src/xenia/kernel/objects/xthread.cc | 8 +++++--- src/xenia/kernel/objects/xthread.h | 4 +++- src/xenia/kernel/objects/xuser_module.cc | 2 +- src/xenia/kernel/xboxkrnl_threading.cc | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 494086b85..46ef3707b 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -41,7 +41,8 @@ xe::mutex critical_region_; XThread::XThread(KernelState* kernel_state, uint32_t stack_size, uint32_t xapi_thread_startup, uint32_t start_address, - uint32_t start_context, uint32_t creation_flags) + uint32_t start_context, uint32_t creation_flags, + bool guest_thread) : XObject(kernel_state, kTypeThread), thread_id_(++next_xthread_id), thread_handle_(0), @@ -50,7 +51,8 @@ XThread::XThread(KernelState* kernel_state, uint32_t stack_size, thread_state_(0), priority_(0), affinity_(0), - irql_(0) { + irql_(0), + guest_thread_(guest_thread) { creation_params_.stack_size = stack_size; creation_params_.xapi_thread_startup = xapi_thread_startup; creation_params_.start_address = start_address; @@ -758,7 +760,7 @@ void* XThread::GetWaitHandle() { return event_->GetWaitHandle(); } XHostThread::XHostThread(KernelState* kernel_state, uint32_t stack_size, uint32_t creation_flags, std::function host_fn) - : XThread(kernel_state, stack_size, 0, 0, 0, creation_flags), + : XThread(kernel_state, stack_size, 0, 0, 0, creation_flags, false), host_fn_(host_fn) {} void XHostThread::Execute() { diff --git a/src/xenia/kernel/objects/xthread.h b/src/xenia/kernel/objects/xthread.h index 03516833f..70e2a8ed2 100644 --- a/src/xenia/kernel/objects/xthread.h +++ b/src/xenia/kernel/objects/xthread.h @@ -81,7 +81,7 @@ class XThread : public XObject { public: XThread(KernelState* kernel_state, uint32_t stack_size, uint32_t xapi_thread_startup, uint32_t start_address, - uint32_t start_context, uint32_t creation_flags); + uint32_t start_context, uint32_t creation_flags, bool guest_thread); virtual ~XThread(); static bool IsInThread(XThread* other); @@ -92,6 +92,7 @@ class XThread : public XObject { uint32_t tls_ptr() const { return tls_address_; } uint32_t pcr_ptr() const { return pcr_address_; } uint32_t thread_state_ptr() const { return thread_state_address_; } + bool guest_thread() const { return guest_thread_; } cpu::ThreadState* thread_state() const { return thread_state_; } uint32_t thread_id() const { return thread_id_; } @@ -156,6 +157,7 @@ class XThread : public XObject { uint32_t pcr_address_; uint32_t thread_state_address_; cpu::ThreadState* thread_state_; + bool guest_thread_; // Launched into guest code? std::string name_; diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 4b30c7a20..f4fbdee69 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -206,7 +206,7 @@ X_STATUS XUserModule::Launch(uint32_t flags) { // Create a thread to run in. auto thread = object_ref( - new XThread(kernel_state(), stack_size_, 0, entry_point_, 0, 0)); + new XThread(kernel_state(), stack_size_, 0, entry_point_, 0, 0, true)); X_STATUS result = thread->Create(); if (XFAILED(result)) { diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index d24aa08f4..9d91891b8 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -117,7 +117,7 @@ SHIM_CALL ExCreateThread_shim(PPCContext* ppc_context, auto thread = object_ref( new XThread(kernel_state, stack_size, xapi_thread_startup, start_address, - start_context, creation_flags)); + start_context, creation_flags, true)); X_STATUS result = thread->Create(); if (XFAILED(result)) {