xenia-cpu-ppc-tests is now building on linux
This commit is contained in:
@@ -15,14 +15,13 @@ namespace xe {
|
||||
namespace cpu {
|
||||
namespace backend {
|
||||
|
||||
Backend::Backend(Processor* processor)
|
||||
: processor_(processor), code_cache_(nullptr) {
|
||||
std::memset(&machine_info_, 0, sizeof(machine_info_));
|
||||
}
|
||||
|
||||
Backend::Backend() { std::memset(&machine_info_, 0, sizeof(machine_info_)); }
|
||||
Backend::~Backend() = default;
|
||||
|
||||
bool Backend::Initialize() { return true; }
|
||||
bool Backend::Initialize(Processor* processor) {
|
||||
processor_ = processor;
|
||||
return true;
|
||||
}
|
||||
|
||||
void* Backend::AllocThreadData() { return nullptr; }
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ class CodeCache;
|
||||
|
||||
class Backend {
|
||||
public:
|
||||
explicit Backend(Processor* processor);
|
||||
explicit Backend();
|
||||
virtual ~Backend();
|
||||
|
||||
Processor* processor() const { return processor_; }
|
||||
const MachineInfo* machine_info() const { return &machine_info_; }
|
||||
CodeCache* code_cache() const { return code_cache_; }
|
||||
|
||||
virtual bool Initialize();
|
||||
virtual bool Initialize(Processor* processor);
|
||||
|
||||
virtual void* AllocThreadData();
|
||||
virtual void FreeThreadData(void* thread_data);
|
||||
@@ -65,9 +65,9 @@ class Backend {
|
||||
virtual void UninstallBreakpoint(Breakpoint* breakpoint) {}
|
||||
|
||||
protected:
|
||||
Processor* processor_;
|
||||
Processor* processor_ = nullptr;
|
||||
MachineInfo machine_info_;
|
||||
CodeCache* code_cache_;
|
||||
CodeCache* code_cache_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace backend
|
||||
|
||||
@@ -42,8 +42,7 @@ class X64ThunkEmitter : public X64Emitter {
|
||||
ResolveFunctionThunk EmitResolveFunctionThunk();
|
||||
};
|
||||
|
||||
X64Backend::X64Backend(Processor* processor)
|
||||
: Backend(processor), code_cache_(nullptr) {
|
||||
X64Backend::X64Backend() : Backend(), code_cache_(nullptr) {
|
||||
if (cs_open(CS_ARCH_X86, CS_MODE_64, &capstone_handle_) != CS_ERR_OK) {
|
||||
assert_always("Failed to initialize capstone");
|
||||
}
|
||||
@@ -61,8 +60,8 @@ X64Backend::~X64Backend() {
|
||||
ExceptionHandler::Uninstall(&ExceptionCallbackThunk, this);
|
||||
}
|
||||
|
||||
bool X64Backend::Initialize() {
|
||||
if (!Backend::Initialize()) {
|
||||
bool X64Backend::Initialize(Processor* processor) {
|
||||
if (!Backend::Initialize(processor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class X64Backend : public Backend {
|
||||
public:
|
||||
static const uint32_t kForceReturnAddress = 0x9FFF0000u;
|
||||
|
||||
explicit X64Backend(Processor* processor);
|
||||
explicit X64Backend();
|
||||
~X64Backend() override;
|
||||
|
||||
X64CodeCache* code_cache() const { return code_cache_.get(); }
|
||||
@@ -53,7 +53,7 @@ class X64Backend : public Backend {
|
||||
return resolve_function_thunk_;
|
||||
}
|
||||
|
||||
bool Initialize() override;
|
||||
bool Initialize(Processor* processor) override;
|
||||
|
||||
void CommitExecutableRange(uint32_t guest_low, uint32_t guest_high) override;
|
||||
|
||||
|
||||
51
src/xenia/cpu/backend/x64/x64_code_cache_posix.cc
Normal file
51
src/xenia/cpu/backend/x64/x64_code_cache_posix.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2017 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/cpu/backend/x64/x64_code_cache.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
|
||||
class PosixX64CodeCache : public X64CodeCache {
|
||||
public:
|
||||
PosixX64CodeCache();
|
||||
~PosixX64CodeCache() override;
|
||||
|
||||
bool Initialize() override;
|
||||
|
||||
void* LookupUnwindInfo(uint64_t host_pc) override { return nullptr; }
|
||||
|
||||
private:
|
||||
/*
|
||||
UnwindReservation RequestUnwindReservation(uint8_t* entry_address) override;
|
||||
void PlaceCode(uint32_t guest_address, void* machine_code, size_t code_size,
|
||||
size_t stack_size, void* code_address,
|
||||
UnwindReservation unwind_reservation) override;
|
||||
|
||||
void InitializeUnwindEntry(uint8_t* unwind_entry_address,
|
||||
size_t unwind_table_slot, void* code_address,
|
||||
size_t code_size, size_t stack_size);
|
||||
*/
|
||||
};
|
||||
|
||||
std::unique_ptr<X64CodeCache> X64CodeCache::Create() {
|
||||
return std::make_unique<PosixX64CodeCache>();
|
||||
}
|
||||
|
||||
PosixX64CodeCache::PosixX64CodeCache() = default;
|
||||
PosixX64CodeCache::~PosixX64CodeCache() = default;
|
||||
|
||||
bool PosixX64CodeCache::Initialize() { return X64CodeCache::Initialize(); }
|
||||
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace cpu
|
||||
} // namespace xe
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/platform.h"
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
#include "xenia/cpu/cpu_flags.h"
|
||||
#include "xenia/cpu/ppc/ppc_context.h"
|
||||
#include "xenia/cpu/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/processor.h"
|
||||
@@ -188,9 +189,25 @@ class TestRunner {
|
||||
// Reset memory.
|
||||
memory->Reset();
|
||||
|
||||
std::unique_ptr<xe::cpu::backend::Backend> backend;
|
||||
if (!backend) {
|
||||
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
|
||||
if (FLAGS_cpu == "x64") {
|
||||
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
||||
}
|
||||
#endif // XENIA_HAS_X64_BACKEND
|
||||
if (FLAGS_cpu == "any") {
|
||||
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
|
||||
if (!backend) {
|
||||
backend.reset(new xe::cpu::backend::x64::X64Backend());
|
||||
}
|
||||
#endif // XENIA_HAS_X64_BACKEND
|
||||
}
|
||||
}
|
||||
|
||||
// Setup a fresh processor.
|
||||
processor.reset(new Processor(memory.get(), nullptr));
|
||||
processor->Setup();
|
||||
processor->Setup(std::move(backend));
|
||||
processor->set_debug_info_flags(DebugInfoFlags::kDebugInfoAll);
|
||||
|
||||
// Load the binary module.
|
||||
|
||||
@@ -7,9 +7,9 @@ project("xenia-cpu-ppc-tests")
|
||||
kind("ConsoleApp")
|
||||
language("C++")
|
||||
links({
|
||||
"xenia-core",
|
||||
"xenia-cpu-backend-x64",
|
||||
"xenia-cpu",
|
||||
"xenia-core",
|
||||
"xenia-base",
|
||||
"gflags",
|
||||
"capstone", -- cpu-backend-x64
|
||||
|
||||
@@ -95,7 +95,7 @@ Processor::~Processor() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Processor::Setup() {
|
||||
bool Processor::Setup(std::unique_ptr<backend::Backend> backend) {
|
||||
// TODO(benvanik): query mode from debugger?
|
||||
debug_info_flags_ = 0;
|
||||
|
||||
@@ -113,26 +113,10 @@ bool Processor::Setup() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<xe::cpu::backend::Backend> backend;
|
||||
if (!backend) {
|
||||
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
|
||||
if (FLAGS_cpu == "x64") {
|
||||
backend.reset(new xe::cpu::backend::x64::X64Backend(this));
|
||||
}
|
||||
#endif // XENIA_HAS_X64_BACKEND
|
||||
if (FLAGS_cpu == "any") {
|
||||
#if defined(XENIA_HAS_X64_BACKEND) && XENIA_HAS_X64_BACKEND
|
||||
if (!backend) {
|
||||
backend.reset(new xe::cpu::backend::x64::X64Backend(this));
|
||||
}
|
||||
#endif // XENIA_HAS_X64_BACKEND
|
||||
}
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
return false;
|
||||
}
|
||||
if (!backend->Initialize()) {
|
||||
if (!backend->Initialize(this)) {
|
||||
return false;
|
||||
}
|
||||
if (!frontend->Initialize()) {
|
||||
|
||||
@@ -71,7 +71,7 @@ class Processor {
|
||||
backend::Backend* backend() const { return backend_.get(); }
|
||||
ExportResolver* export_resolver() const { return export_resolver_; }
|
||||
|
||||
bool Setup();
|
||||
bool Setup(std::unique_ptr<backend::Backend> backend);
|
||||
|
||||
// Runs any pre-launch logic once the module and thread have been setup.
|
||||
void PreLaunch();
|
||||
|
||||
24
src/xenia/cpu/stack_walker_posix.cc
Normal file
24
src/xenia/cpu/stack_walker_posix.cc
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2017 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "xenia/cpu/stack_walker.h"
|
||||
|
||||
#include "xenia/base/logging.h"
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
|
||||
std::unique_ptr<StackWalker> StackWalker::Create(
|
||||
backend::CodeCache* code_cache) {
|
||||
XELOGD("Stack walker unimplemented on posix");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace cpu
|
||||
} // namespace xe
|
||||
@@ -39,8 +39,9 @@ class TestFunction {
|
||||
|
||||
#if XENIA_TEST_X64
|
||||
{
|
||||
auto backend = std::make_unique<xe::cpu::backend::x64::X64Backend>();
|
||||
auto processor = std::make_unique<Processor>(memory.get(), nullptr);
|
||||
processor->Setup();
|
||||
processor->Setup(std::move(backend));
|
||||
processors.emplace_back(std::move(processor));
|
||||
}
|
||||
#endif // XENIA_TEST_X64
|
||||
|
||||
Reference in New Issue
Block a user