2013-12-07 06:57:16 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* 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>
|
2013-12-07 06:57:16 +00:00
|
|
|
#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>
|
2013-12-07 06:57:16 +00:00
|
|
|
#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>
|
2013-12-07 06:57:16 +00:00
|
|
|
|
|
|
|
#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");
|
|
|
|
|
2013-12-07 06:57:16 +00:00
|
|
|
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));
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-14 04:53:31 +00:00
|
|
|
auto module = std::make_unique<RawModule>(runtime);
|
2013-12-07 06:57:16 +00:00
|
|
|
module->LoadFile(0x82000000, "test\\codegen\\instr_add.bin");
|
2014-07-14 04:53:31 +00:00
|
|
|
runtime->AddModule(std::move(module));
|
2013-12-07 06:57:16 +00:00
|
|
|
|
2014-07-13 05:59:16 +00:00
|
|
|
XenonThreadState* thread_state =
|
|
|
|
new XenonThreadState(runtime, 100, 64 * 1024, 0);
|
2013-12-07 06:57:16 +00:00
|
|
|
|
|
|
|
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;
|
2014-02-02 22:35:16 +00:00
|
|
|
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);
|
2013-12-07 06:57:16 +00:00
|
|
|
|
|
|
|
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;
|
2013-12-07 06:57:16 +00:00
|
|
|
}
|
|
|
|
// ehhh
|
|
|
|
#include <xenia/platform.cc>
|
|
|
|
XE_MAIN_THUNK(alloy_sandbox, "alloy-sandbox");
|