Real modules and threads (mostly).
Need events/waiting to get proper launch thread behavior.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'includes': [
|
||||
'xenia-info/xenia-info.gypi',
|
||||
'xenia-run/xenia-run.gypi',
|
||||
'xenia-test/xenia-test.gypi',
|
||||
],
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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 <xenia/xenia.h>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
|
||||
|
||||
int xenia_info(int argc, xechar_t **argv) {
|
||||
std::string usage = "usage: ";
|
||||
usage += "xenia-info some.xex";
|
||||
google::SetUsageMessage(usage);
|
||||
google::SetVersionString("1.0");
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
int result_code = 1;
|
||||
|
||||
xe_pal_ref pal = NULL;
|
||||
xe_memory_ref memory = NULL;
|
||||
shared_ptr<Processor> processor;
|
||||
shared_ptr<Runtime> runtime;
|
||||
|
||||
// Grab path.
|
||||
if (argc < 2) {
|
||||
google::ShowUsageWithFlags("xenia-info");
|
||||
return 1;
|
||||
}
|
||||
const xechar_t *path = argv[1];
|
||||
|
||||
xe_pal_options_t pal_options;
|
||||
xe_zero_struct(&pal_options, sizeof(pal_options));
|
||||
pal = xe_pal_create(pal_options);
|
||||
XEEXPECTNOTNULL(pal);
|
||||
|
||||
xe_memory_options_t memory_options;
|
||||
xe_zero_struct(&memory_options, sizeof(memory_options));
|
||||
memory = xe_memory_create(pal, memory_options);
|
||||
XEEXPECTNOTNULL(memory);
|
||||
|
||||
processor = shared_ptr<Processor>(new Processor(pal, memory));
|
||||
XEEXPECTZERO(processor->Setup());
|
||||
|
||||
runtime = shared_ptr<Runtime>(new Runtime(pal, processor, XT("")));
|
||||
|
||||
XEEXPECTZERO(runtime->LoadModule(path));
|
||||
|
||||
result_code = 0;
|
||||
XECLEANUP:
|
||||
xe_memory_release(memory);
|
||||
xe_pal_release(pal);
|
||||
|
||||
google::ShutDownCommandLineFlags();
|
||||
return result_code;
|
||||
}
|
||||
XE_MAIN_THUNK(xenia_info);
|
||||
@@ -1,23 +0,0 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'xenia-info',
|
||||
'type': 'executable',
|
||||
|
||||
'dependencies': [
|
||||
'xeniacore',
|
||||
'xeniacpu',
|
||||
'xeniakernel',
|
||||
],
|
||||
|
||||
'include_dirs': [
|
||||
'.',
|
||||
],
|
||||
|
||||
'sources': [
|
||||
'xenia-info.cc',
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -26,15 +26,14 @@ public:
|
||||
Run();
|
||||
~Run();
|
||||
|
||||
int Setup(const xechar_t* path);
|
||||
int Launch();
|
||||
int Setup();
|
||||
int Launch(const xechar_t* path);
|
||||
|
||||
private:
|
||||
xe_pal_ref pal_;
|
||||
xe_memory_ref memory_;
|
||||
shared_ptr<Processor> processor_;
|
||||
shared_ptr<Runtime> runtime_;
|
||||
UserModule* module_;
|
||||
};
|
||||
|
||||
Run::Run() {
|
||||
@@ -45,7 +44,7 @@ Run::~Run() {
|
||||
xe_pal_release(pal_);
|
||||
}
|
||||
|
||||
int Run::Setup(const xechar_t* path) {
|
||||
int Run::Setup() {
|
||||
xe_pal_options_t pal_options;
|
||||
xe_zero_struct(&pal_options, sizeof(pal_options));
|
||||
pal_ = xe_pal_create(pal_options);
|
||||
@@ -61,21 +60,19 @@ int Run::Setup(const xechar_t* path) {
|
||||
|
||||
runtime_ = shared_ptr<Runtime>(new Runtime(pal_, processor_, XT("")));
|
||||
|
||||
XEEXPECTZERO(runtime_->LoadModule(path));
|
||||
module_ = runtime_->GetModule(path);
|
||||
|
||||
return 0;
|
||||
XECLEANUP:
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Run::Launch() {
|
||||
int Run::Launch(const xechar_t* path) {
|
||||
if (FLAGS_abort_before_entry) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(benvanik): wait until the module thread exits
|
||||
runtime_->LaunchModule(module_);
|
||||
runtime_->LaunchModule(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,12 +97,12 @@ int xenia_run(int argc, xechar_t **argv) {
|
||||
|
||||
auto_ptr<Run> run = auto_ptr<Run>(new Run());
|
||||
|
||||
result_code = run->Setup(path);
|
||||
result_code = run->Setup();
|
||||
XEEXPECTZERO(result_code);
|
||||
|
||||
//xe_module_dump(run->module);
|
||||
|
||||
run->Launch();
|
||||
run->Launch(path);
|
||||
|
||||
result_code = 0;
|
||||
XECLEANUP:
|
||||
|
||||
@@ -126,10 +126,11 @@ int run_test(xe_pal_ref pal, string& src_file_path) {
|
||||
runtime = shared_ptr<Runtime>(new Runtime(pal, processor, XT("")));
|
||||
|
||||
// Load the binary module.
|
||||
XEEXPECTZERO(runtime->LoadBinaryModule(bin_file_path.c_str(), 0x82010000));
|
||||
XEEXPECTZERO(processor->LoadBinary(bin_file_path.c_str(), 0x82010000,
|
||||
runtime->export_resolver()));
|
||||
|
||||
// Simulate a thread.
|
||||
thread_state = processor->AllocThread(0x80000000, 256 * 1024 * 1024);
|
||||
thread_state = processor->AllocThread(256 * 1024 * 1024, 0);
|
||||
|
||||
// Setup test state from annotations.
|
||||
XEEXPECTZERO(setup_test_state(memory, processor.get(), thread_state,
|
||||
@@ -157,6 +158,10 @@ int discover_tests(string& test_path,
|
||||
vector<string>& test_files) {
|
||||
// TODO(benvanik): use PAL instead of this
|
||||
DIR* d = opendir(test_path.c_str());
|
||||
if (!d) {
|
||||
XELOGE(XT("Unable to find test path %s"), test_path.c_str());
|
||||
return 1;
|
||||
}
|
||||
struct dirent* dir;
|
||||
while ((dir = readdir(d))) {
|
||||
if (dir->d_type == DT_REG) {
|
||||
|
||||
Reference in New Issue
Block a user