Starting to clean up thread state.

This commit is contained in:
Ben Vanik
2015-05-16 16:34:14 -07:00
parent 147a70b9c1
commit da630cc159
5 changed files with 37 additions and 28 deletions

View File

@@ -197,9 +197,9 @@ class TestRunner {
// Simulate a thread.
uint32_t stack_size = 64 * 1024;
uint32_t stack_address = START_ADDRESS - stack_size;
uint32_t thread_state_address = stack_address - 0x1000;
uint32_t pcr_address = stack_address - 0x1000;
thread_state.reset(new ThreadState(processor.get(), 0x100, stack_address,
stack_size, thread_state_address));
stack_size, pcr_address));
return true;
}

View File

@@ -28,14 +28,14 @@ thread_local ThreadState* thread_state_ = nullptr;
ThreadState::ThreadState(Processor* processor, uint32_t thread_id,
uint32_t stack_address, uint32_t stack_size,
uint32_t thread_state_address)
uint32_t pcr_address)
: processor_(processor),
memory_(processor->memory()),
thread_id_(thread_id),
name_(""),
backend_data_(0),
stack_size_(stack_size),
thread_state_address_(thread_state_address) {
pcr_address_(pcr_address) {
if (thread_id_ == UINT_MAX) {
// System thread. Assign the system thread ID with a high bit
// set so people know what's up.
@@ -87,7 +87,7 @@ ThreadState::ThreadState(Processor* processor, uint32_t thread_id,
// Set initial registers.
context_->r[1] = stack_position;
context_->r[13] = thread_state_address_;
context_->r[13] = pcr_address_;
// Pad out stack a bit, as some games seem to overwrite the caller by about
// 16 to 32b.

View File

@@ -22,7 +22,7 @@ class Processor;
class ThreadState {
public:
ThreadState(Processor* processor, uint32_t thread_id, uint32_t stack_address,
uint32_t stack_size, uint32_t thread_state_address);
uint32_t stack_size, uint32_t pcr_address);
~ThreadState();
Processor* processor() const { return processor_; }
@@ -33,7 +33,7 @@ class ThreadState {
void* backend_data() const { return backend_data_; }
uint32_t stack_address() const { return stack_address_; }
uint32_t stack_size() const { return stack_size_; }
uint32_t thread_state_address() const { return thread_state_address_; }
uint32_t pcr_address() const { return pcr_address_; }
xe::cpu::frontend::PPCContext* context() const { return context_; }
bool Suspend() { return Suspend(~0); }
@@ -53,7 +53,7 @@ class ThreadState {
uint32_t stack_address_;
bool stack_allocated_;
uint32_t stack_size_;
uint32_t thread_state_address_;
uint32_t pcr_address_;
// NOTE: must be 64b aligned for SSE ops.
xe::cpu::frontend::PPCContext* context_;