Starting work on APCs, though nothing is hitting them yet.

This commit is contained in:
Ben Vanik
2014-01-11 22:12:05 -08:00
parent c50fbafbd9
commit 61e873cd31
6 changed files with 209 additions and 30 deletions

View File

@@ -10,6 +10,7 @@
#include <xenia/kernel/objects/xthread.h>
#include <xenia/cpu/cpu.h>
#include <xenia/kernel/native_list.h>
#include <xenia/kernel/xboxkrnl_threading.h>
#include <xenia/kernel/objects/xevent.h>
#include <xenia/kernel/objects/xuser_module.h>
@@ -53,6 +54,9 @@ XThread::XThread(KernelState* kernel_state,
creation_params_.stack_size = 16 * 1024 * 1024;
}
apc_lock_ = xe_mutex_alloc();
apc_list_ = new NativeList(kernel_state->memory());
event_ = new XEvent(kernel_state);
event_->Initialize(true, false);
@@ -64,6 +68,9 @@ XThread::~XThread() {
// Unregister first to prevent lookups while deleting.
kernel_state_->UnregisterThread(this);
delete apc_list_;
xe_mutex_free(apc_lock_);
event_->Release();
PlatformDestroy();
@@ -382,6 +389,14 @@ void XThread::LowerIrql(uint32_t new_irql) {
irql_ = new_irql;
}
void XThread::LockApc() {
xe_mutex_lock(apc_lock_);
}
void XThread::UnlockApc() {
xe_mutex_unlock(apc_lock_);
}
int32_t XThread::QueryPriority() {
return GetThreadPriority(thread_handle_);
}

View File

@@ -14,18 +14,13 @@
#include <xenia/xbox.h>
namespace xe {
namespace cpu {
class XenonThreadState;
}
}
XEDECLARECLASS2(xe, cpu, XenonThreadState);
namespace xe {
namespace kernel {
class NativeList;
class XEvent;
@@ -59,6 +54,10 @@ public:
uint32_t RaiseIrql(uint32_t new_irql);
void LowerIrql(uint32_t new_irql);
void LockApc();
void UnlockApc();
NativeList* apc_list() const { return apc_list_; }
int32_t QueryPriority();
void SetPriority(int32_t increment);
@@ -91,6 +90,8 @@ private:
char* name_;
uint32_t irql_;
xe_mutex_t* apc_lock_;
NativeList* apc_list_;
XEvent* event_;
};