xenia/tools/alloy-sandbox/alloy-sandbox.cc

72 lines
2.1 KiB
C++
Raw Normal View History

/**
******************************************************************************
* 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. *
******************************************************************************
*/
#include <alloy/alloy.h>
2014-07-14 04:15:37 +00:00
#include <alloy/backend/ivm/ivm_backend.h>
#include <alloy/backend/x64/x64_backend.h>
#include <alloy/runtime/raw_module.h>
2014-07-30 03:29:50 +00:00
#include <poly/poly.h>
2014-07-13 05:59:16 +00:00
#include <xenia/export_resolver.h>
#include <xenia/cpu/xenon_memory.h>
#include <xenia/cpu/xenon_runtime.h>
2014-07-13 05:59:16 +00:00
#include <xenia/cpu/xenon_thread_state.h>
#include <gflags/gflags.h>
using namespace alloy;
using namespace alloy::backend;
using namespace alloy::runtime;
using namespace xe;
using namespace xe::cpu;
int alloy_sandbox(int argc, xechar_t** argv) {
2014-05-28 20:59:43 +00:00
Profiler::Initialize();
2014-05-28 05:54:40 +00:00
xe::Profiler::ThreadEnter("main");
XenonMemory* memory = new XenonMemory();
ExportResolver* export_resolver = new ExportResolver();
XenonRuntime* runtime = new XenonRuntime(memory, export_resolver);
2014-07-14 04:15:37 +00:00
std::unique_ptr<Backend> backend;
// backend.reset(new alloy::backend::ivm::IVMBackend(runtime));
// backend.reset(new alloy::backend::x64::X64Backend(runtime));
runtime->Initialize(std::move(backend));
2014-07-14 04:53:31 +00:00
auto module = std::make_unique<RawModule>(runtime);
module->LoadFile(0x82000000, "test\\codegen\\instr_add.bin");
2014-07-14 04:53:31 +00:00
runtime->AddModule(std::move(module));
2014-07-13 05:59:16 +00:00
XenonThreadState* thread_state =
new XenonThreadState(runtime, 100, 64 * 1024, 0);
Function* fn;
runtime->ResolveFunction(0x82000000, &fn);
2013-12-25 00:23:53 +00:00
auto ctx = thread_state->context();
ctx->lr = 0xBEBEBEBE;
ctx->r[5] = 10;
ctx->r[25] = 25;
fn->Call(thread_state, ctx->lr);
2013-12-25 00:23:53 +00:00
auto result = ctx->r[11];
2014-07-13 05:59:16 +00:00
printf("%llu", result);
delete thread_state;
delete runtime;
delete memory;
2014-05-28 05:54:40 +00:00
xe::Profiler::Dump();
xe::Profiler::ThreadExit();
2013-12-25 00:23:53 +00:00
return 0;
}
// ehhh
#include <xenia/platform.cc>
XE_MAIN_THUNK(alloy_sandbox, "alloy-sandbox");