First instruction executed in the test runner!

Fixes #7.
This commit is contained in:
Ben Vanik
2013-01-27 17:49:32 -08:00
parent bba99d4a22
commit 12d9c3d15e
24 changed files with 335 additions and 39 deletions

View File

@@ -10,6 +10,11 @@
#ifndef XENIA_CPU_CODEGEN_MODULE_GENERATOR_H_
#define XENIA_CPU_CODEGEN_MODULE_GENERATOR_H_
#include <xenia/common.h>
#include <xenia/core.h>
#include <tr1/unordered_map>
#include <xenia/cpu/sdb.h>
#include <xenia/core/memory.h>
#include <xenia/kernel/export.h>
@@ -17,11 +22,11 @@
namespace llvm {
class DIBuilder;
class Function;
class FunctionType;
class LLVMContext;
class Module;
class FunctionType;
class Function;
class DIBuilder;
class MDNode;
}
@@ -42,6 +47,9 @@ public:
int Generate();
void AddFunctionsToMap(
std::tr1::unordered_map<uint32_t, llvm::Function*>& map);
private:
class CodegenFunction {
public:

View File

@@ -13,15 +13,18 @@
#include <xenia/common.h>
#include <xenia/core.h>
#include <tr1/unordered_map>
#include <xenia/cpu/sdb.h>
#include <xenia/kernel/export.h>
#include <xenia/kernel/user_module.h>
namespace llvm {
class ExecutionEngine;
class Function;
class LLVMContext;
class Module;
class ExecutionEngine;
}
namespace xe {
@@ -37,6 +40,9 @@ namespace xe {
namespace cpu {
typedef std::tr1::unordered_map<uint32_t, llvm::Function*> FunctionMap;
class ExecModule {
public:
ExecModule(
@@ -48,6 +54,8 @@ public:
int PrepareUserModule(kernel::UserModule* user_module);
int PrepareRawBinary(uint32_t start_address, uint32_t end_address);
void AddFunctionsToMap(FunctionMap& map);
void Dump();
private:
@@ -65,6 +73,8 @@ private:
shared_ptr<llvm::LLVMContext> context_;
shared_ptr<llvm::Module> gen_module_;
auto_ptr<codegen::ModuleGenerator> codegen_;
FunctionMap fns_;
};

View File

@@ -143,7 +143,13 @@ typedef struct XECACHEALIGN64 xe_ppc_state {
// Runtime-specific data pointer. Used on callbacks to get access to the
// current runtime and its data.
void* runtime_data;
void* processor;
void* thread_state;
void* runtime;
void SetRegFromString(const char* name, const char* value);
bool CompareRegWithString(const char* name, const char* value,
char* out_value, size_t out_value_size);
} xe_ppc_state_t;

View File

@@ -12,15 +12,18 @@
#include <xenia/core.h>
#include <tr1/unordered_map>
#include <vector>
#include <xenia/cpu/exec_module.h>
#include <xenia/cpu/thread_state.h>
#include <xenia/kernel/export.h>
#include <xenia/kernel/user_module.h>
namespace llvm {
class ExecutionEngine;
class Function;
}
@@ -44,10 +47,15 @@ public:
int PrepareModule(kernel::UserModule* user_module,
shared_ptr<kernel::ExportResolver> export_resolver);
int Execute(uint32_t address);
uint32_t CreateCallback(void (*callback)(void* data), void* data);
ThreadState* AllocThread(uint32_t stack_address, uint32_t stack_size);
void DeallocThread(ThreadState* thread_state);
int Execute(ThreadState* thread_state, uint32_t address);
private:
llvm::Function* GetFunction(uint32_t address);
xe_pal_ref pal_;
xe_memory_ref memory_;
shared_ptr<llvm::ExecutionEngine> engine_;
@@ -55,6 +63,8 @@ private:
auto_ptr<llvm::LLVMContext> dummy_context_;
std::vector<ExecModule*> modules_;
FunctionMap all_fns_;
};

View File

@@ -77,7 +77,7 @@ public:
uint32_t start_address;
uint32_t end_address;
vector<FunctionBlock*> incoming_blocks;
std::vector<FunctionBlock*> incoming_blocks;
TargetType outgoing_type;
uint32_t outgoing_address;
@@ -114,11 +114,11 @@ public:
kernel::KernelExport* kernel_export;
ExceptionEntrySymbol* ee;
vector<FunctionCall*> incoming_calls;
vector<FunctionCall*> outgoing_calls;
vector<VariableAccess*> variable_accesses;
std::vector<FunctionCall*> incoming_calls;
std::vector<FunctionCall*> outgoing_calls;
std::vector<VariableAccess*> variable_accesses;
map<uint32_t, FunctionBlock*> blocks;
std::map<uint32_t, FunctionBlock*> blocks;
};
class VariableSymbol : public Symbol {
@@ -154,7 +154,7 @@ public:
VariableSymbol* GetVariable(uint32_t address);
Symbol* GetSymbol(uint32_t address);
int GetAllFunctions(vector<FunctionSymbol*>& functions);
int GetAllFunctions(std::vector<FunctionSymbol*>& functions);
void Write(const char* file_name);
void Dump();

View File

@@ -0,0 +1,45 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_CPU_THREAD_STATE_H_
#define XENIA_CPU_THREAD_STATE_H_
#include <xenia/core.h>
#include <xenia/cpu/ppc.h>
namespace xe {
namespace cpu {
class Processor;
class ThreadState {
public:
ThreadState(Processor* processor,
uint32_t stack_address, uint32_t stack_size);
~ThreadState();
xe_ppc_state_t* ppc_state();
private:
uint32_t stack_address_;
uint32_t stack_size_;
xe_ppc_state_t ppc_state_;
};
} // namespace cpu
} // namespace xe
#endif // XENIA_CPU_THREAD_STATE_H_

View File

@@ -13,12 +13,11 @@
#include <xenia/platform.h>
#include <xenia/platform_includes.h>
#include <tr1/memory>
namespace xe {
// TODO(benvanik): support other compilers/etc
using namespace std;
using namespace std::tr1;
using std::auto_ptr;
using std::tr1::shared_ptr;
} // namespace xe