Massive refactoring of all code + audio skeleton.
This should make it easier to find files and (in the future) split things up into separate libraries. It also changes around emulator initialization to make it a little more difficult to do things out of order and a little more sensible as to when real init work happens. Also adding a skeleton audio system/driver and reworking CPU register access to be more extensible.
This commit is contained in:
@@ -1,83 +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/kernel/export.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
|
||||
|
||||
ExportResolver::ExportResolver() {
|
||||
}
|
||||
|
||||
ExportResolver::~ExportResolver() {
|
||||
}
|
||||
|
||||
void ExportResolver::RegisterTable(
|
||||
const char* library_name, KernelExport* exports, const size_t count) {
|
||||
ExportTable table;
|
||||
XEIGNORE(xestrcpya(table.name, XECOUNT(table.name), library_name));
|
||||
table.exports = exports;
|
||||
table.count = count;
|
||||
tables_.push_back(table);
|
||||
|
||||
for (size_t n = 0; n < count; n++) {
|
||||
exports[n].is_implemented = false;
|
||||
exports[n].variable_ptr = 0;
|
||||
exports[n].function_data.shim_data = NULL;
|
||||
exports[n].function_data.shim = NULL;
|
||||
exports[n].function_data.impl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
KernelExport* ExportResolver::GetExportByOrdinal(const char* library_name,
|
||||
const uint32_t ordinal) {
|
||||
for (std::vector<ExportTable>::iterator it = tables_.begin();
|
||||
it != tables_.end(); ++it) {
|
||||
if (!xestrcmpa(library_name, it->name)) {
|
||||
// TODO(benvanik): binary search?
|
||||
for (size_t n = 0; n < it->count; n++) {
|
||||
if (it->exports[n].ordinal == ordinal) {
|
||||
return &it->exports[n];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
KernelExport* ExportResolver::GetExportByName(const char* library_name,
|
||||
const char* name) {
|
||||
// TODO(benvanik): lookup by name.
|
||||
XEASSERTALWAYS();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ExportResolver::SetVariableMapping(const char* library_name,
|
||||
const uint32_t ordinal,
|
||||
uint32_t value) {
|
||||
KernelExport* kernel_export = GetExportByOrdinal(library_name, ordinal);
|
||||
XEASSERTNOTNULL(kernel_export);
|
||||
kernel_export->is_implemented = true;
|
||||
kernel_export->variable_ptr = value;
|
||||
}
|
||||
|
||||
void ExportResolver::SetFunctionMapping(
|
||||
const char* library_name, const uint32_t ordinal,
|
||||
void* shim_data, xe_kernel_export_shim_fn shim,
|
||||
xe_kernel_export_impl_fn impl) {
|
||||
KernelExport* kernel_export = GetExportByOrdinal(library_name, ordinal);
|
||||
XEASSERTNOTNULL(kernel_export);
|
||||
kernel_export->is_implemented = true;
|
||||
kernel_export->function_data.shim_data = shim_data;
|
||||
kernel_export->function_data.shim = shim;
|
||||
kernel_export->function_data.impl = impl;
|
||||
}
|
||||
@@ -1,99 +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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_EXPORT_H_
|
||||
#define XENIA_KERNEL_EXPORT_H_
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
typedef struct xe_ppc_state xe_ppc_state_t;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
|
||||
typedef void (*xe_kernel_export_impl_fn)();
|
||||
typedef void (*xe_kernel_export_shim_fn)(xe_ppc_state_t*, void*);
|
||||
|
||||
class KernelExport {
|
||||
public:
|
||||
enum ExportType {
|
||||
Function = 0,
|
||||
Variable = 1,
|
||||
};
|
||||
|
||||
uint32_t ordinal;
|
||||
ExportType type;
|
||||
uint32_t flags;
|
||||
char signature[16];
|
||||
char name[96];
|
||||
|
||||
bool is_implemented;
|
||||
|
||||
union {
|
||||
// Variable data. Only valid when kXEKernelExportFlagVariable is set.
|
||||
// This is an address in the client memory space that the variable can
|
||||
// be found at.
|
||||
uint32_t variable_ptr;
|
||||
|
||||
struct {
|
||||
// Second argument passed to the shim function.
|
||||
void* shim_data;
|
||||
|
||||
// Shimmed implementation.
|
||||
// This is called directly from generated code.
|
||||
// It should parse args, do fixups, and call the impl.
|
||||
xe_kernel_export_shim_fn shim;
|
||||
|
||||
// Real function implementation.
|
||||
xe_kernel_export_impl_fn impl;
|
||||
} function_data;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
class ExportResolver {
|
||||
public:
|
||||
ExportResolver();
|
||||
~ExportResolver();
|
||||
|
||||
void RegisterTable(const char* library_name, KernelExport* exports,
|
||||
const size_t count);
|
||||
|
||||
KernelExport* GetExportByOrdinal(const char* library_name,
|
||||
const uint32_t ordinal);
|
||||
KernelExport* GetExportByName(const char* library_name, const char* name);
|
||||
|
||||
void SetVariableMapping(const char* library_name, const uint32_t ordinal,
|
||||
uint32_t value);
|
||||
void SetFunctionMapping(const char* library_name, const uint32_t ordinal,
|
||||
void* shim_data, xe_kernel_export_shim_fn shim,
|
||||
xe_kernel_export_impl_fn impl);
|
||||
|
||||
private:
|
||||
class ExportTable {
|
||||
public:
|
||||
char name[32];
|
||||
KernelExport* exports;
|
||||
size_t count;
|
||||
};
|
||||
|
||||
std::vector<ExportTable> tables_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_EXPORT_H_
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef XENIA_KERNEL_KERNEL_H_
|
||||
#define XENIA_KERNEL_KERNEL_H_
|
||||
|
||||
#include <xenia/kernel/runtime.h>
|
||||
#include <xenia/kernel/modules/modules.h>
|
||||
#include <xenia/kernel/modules.h>
|
||||
|
||||
#endif // XENIA_KERNEL_KERNEL_H_
|
||||
|
||||
@@ -9,21 +9,20 @@
|
||||
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/runtime.h>
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
|
||||
|
||||
KernelModule::KernelModule(Runtime* runtime) {
|
||||
runtime_ = runtime;
|
||||
memory_ = runtime->memory();
|
||||
export_resolver_ = runtime->export_resolver();
|
||||
KernelModule::KernelModule(Emulator* emulator) :
|
||||
emulator_(emulator) {
|
||||
memory_ = xe_memory_retain(emulator_->memory());
|
||||
export_resolver_ = emulator->export_resolver();
|
||||
}
|
||||
|
||||
KernelModule::~KernelModule() {
|
||||
export_resolver_.reset();
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
@@ -14,23 +14,23 @@
|
||||
#include <xenia/core.h>
|
||||
|
||||
|
||||
XEDECLARECLASS1(xe, Emulator);
|
||||
XEDECLARECLASS1(xe, ExportResolver);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
|
||||
class ExportResolver;
|
||||
class Runtime;
|
||||
|
||||
|
||||
class KernelModule {
|
||||
public:
|
||||
KernelModule(Runtime* runtime);
|
||||
KernelModule(Emulator* emulator);
|
||||
virtual ~KernelModule();
|
||||
|
||||
protected:
|
||||
Runtime* runtime_;
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
shared_ptr<ExportResolver> export_resolver_;
|
||||
ExportResolver* export_resolver_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifndef XENIA_KERNEL_MODULES_H_
|
||||
#define XENIA_KERNEL_MODULES_H_
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_module.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/module.h>
|
||||
#include <xenia/kernel/xam/xam_module.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_module.h>
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_H_
|
||||
@@ -1,11 +0,0 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'modules.h',
|
||||
],
|
||||
|
||||
'includes': [
|
||||
'xam/sources.gypi',
|
||||
'xboxkrnl/sources.gypi',
|
||||
],
|
||||
}
|
||||
@@ -1,78 +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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_KERNEL_STATE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_KERNEL_STATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/object_table.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/filesystem.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
class Processor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
class XModule;
|
||||
namespace fs {
|
||||
class FileSystem;
|
||||
}
|
||||
|
||||
|
||||
class KernelState {
|
||||
public:
|
||||
KernelState(Runtime* runtime);
|
||||
~KernelState();
|
||||
|
||||
static KernelState* shared();
|
||||
|
||||
Runtime* runtime();
|
||||
xe_memory_ref memory();
|
||||
cpu::Processor* processor();
|
||||
fs::FileSystem* filesystem();
|
||||
|
||||
ObjectTable* object_table() const;
|
||||
|
||||
XModule* GetModule(const char* name);
|
||||
XModule* GetExecutableModule();
|
||||
void SetExecutableModule(XModule* module);
|
||||
|
||||
private:
|
||||
Runtime* runtime_;
|
||||
xe_memory_ref memory_;
|
||||
shared_ptr<cpu::Processor> processor_;
|
||||
shared_ptr<fs::FileSystem> filesystem_;
|
||||
|
||||
ObjectTable* object_table_;
|
||||
xe_mutex_t* object_mutex_;
|
||||
|
||||
XModule* executable_module_;
|
||||
|
||||
friend class XObject;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_KERNEL_STATE_H_
|
||||
@@ -1,136 +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/kernel/runtime.h>
|
||||
|
||||
#include <xenia/kernel/modules/modules.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/filesystem.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::cpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
Runtime::Runtime(shared_ptr<cpu::Processor> processor,
|
||||
const xechar_t* command_line) {
|
||||
memory_ = processor->memory();
|
||||
processor_ = processor;
|
||||
XEIGNORE(xestrcpy(command_line_, XECOUNT(command_line_), command_line));
|
||||
export_resolver_ = shared_ptr<ExportResolver>(new ExportResolver());
|
||||
|
||||
filesystem_ = shared_ptr<FileSystem>(new FileSystem());
|
||||
|
||||
xboxkrnl_ = auto_ptr<xboxkrnl::XboxkrnlModule>(
|
||||
new xboxkrnl::XboxkrnlModule(this));
|
||||
xam_ = auto_ptr<xam::XamModule>(
|
||||
new xam::XamModule(this));
|
||||
}
|
||||
|
||||
Runtime::~Runtime() {
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
const xechar_t* Runtime::command_line() {
|
||||
return command_line_;
|
||||
}
|
||||
|
||||
xe_memory_ref Runtime::memory() {
|
||||
return xe_memory_retain(memory_);
|
||||
}
|
||||
|
||||
shared_ptr<cpu::Processor> Runtime::processor() {
|
||||
return processor_;
|
||||
}
|
||||
|
||||
shared_ptr<ExportResolver> Runtime::export_resolver() {
|
||||
return export_resolver_;
|
||||
}
|
||||
|
||||
shared_ptr<FileSystem> Runtime::filesystem() {
|
||||
return filesystem_;
|
||||
}
|
||||
|
||||
int Runtime::LaunchXexFile(const xechar_t* path) {
|
||||
// We create a virtual filesystem pointing to its directory and symlink
|
||||
// that to the game filesystem.
|
||||
// e.g., /my/files/foo.xex will get a local fs at:
|
||||
// \\Device\\Harddisk0\\Partition1
|
||||
// and then get that symlinked to game:\, so
|
||||
// -> game:\foo.xex
|
||||
|
||||
int result_code = 0;
|
||||
|
||||
// Get just the filename (foo.xex).
|
||||
const xechar_t* file_name = xestrrchr(path, XE_PATH_SEPARATOR);
|
||||
if (file_name) {
|
||||
// Skip slash.
|
||||
file_name++;
|
||||
} else {
|
||||
// No slash found, whole thing is a file.
|
||||
file_name = path;
|
||||
}
|
||||
|
||||
// Get the parent path of the file.
|
||||
xechar_t parent_path[XE_MAX_PATH];
|
||||
XEIGNORE(xestrcpy(parent_path, XECOUNT(parent_path), path));
|
||||
parent_path[file_name - path] = 0;
|
||||
|
||||
// Register the local directory in the virtual filesystem.
|
||||
result_code = filesystem_->RegisterHostPathDevice(
|
||||
"\\Device\\Harddisk1\\Partition0", parent_path);
|
||||
if (result_code) {
|
||||
XELOGE("Unable to mount local directory");
|
||||
return result_code;
|
||||
}
|
||||
|
||||
// Create symlinks to the device.
|
||||
filesystem_->CreateSymbolicLink(
|
||||
"game:", "\\Device\\Harddisk1\\Partition0");
|
||||
filesystem_->CreateSymbolicLink(
|
||||
"d:", "\\Device\\Harddisk1\\Partition0");
|
||||
|
||||
// Get the file name of the module to load from the filesystem.
|
||||
char fs_path[XE_MAX_PATH];
|
||||
XEIGNORE(xestrcpya(fs_path, XECOUNT(fs_path), "game:\\"));
|
||||
char* fs_path_ptr = fs_path + xestrlena(fs_path);
|
||||
*fs_path_ptr = 0;
|
||||
#if XE_WCHAR
|
||||
XEIGNORE(xestrnarrow(fs_path_ptr, XECOUNT(fs_path), file_name));
|
||||
#else
|
||||
XEIGNORE(xestrcpya(fs_path_ptr, XECOUNT(fs_path), file_name));
|
||||
#endif
|
||||
|
||||
// Launch the game.
|
||||
return xboxkrnl_->LaunchModule(fs_path);
|
||||
}
|
||||
|
||||
int Runtime::LaunchDiscImage(const xechar_t* path) {
|
||||
int result_code = 0;
|
||||
|
||||
// Register the disc image in the virtual filesystem.
|
||||
result_code = filesystem_->RegisterDiscImageDevice(
|
||||
"\\Device\\Cdrom0", path);
|
||||
if (result_code) {
|
||||
XELOGE("Unable to mount disc image");
|
||||
return result_code;
|
||||
}
|
||||
|
||||
// Create symlinks to the device.
|
||||
filesystem_->CreateSymbolicLink(
|
||||
"game:",
|
||||
"\\Device\\Cdrom0");
|
||||
filesystem_->CreateSymbolicLink(
|
||||
"d:",
|
||||
"\\Device\\Cdrom0");
|
||||
|
||||
// Launch the game.
|
||||
return xboxkrnl_->LaunchModule("game:\\default.xex");
|
||||
}
|
||||
@@ -1,77 +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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_RUNTIME_H_
|
||||
#define XENIA_KERNEL_RUNTIME_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
#include <xenia/cpu/cpu.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace cpu {
|
||||
class Processor;
|
||||
}
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
class XboxkrnlModule;
|
||||
namespace fs {
|
||||
class FileSystem;
|
||||
}
|
||||
}
|
||||
namespace xam {
|
||||
class XamModule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
class KernelModule;
|
||||
|
||||
|
||||
class Runtime {
|
||||
public:
|
||||
Runtime(shared_ptr<cpu::Processor> processor, const xechar_t* command_line);
|
||||
~Runtime();
|
||||
|
||||
const xechar_t* command_line();
|
||||
|
||||
xe_memory_ref memory();
|
||||
shared_ptr<cpu::Processor> processor();
|
||||
shared_ptr<ExportResolver> export_resolver();
|
||||
shared_ptr<xboxkrnl::fs::FileSystem> filesystem();
|
||||
|
||||
int LaunchXexFile(const xechar_t* path);
|
||||
int LaunchDiscImage(const xechar_t* path);
|
||||
|
||||
private:
|
||||
xechar_t command_line_[XE_MAX_PATH];
|
||||
|
||||
xe_memory_ref memory_;
|
||||
shared_ptr<cpu::Processor> processor_;
|
||||
shared_ptr<ExportResolver> export_resolver_;
|
||||
shared_ptr<xboxkrnl::fs::FileSystem> filesystem_;
|
||||
|
||||
auto_ptr<xboxkrnl::XboxkrnlModule> xboxkrnl_;
|
||||
auto_ptr<xam::XamModule> xam_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_RUNTIME_H_
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/cpu/ppc.h>
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'export.cc',
|
||||
'export.h',
|
||||
'kernel.h',
|
||||
'kernel_module.cc',
|
||||
'kernel_module.h',
|
||||
'runtime.cc',
|
||||
'runtime.h',
|
||||
'modules.h',
|
||||
'shim_utils.h',
|
||||
'xbox.h',
|
||||
'xex2.cc',
|
||||
'xex2.h',
|
||||
'xex2_info.h',
|
||||
],
|
||||
|
||||
'includes': [
|
||||
'modules/sources.gypi',
|
||||
'xam/sources.gypi',
|
||||
'xboxkrnl/sources.gypi',
|
||||
'util/sources.gypi',
|
||||
],
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* // Build the export table used for resolution.
|
||||
* #include <xenia/kernel/util/export_table_pre.inc>
|
||||
* static KernelExport my_module_export_table[] = {
|
||||
* #include <xenia/kernel/modules/my_module/my_module_table.inc>
|
||||
* #include <xenia/kernel/my_module/my_module_table.inc>
|
||||
* };
|
||||
* #include <xenia/kernel/util/export_table_post.inc>
|
||||
* export_resolver_->RegisterTable(
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* #include <xenia/kernel/util/ordinal_table_pre.inc>
|
||||
* namespace ordinals {
|
||||
* enum {
|
||||
* #include <xenia/kernel/modules/my_module/my_module_table.inc>
|
||||
* #include <xenia/kernel/my_module/my_module_table.inc>
|
||||
* };
|
||||
* } // namespace ordinals
|
||||
* #include <xenia/kernel/util/ordinal_table_post.inc>
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_content.h>
|
||||
#include <xenia/kernel/xam/xam_content.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_CONTENT_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_CONTENT_H_
|
||||
#ifndef XENIA_KERNEL_XAM_CONTENT_H_
|
||||
#define XENIA_KERNEL_XAM_CONTENT_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_CONTENT_H_
|
||||
#endif // XENIA_KERNEL_XAM_CONTENT_H_
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_info.h>
|
||||
#include <xenia/kernel/xam/xam_info.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_INFO_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_INFO_H_
|
||||
#ifndef XENIA_KERNEL_XAM_INFO_H_
|
||||
#define XENIA_KERNEL_XAM_INFO_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_INFO_H_
|
||||
#endif // XENIA_KERNEL_XAM_INFO_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_input.h>
|
||||
#include <xenia/kernel/xam/xam_input.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_INPUT_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_INPUT_H_
|
||||
#ifndef XENIA_KERNEL_XAM_INPUT_H_
|
||||
#define XENIA_KERNEL_XAM_INPUT_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_INPUT_H_
|
||||
#endif // XENIA_KERNEL_XAM_INPUT_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_module.h>
|
||||
#include <xenia/kernel/xam/xam_module.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -22,31 +22,31 @@ using namespace xe::kernel::xam;
|
||||
XamState* xe::kernel::xam::shared_xam_state_ = NULL;
|
||||
|
||||
|
||||
XamModule::XamModule(Runtime* runtime) :
|
||||
KernelModule(runtime) {
|
||||
XamModule::XamModule(Emulator* emulator) :
|
||||
KernelModule(emulator) {
|
||||
// Build the export table used for resolution.
|
||||
#include <xenia/kernel/util/export_table_pre.inc>
|
||||
static KernelExport xam_export_table[] = {
|
||||
#include <xenia/kernel/modules/xam/xam_table.inc>
|
||||
#include <xenia/kernel/xam/xam_table.inc>
|
||||
};
|
||||
#include <xenia/kernel/util/export_table_post.inc>
|
||||
export_resolver_->RegisterTable(
|
||||
"xam.xex", xam_export_table, XECOUNT(xam_export_table));
|
||||
|
||||
// Setup the xam state instance.
|
||||
xam_state = auto_ptr<XamState>(new XamState(memory_, export_resolver_));
|
||||
xam_state_ = new XamState(emulator);
|
||||
|
||||
// Setup the shared global state object.
|
||||
XEASSERTNULL(shared_xam_state_);
|
||||
shared_xam_state_ = xam_state.get();
|
||||
shared_xam_state_ = xam_state_;
|
||||
|
||||
// Register all exported functions.
|
||||
RegisterContentExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterInfoExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterInputExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterNetExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterUserExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterVideoExports(export_resolver_.get(), xam_state.get());
|
||||
RegisterContentExports(export_resolver_, xam_state_);
|
||||
RegisterInfoExports(export_resolver_, xam_state_);
|
||||
RegisterInputExports(export_resolver_, xam_state_);
|
||||
RegisterNetExports(export_resolver_, xam_state_);
|
||||
RegisterUserExports(export_resolver_, xam_state_);
|
||||
RegisterVideoExports(export_resolver_, xam_state_);
|
||||
}
|
||||
|
||||
XamModule::~XamModule() {
|
||||
@@ -7,18 +7,18 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_H_
|
||||
#ifndef XENIA_KERNEL_XAM_H_
|
||||
#define XENIA_KERNEL_XAM_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
#include <xenia/kernel/modules/xam/xam_ordinals.h>
|
||||
#include <xenia/kernel/xam/xam_ordinals.h>
|
||||
|
||||
// All of the exported functions:
|
||||
#include <xenia/kernel/modules/xam/xam_info.h>
|
||||
#include <xenia/kernel/xam/xam_info.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -30,11 +30,11 @@ class XamState;
|
||||
|
||||
class XamModule : public KernelModule {
|
||||
public:
|
||||
XamModule(Runtime* runtime);
|
||||
XamModule(Emulator* emulator);
|
||||
virtual ~XamModule();
|
||||
|
||||
private:
|
||||
auto_ptr<XamState> xam_state;
|
||||
XamState* xam_state_;
|
||||
};
|
||||
|
||||
|
||||
@@ -43,4 +43,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_H_
|
||||
#endif // XENIA_KERNEL_XAM_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_net.h>
|
||||
#include <xenia/kernel/xam/xam_net.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_NET_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_NET_H_
|
||||
#ifndef XENIA_KERNEL_XAM_NET_H_
|
||||
#define XENIA_KERNEL_XAM_NET_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_NET_H_
|
||||
#endif // XENIA_KERNEL_XAM_NET_H_
|
||||
@@ -1,29 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XAM_ORDINALS_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_ORDINALS_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
|
||||
|
||||
// Build an ordinal enum to make it easy to lookup ordinals.
|
||||
#include <xenia/kernel/util/ordinal_table_pre.inc>
|
||||
namespace ordinals {
|
||||
enum {
|
||||
#include <xenia/kernel/modules/xam/xam_table.inc>
|
||||
};
|
||||
} // namespace ordinals
|
||||
#include <xenia/kernel/util/ordinal_table_post.inc>
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_ORDINALS_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XAM_ORDINALS_H_
|
||||
#define XENIA_KERNEL_XAM_ORDINALS_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/export_resolver.h>
|
||||
|
||||
|
||||
// Build an ordinal enum to make it easy to lookup ordinals.
|
||||
#include <xenia/kernel/util/ordinal_table_pre.inc>
|
||||
namespace ordinals {
|
||||
enum {
|
||||
#include <xenia/kernel/xam/xam_table.inc>
|
||||
};
|
||||
} // namespace ordinals
|
||||
#include <xenia/kernel/util/ordinal_table_post.inc>
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XAM_ORDINALS_H_
|
||||
@@ -1,46 +1,46 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XAM_PRIVATE_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_PRIVATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_ordinals.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
class XamState;
|
||||
|
||||
|
||||
// This is a global object initialized with the XamModule.
|
||||
// It references the current xam state object that all xam methods should
|
||||
// be using to stash their variables.
|
||||
extern XamState* shared_xam_state_;
|
||||
|
||||
|
||||
// Registration functions, one per file.
|
||||
void RegisterContentExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterInfoExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterInputExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterNetExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterUserExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterVideoExports(ExportResolver* export_resolver, XamState* state);
|
||||
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_PRIVATE_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XAM_PRIVATE_H_
|
||||
#define XENIA_KERNEL_XAM_PRIVATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xam/xam_ordinals.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
class XamState;
|
||||
|
||||
|
||||
// This is a global object initialized with the XamModule.
|
||||
// It references the current xam state object that all xam methods should
|
||||
// be using to stash their variables.
|
||||
extern XamState* shared_xam_state_;
|
||||
|
||||
|
||||
// Registration functions, one per file.
|
||||
void RegisterContentExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterInfoExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterInputExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterNetExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterUserExports(ExportResolver* export_resolver, XamState* state);
|
||||
void RegisterVideoExports(ExportResolver* export_resolver, XamState* state);
|
||||
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XAM_PRIVATE_H_
|
||||
@@ -7,7 +7,9 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
#include <xenia/emulator.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -20,12 +22,12 @@ namespace {
|
||||
}
|
||||
|
||||
|
||||
XamState::XamState(xe_memory_ref memory,
|
||||
shared_ptr<ExportResolver> export_resolver) {
|
||||
this->memory = xe_memory_retain(memory);
|
||||
export_resolver_ = export_resolver;
|
||||
XamState::XamState(Emulator* emulator) :
|
||||
emulator_(emulator) {
|
||||
memory_ = xe_memory_retain(emulator->memory());
|
||||
export_resolver_ = emulator->export_resolver();
|
||||
}
|
||||
|
||||
XamState::~XamState() {
|
||||
xe_memory_release(memory);
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_XAM_STATE_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_XAM_STATE_H_
|
||||
#ifndef XENIA_KERNEL_XAM_XAM_STATE_H_
|
||||
#define XENIA_KERNEL_XAM_XAM_STATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
|
||||
|
||||
@@ -24,13 +24,15 @@ namespace xam {
|
||||
|
||||
class XamState {
|
||||
public:
|
||||
XamState(xe_memory_ref memory, shared_ptr<ExportResolver> export_resolver);
|
||||
XamState(Emulator* emulator);
|
||||
~XamState();
|
||||
|
||||
xe_memory_ref memory;
|
||||
xe_memory_ref memory() const { return memory_; }
|
||||
|
||||
private:
|
||||
shared_ptr<ExportResolver> export_resolver_;
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
ExportResolver* export_resolver_;
|
||||
};
|
||||
|
||||
|
||||
@@ -39,4 +41,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_XAM_STATE_H_
|
||||
#endif // XENIA_KERNEL_XAM_XAM_STATE_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xam/xam_user.h>
|
||||
#include <xenia/kernel/xam/xam_user.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_USER_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_USER_H_
|
||||
#ifndef XENIA_KERNEL_XAM_USER_H_
|
||||
#define XENIA_KERNEL_XAM_USER_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_USER_H_
|
||||
#endif // XENIA_KERNEL_XAM_USER_H_
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xam/xam_video.h>
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xam/xam_video.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xam/xam_private.h>
|
||||
#include <xenia/kernel/modules/xam/xam_state.h>
|
||||
|
||||
#include <xenia/kernel/modules/modules.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xam;
|
||||
|
||||
|
||||
#include <xenia/kernel/xam/xam_private.h>
|
||||
#include <xenia/kernel/xam/xam_state.h>
|
||||
|
||||
#include <xenia/kernel/modules.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xam;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XGetVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
xe::kernel::xboxkrnl::X_VIDEO_MODE *video_mode = (xe::kernel::xboxkrnl::X_VIDEO_MODE*)SHIM_MEM_ADDR(SHIM_GET_ARG_32(0));
|
||||
xeVdQueryVideoMode(video_mode, true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xam::RegisterVideoExports(
|
||||
ExportResolver* export_resolver, XamState* state) {
|
||||
SHIM_SET_MAPPING("xam.xex", XGetVideoMode, state);
|
||||
}
|
||||
namespace xam {
|
||||
|
||||
|
||||
SHIM_CALL XGetVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, XamState* state) {
|
||||
xe::kernel::xboxkrnl::X_VIDEO_MODE *video_mode = (xe::kernel::xboxkrnl::X_VIDEO_MODE*)SHIM_MEM_ADDR(SHIM_GET_ARG_32(0));
|
||||
xeVdQueryVideoMode(video_mode, true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xam::RegisterVideoExports(
|
||||
ExportResolver* export_resolver, XamState* state) {
|
||||
SHIM_SET_MAPPING("xam.xex", XGetVideoMode, state);
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XAM_VIDEO_H_
|
||||
#define XENIA_KERNEL_MODULES_XAM_VIDEO_H_
|
||||
#ifndef XENIA_KERNEL_XAM_VIDEO_H_
|
||||
#define XENIA_KERNEL_XAM_VIDEO_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -28,4 +28,4 @@ namespace xam {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XAM_VIDEO_H_
|
||||
#endif // XENIA_KERNEL_XAM_VIDEO_H_
|
||||
@@ -1,250 +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. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_XBOX_H_
|
||||
#define XENIA_KERNEL_XBOX_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
|
||||
typedef uint32_t X_HANDLE;
|
||||
#define X_INVALID_HANDLE_VALUE ((X_HANDLE)-1)
|
||||
|
||||
|
||||
// NT_STATUS (STATUS_*)
|
||||
// http://msdn.microsoft.com/en-us/library/cc704588.aspx
|
||||
// Adding as needed.
|
||||
typedef uint32_t X_STATUS;
|
||||
#define XFAILED(s) (s & X_STATUS_UNSUCCESSFUL)
|
||||
#define XSUCCEEDED(s) !XFAILED(s)
|
||||
#define X_STATUS_SUCCESS ((uint32_t)0x00000000L)
|
||||
#define X_STATUS_ABANDONED_WAIT_0 ((uint32_t)0x00000080L)
|
||||
#define X_STATUS_USER_APC ((uint32_t)0x000000C0L)
|
||||
#define X_STATUS_ALERTED ((uint32_t)0x00000101L)
|
||||
#define X_STATUS_TIMEOUT ((uint32_t)0x00000102L)
|
||||
#define X_STATUS_PENDING ((uint32_t)0x00000103L)
|
||||
#define X_STATUS_UNSUCCESSFUL ((uint32_t)0xC0000001L)
|
||||
#define X_STATUS_NOT_IMPLEMENTED ((uint32_t)0xC0000002L)
|
||||
#define X_STATUS_ACCESS_VIOLATION ((uint32_t)0xC0000005L)
|
||||
#define X_STATUS_INVALID_HANDLE ((uint32_t)0xC0000008L)
|
||||
#define X_STATUS_INVALID_PARAMETER ((uint32_t)0xC000000DL)
|
||||
#define X_STATUS_NO_SUCH_FILE ((uint32_t)0xC000000FL)
|
||||
#define X_STATUS_NO_MEMORY ((uint32_t)0xC0000017L)
|
||||
#define X_STATUS_ALREADY_COMMITTED ((uint32_t)0xC0000021L)
|
||||
#define X_STATUS_ACCESS_DENIED ((uint32_t)0xC0000022L)
|
||||
#define X_STATUS_BUFFER_TOO_SMALL ((uint32_t)0xC0000023L)
|
||||
#define X_STATUS_OBJECT_TYPE_MISMATCH ((uint32_t)0xC0000024L)
|
||||
#define X_STATUS_INVALID_PAGE_PROTECTION ((uint32_t)0xC0000045L)
|
||||
#define X_STATUS_MEMORY_NOT_ALLOCATED ((uint32_t)0xC00000A0L)
|
||||
#define X_STATUS_INVALID_PARAMETER_1 ((uint32_t)0xC00000EFL)
|
||||
#define X_STATUS_INVALID_PARAMETER_2 ((uint32_t)0xC00000F0L)
|
||||
#define X_STATUS_INVALID_PARAMETER_3 ((uint32_t)0xC00000F1L)
|
||||
|
||||
// MEM_*, used by NtAllocateVirtualMemory
|
||||
#define X_MEM_COMMIT 0x00001000
|
||||
#define X_MEM_RESERVE 0x00002000
|
||||
#define X_MEM_DECOMMIT 0x00004000
|
||||
#define X_MEM_RELEASE 0x00008000
|
||||
#define X_MEM_FREE 0x00010000
|
||||
#define X_MEM_PRIVATE 0x00020000
|
||||
#define X_MEM_RESET 0x00080000
|
||||
#define X_MEM_TOP_DOWN 0x00100000
|
||||
#define X_MEM_NOZERO 0x00800000
|
||||
#define X_MEM_LARGE_PAGES 0x20000000
|
||||
#define X_MEM_HEAP 0x40000000
|
||||
#define X_MEM_16MB_PAGES 0x80000000 // from Valve SDK
|
||||
|
||||
// FILE_*, used by NtOpenFile
|
||||
#define X_FILE_SUPERSEDED 0x00000000
|
||||
#define X_FILE_OPENED 0x00000001
|
||||
#define X_FILE_CREATED 0x00000002
|
||||
#define X_FILE_OVERWRITTEN 0x00000003
|
||||
#define X_FILE_EXISTS 0x00000004
|
||||
#define X_FILE_DOES_NOT_EXIST 0x00000005
|
||||
|
||||
|
||||
// PAGE_*, used by NtAllocateVirtualMemory
|
||||
#define X_PAGE_NOACCESS 0x00000001
|
||||
#define X_PAGE_READONLY 0x00000002
|
||||
#define X_PAGE_READWRITE 0x00000004
|
||||
#define X_PAGE_WRITECOPY 0x00000008
|
||||
#define X_PAGE_EXECUTE 0x00000010
|
||||
#define X_PAGE_EXECUTE_READ 0x00000020
|
||||
#define X_PAGE_EXECUTE_READWRITE 0x00000040
|
||||
#define X_PAGE_EXECUTE_WRITECOPY 0x00000080
|
||||
#define X_PAGE_GUARD 0x00000100
|
||||
#define X_PAGE_NOCACHE 0x00000200
|
||||
#define X_PAGE_WRITECOMBINE 0x00000400
|
||||
|
||||
|
||||
// (?), used by KeGetCurrentProcessType
|
||||
#define X_PROCTYPE_IDLE 0
|
||||
#define X_PROCTYPE_USER 1
|
||||
#define X_PROCTYPE_SYSTEM 2
|
||||
|
||||
|
||||
// Thread enums.
|
||||
#define X_CREATE_SUSPENDED 0x00000004
|
||||
|
||||
|
||||
// TLS specials.
|
||||
#define X_TLS_OUT_OF_INDEXES UINT32_MAX // (-1)
|
||||
|
||||
|
||||
// Languages.
|
||||
#define X_LANGUAGE_ENGLISH 1
|
||||
#define X_LANGUAGE_JAPANESE 2
|
||||
|
||||
|
||||
typedef enum _X_FILE_ATTRIBUTES {
|
||||
X_FILE_ATTRIBUTE_NONE = 0x0000,
|
||||
X_FILE_ATTRIBUTE_READONLY = 0x0001,
|
||||
X_FILE_ATTRIBUTE_HIDDEN = 0x0002,
|
||||
X_FILE_ATTRIBUTE_SYSTEM = 0x0004,
|
||||
X_FILE_ATTRIBUTE_DIRECTORY = 0x0010,
|
||||
X_FILE_ATTRIBUTE_ARCHIVE = 0x0020,
|
||||
X_FILE_ATTRIBUTE_DEVICE = 0x0040,
|
||||
X_FILE_ATTRIBUTE_NORMAL = 0x0080,
|
||||
X_FILE_ATTRIBUTE_TEMPORARY = 0x0100,
|
||||
X_FILE_ATTRIBUTE_COMPRESSED = 0x0800,
|
||||
X_FILE_ATTRIBUTE_ENCRYPTED = 0x4000,
|
||||
} X_FILE_ATTRIBUTES;
|
||||
|
||||
|
||||
typedef enum _X_FILE_INFORMATION_CLASS {
|
||||
XFileDirectoryInformation = 1,
|
||||
XFileFullDirectoryInformation,
|
||||
XFileBothDirectoryInformation,
|
||||
XFileBasicInformation,
|
||||
XFileStandardInformation,
|
||||
XFileInternalInformation,
|
||||
XFileEaInformation,
|
||||
XFileAccessInformation,
|
||||
XFileNameInformation,
|
||||
XFileRenameInformation,
|
||||
XFileLinkInformation,
|
||||
XFileNamesInformation,
|
||||
XFileDispositionInformation,
|
||||
XFilePositionInformation,
|
||||
XFileFullEaInformation,
|
||||
XFileModeInformation,
|
||||
XFileAlignmentInformation,
|
||||
XFileAllInformation,
|
||||
XFileAllocationInformation,
|
||||
XFileEndOfFileInformation,
|
||||
XFileAlternateNameInformation,
|
||||
XFileStreamInformation,
|
||||
XFilePipeInformation,
|
||||
XFilePipeLocalInformation,
|
||||
XFilePipeRemoteInformation,
|
||||
XFileMailslotQueryInformation,
|
||||
XFileMailslotSetInformation,
|
||||
XFileCompressionInformation,
|
||||
XFileObjectIdInformation,
|
||||
XFileCompletionInformation,
|
||||
XFileMoveClusterInformation,
|
||||
XFileQuotaInformation,
|
||||
XFileReparsePointInformation,
|
||||
XFileNetworkOpenInformation,
|
||||
XFileAttributeTagInformation,
|
||||
XFileTrackingInformation,
|
||||
XFileIdBothDirectoryInformation,
|
||||
XFileIdFullDirectoryInformation,
|
||||
XFileValidDataLengthInformation,
|
||||
XFileShortNameInformation,
|
||||
XFileIoCompletionNotificationInformation,
|
||||
XFileIoStatusBlockRangeInformation,
|
||||
XFileIoPriorityHintInformation,
|
||||
XFileSfioReserveInformation,
|
||||
XFileSfioVolumeInformation,
|
||||
XFileHardLinkInformation,
|
||||
XFileProcessIdsUsingFileInformation,
|
||||
XFileNormalizedNameInformation,
|
||||
XFileNetworkPhysicalNameInformation,
|
||||
XFileIdGlobalTxDirectoryInformation,
|
||||
XFileIsRemoteDeviceInformation,
|
||||
XFileAttributeCacheInformation,
|
||||
XFileNumaNodeInformation,
|
||||
XFileStandardLinkInformation,
|
||||
XFileRemoteProtocolInformation,
|
||||
XFileReplaceCompletionInformation,
|
||||
XFileMaximumInformation
|
||||
} X_FILE_INFORMATION_CLASS;
|
||||
|
||||
|
||||
class X_ANSI_STRING {
|
||||
public:
|
||||
uint16_t length;
|
||||
uint16_t maximum_length;
|
||||
char* buffer;
|
||||
|
||||
X_ANSI_STRING() {
|
||||
Zero();
|
||||
}
|
||||
X_ANSI_STRING(const uint8_t* base, uint32_t p) {
|
||||
Read(base, p);
|
||||
}
|
||||
void Read(const uint8_t* base, uint32_t p) {
|
||||
length = XEGETUINT16BE(base + p);
|
||||
maximum_length = XEGETUINT16BE(base + p + 2);
|
||||
if (maximum_length) {
|
||||
buffer = (char*)(base + XEGETUINT32BE(base + p + 4));
|
||||
} else {
|
||||
buffer = 0;
|
||||
}
|
||||
}
|
||||
void Zero() {
|
||||
length = maximum_length = 0;
|
||||
buffer = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class X_OBJECT_ATTRIBUTES {
|
||||
public:
|
||||
uint32_t root_directory;
|
||||
uint32_t object_name_ptr;
|
||||
X_ANSI_STRING object_name;
|
||||
uint32_t attributes;
|
||||
|
||||
X_OBJECT_ATTRIBUTES() {
|
||||
Zero();
|
||||
}
|
||||
X_OBJECT_ATTRIBUTES(const uint8_t* base, uint32_t p) {
|
||||
Read(base, p);
|
||||
}
|
||||
void Read(const uint8_t* base, uint32_t p) {
|
||||
root_directory = XEGETUINT32BE(base + p);
|
||||
object_name_ptr = XEGETUINT32BE(base + p + 4);
|
||||
if (object_name_ptr) {
|
||||
object_name.Read(base, object_name_ptr);
|
||||
} else {
|
||||
object_name.Zero();
|
||||
}
|
||||
attributes = XEGETUINT32BE(base + p + 8);
|
||||
}
|
||||
void Zero() {
|
||||
root_directory = 0;
|
||||
object_name_ptr = 0;
|
||||
object_name.Zero();
|
||||
attributes = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOX_H_
|
||||
@@ -1,42 +1,42 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/async_request.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
XAsyncRequest::XAsyncRequest(
|
||||
KernelState* kernel_state, XObject* object,
|
||||
CompletionCallback callback, void* callback_context) :
|
||||
kernel_state_(kernel_state), object_(object),
|
||||
callback_(callback), callback_context_(callback_context),
|
||||
apc_routine_(0), apc_context_(0) {
|
||||
object_->Retain();
|
||||
}
|
||||
|
||||
XAsyncRequest::~XAsyncRequest() {
|
||||
for (vector<XEvent*>::iterator it = wait_events_.begin();
|
||||
it != wait_events_.end(); ++it) {
|
||||
(*it)->Release();
|
||||
}
|
||||
object_->Release();
|
||||
}
|
||||
|
||||
void XAsyncRequest::AddWaitEvent(XEvent* ev) {
|
||||
ev->Retain();
|
||||
wait_events_.push_back(ev);
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/async_request.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xevent.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
XAsyncRequest::XAsyncRequest(
|
||||
KernelState* kernel_state, XObject* object,
|
||||
CompletionCallback callback, void* callback_context) :
|
||||
kernel_state_(kernel_state), object_(object),
|
||||
callback_(callback), callback_context_(callback_context),
|
||||
apc_routine_(0), apc_context_(0) {
|
||||
object_->Retain();
|
||||
}
|
||||
|
||||
XAsyncRequest::~XAsyncRequest() {
|
||||
for (vector<XEvent*>::iterator it = wait_events_.begin();
|
||||
it != wait_events_.end(); ++it) {
|
||||
(*it)->Release();
|
||||
}
|
||||
object_->Release();
|
||||
}
|
||||
|
||||
void XAsyncRequest::AddWaitEvent(XEvent* ev) {
|
||||
ev->Retain();
|
||||
wait_events_.push_back(ev);
|
||||
}
|
||||
@@ -1,61 +1,61 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
class KernelState;
|
||||
class XEvent;
|
||||
class XObject;
|
||||
|
||||
|
||||
class XAsyncRequest {
|
||||
public:
|
||||
typedef void (*CompletionCallback)(XAsyncRequest* request, void* context);
|
||||
|
||||
XAsyncRequest(
|
||||
KernelState* kernel_state, XObject* object,
|
||||
CompletionCallback callback, void* callback_context);
|
||||
virtual ~XAsyncRequest();
|
||||
|
||||
KernelState* kernel_state() const { return kernel_state_; }
|
||||
XObject* object() const { return object_; }
|
||||
|
||||
void AddWaitEvent(XEvent* ev);
|
||||
|
||||
// Complete(result)
|
||||
|
||||
protected:
|
||||
KernelState* kernel_state_;
|
||||
XObject* object_;
|
||||
CompletionCallback callback_;
|
||||
void* callback_context_;
|
||||
|
||||
std::vector<XEvent*> wait_events_;
|
||||
uint32_t apc_routine_;
|
||||
uint32_t apc_context_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
class KernelState;
|
||||
class XEvent;
|
||||
class XObject;
|
||||
|
||||
|
||||
class XAsyncRequest {
|
||||
public:
|
||||
typedef void (*CompletionCallback)(XAsyncRequest* request, void* context);
|
||||
|
||||
XAsyncRequest(
|
||||
KernelState* kernel_state, XObject* object,
|
||||
CompletionCallback callback, void* callback_context);
|
||||
virtual ~XAsyncRequest();
|
||||
|
||||
KernelState* kernel_state() const { return kernel_state_; }
|
||||
XObject* object() const { return object_; }
|
||||
|
||||
void AddWaitEvent(XEvent* ev);
|
||||
|
||||
// Complete(result)
|
||||
|
||||
protected:
|
||||
KernelState* kernel_state_;
|
||||
XObject* object_;
|
||||
CompletionCallback callback_;
|
||||
void* callback_context_;
|
||||
|
||||
std::vector<XEvent*> wait_events_;
|
||||
uint32_t apc_routine_;
|
||||
uint32_t apc_context_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_ASYNC_REQUEST_H_
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/device.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_DEVICE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -42,4 +42,4 @@ protected:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICE_H_
|
||||
@@ -7,10 +7,10 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/disc_image_device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/disc_image_device.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/device.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -47,4 +47,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_DEVICE_H_
|
||||
@@ -1,89 +1,89 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/disc_image_file.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class DiscImageMemoryMapping : public MemoryMapping {
|
||||
public:
|
||||
DiscImageMemoryMapping(uint8_t* address, size_t length, xe_mmap_ref mmap) :
|
||||
MemoryMapping(address, length) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
|
||||
virtual ~DiscImageMemoryMapping() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path,
|
||||
xe_mmap_ref mmap, GDFXEntry* gdfx_entry) :
|
||||
gdfx_entry_(gdfx_entry),
|
||||
Entry(type, device, path) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
|
||||
DiscImageEntry::~DiscImageEntry() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageEntry::QueryInfo(XFileInfo* out_info) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
out_info->creation_time = 0;
|
||||
out_info->last_access_time = 0;
|
||||
out_info->last_write_time = 0;
|
||||
out_info->change_time = 0;
|
||||
out_info->allocation_size = 2048;
|
||||
out_info->file_length = gdfx_entry_->size;
|
||||
out_info->attributes = gdfx_entry_->attributes;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
MemoryMapping* DiscImageEntry::CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) {
|
||||
if (file_mode & kXEFileModeWrite) {
|
||||
// Only allow reads.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t real_offset = gdfx_entry_->offset + offset;
|
||||
size_t real_length = length ?
|
||||
MIN(length, gdfx_entry_->size) : gdfx_entry_->size;
|
||||
return new DiscImageMemoryMapping(
|
||||
xe_mmap_get_addr(mmap_) + real_offset,
|
||||
real_length,
|
||||
mmap_);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageEntry::Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file) {
|
||||
*out_file = new DiscImageFile(kernel_state, desired_access, this);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/disc_image_file.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class DiscImageMemoryMapping : public MemoryMapping {
|
||||
public:
|
||||
DiscImageMemoryMapping(uint8_t* address, size_t length, xe_mmap_ref mmap) :
|
||||
MemoryMapping(address, length) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
|
||||
virtual ~DiscImageMemoryMapping() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path,
|
||||
xe_mmap_ref mmap, GDFXEntry* gdfx_entry) :
|
||||
gdfx_entry_(gdfx_entry),
|
||||
Entry(type, device, path) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
|
||||
DiscImageEntry::~DiscImageEntry() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageEntry::QueryInfo(XFileInfo* out_info) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
out_info->creation_time = 0;
|
||||
out_info->last_access_time = 0;
|
||||
out_info->last_write_time = 0;
|
||||
out_info->change_time = 0;
|
||||
out_info->allocation_size = 2048;
|
||||
out_info->file_length = gdfx_entry_->size;
|
||||
out_info->attributes = gdfx_entry_->attributes;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
MemoryMapping* DiscImageEntry::CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) {
|
||||
if (file_mode & kXEFileModeWrite) {
|
||||
// Only allow reads.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t real_offset = gdfx_entry_->offset + offset;
|
||||
size_t real_length = length ?
|
||||
MIN(length, gdfx_entry_->size) : gdfx_entry_->size;
|
||||
return new DiscImageMemoryMapping(
|
||||
xe_mmap_get_addr(mmap_) + real_offset,
|
||||
real_length,
|
||||
mmap_);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageEntry::Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file) {
|
||||
*out_file = new DiscImageFile(kernel_state, desired_access, this);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
namespace fs {
|
||||
|
||||
class GDFXEntry;
|
||||
|
||||
|
||||
class DiscImageEntry : public Entry {
|
||||
public:
|
||||
DiscImageEntry(Type type, Device* device, const char* path,
|
||||
xe_mmap_ref mmap, GDFXEntry* gdfx_entry);
|
||||
virtual ~DiscImageEntry();
|
||||
|
||||
xe_mmap_ref mmap() const { return mmap_; }
|
||||
GDFXEntry* gdfx_entry() const { return gdfx_entry_; }
|
||||
|
||||
virtual X_STATUS QueryInfo(XFileInfo* out_info);
|
||||
|
||||
virtual MemoryMapping* CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length);
|
||||
|
||||
virtual X_STATUS Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file);
|
||||
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
GDFXEntry* gdfx_entry_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
namespace fs {
|
||||
|
||||
class GDFXEntry;
|
||||
|
||||
|
||||
class DiscImageEntry : public Entry {
|
||||
public:
|
||||
DiscImageEntry(Type type, Device* device, const char* path,
|
||||
xe_mmap_ref mmap, GDFXEntry* gdfx_entry);
|
||||
virtual ~DiscImageEntry();
|
||||
|
||||
xe_mmap_ref mmap() const { return mmap_; }
|
||||
GDFXEntry* gdfx_entry() const { return gdfx_entry_; }
|
||||
|
||||
virtual X_STATUS QueryInfo(XFileInfo* out_info);
|
||||
|
||||
virtual MemoryMapping* CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length);
|
||||
|
||||
virtual X_STATUS Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file);
|
||||
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
GDFXEntry* gdfx_entry_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_ENTRY_H_
|
||||
@@ -1,48 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/fs/devices/disc_image_file.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
DiscImageFile::DiscImageFile(
|
||||
KernelState* kernel_state, uint32_t desired_access,
|
||||
DiscImageEntry* entry) :
|
||||
entry_(entry),
|
||||
XFile(kernel_state, desired_access) {
|
||||
}
|
||||
|
||||
DiscImageFile::~DiscImageFile() {
|
||||
}
|
||||
|
||||
X_STATUS DiscImageFile::QueryInfo(XFileInfo* out_info) {
|
||||
return entry_->QueryInfo(out_info);
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/fs/devices/disc_image_file.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/disc_image_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
DiscImageFile::DiscImageFile(
|
||||
KernelState* kernel_state, uint32_t desired_access,
|
||||
DiscImageEntry* entry) :
|
||||
entry_(entry),
|
||||
XFile(kernel_state, desired_access) {
|
||||
}
|
||||
|
||||
DiscImageFile::~DiscImageFile() {
|
||||
}
|
||||
|
||||
X_STATUS DiscImageFile::QueryInfo(XFileInfo* out_info) {
|
||||
return entry_->QueryInfo(out_info);
|
||||
}
|
||||
|
||||
X_STATUS DiscImageFile::ReadSync(
|
||||
void* buffer, size_t buffer_length, size_t byte_offset,
|
||||
size_t* out_bytes_read) {
|
||||
GDFXEntry* gdfx_entry = entry_->gdfx_entry();
|
||||
xe_mmap_ref mmap = entry_->mmap();
|
||||
size_t real_offset = gdfx_entry->offset + byte_offset;
|
||||
size_t real_length = MIN(buffer_length, gdfx_entry->size - byte_offset);
|
||||
xe_copy_memory(
|
||||
buffer, buffer_length,
|
||||
xe_mmap_get_addr(mmap) + real_offset, real_length);
|
||||
*out_bytes_read = real_length;
|
||||
size_t real_offset = gdfx_entry->offset + byte_offset;
|
||||
size_t real_length = MIN(buffer_length, gdfx_entry->size - byte_offset);
|
||||
xe_copy_memory(
|
||||
buffer, buffer_length,
|
||||
xe_mmap_get_addr(mmap) + real_offset, real_length);
|
||||
*out_bytes_read = real_length;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xfile.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xfile.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -48,4 +48,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_DISC_IMAGE_FILE_H_
|
||||
@@ -7,9 +7,9 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/host_path_device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/host_path_device.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/device.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -40,4 +40,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_DEVICE_H_
|
||||
@@ -1,108 +1,108 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/host_path_file.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class HostPathMemoryMapping : public MemoryMapping {
|
||||
public:
|
||||
HostPathMemoryMapping(uint8_t* address, size_t length, xe_mmap_ref mmap) :
|
||||
MemoryMapping(address, length) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
virtual ~HostPathMemoryMapping() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
HostPathEntry::HostPathEntry(Type type, Device* device, const char* path,
|
||||
const xechar_t* local_path) :
|
||||
Entry(type, device, path) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
}
|
||||
|
||||
HostPathEntry::~HostPathEntry() {
|
||||
xe_free(local_path_);
|
||||
}
|
||||
|
||||
X_STATUS HostPathEntry::QueryInfo(XFileInfo* out_info) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
if (!GetFileAttributesEx(
|
||||
local_path_, GetFileExInfoStandard, &data)) {
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
#define COMBINE_TIME(t) (((uint64_t)t.dwHighDateTime << 32) | t.dwLowDateTime)
|
||||
out_info->creation_time = COMBINE_TIME(data.ftCreationTime);
|
||||
out_info->last_access_time = COMBINE_TIME(data.ftLastAccessTime);
|
||||
out_info->last_write_time = COMBINE_TIME(data.ftLastWriteTime);
|
||||
out_info->change_time = COMBINE_TIME(data.ftLastWriteTime);
|
||||
out_info->allocation_size = 4096;
|
||||
out_info->file_length = ((uint64_t)data.nFileSizeHigh << 32) | data.nFileSizeLow;
|
||||
out_info->attributes = (X_FILE_ATTRIBUTES)data.dwFileAttributes;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
MemoryMapping* HostPathEntry::CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) {
|
||||
xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length);
|
||||
if (!mmap) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HostPathMemoryMapping* lfmm = new HostPathMemoryMapping(
|
||||
(uint8_t*)xe_mmap_get_addr(mmap), xe_mmap_get_length(mmap),
|
||||
mmap);
|
||||
xe_mmap_release(mmap);
|
||||
|
||||
return lfmm;
|
||||
}
|
||||
|
||||
X_STATUS HostPathEntry::Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file) {
|
||||
DWORD share_mode = FILE_SHARE_READ;
|
||||
DWORD creation_disposition = OPEN_EXISTING;
|
||||
DWORD flags_and_attributes = async ? FILE_FLAG_OVERLAPPED : 0;
|
||||
HANDLE file = CreateFile(
|
||||
local_path_,
|
||||
desired_access,
|
||||
share_mode,
|
||||
NULL,
|
||||
creation_disposition,
|
||||
flags_and_attributes,
|
||||
NULL);
|
||||
if (!file) {
|
||||
// TODO(benvanik): pick correct response.
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
*out_file = new HostPathFile(kernel_state, desired_access, this, file);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/host_path_file.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
class HostPathMemoryMapping : public MemoryMapping {
|
||||
public:
|
||||
HostPathMemoryMapping(uint8_t* address, size_t length, xe_mmap_ref mmap) :
|
||||
MemoryMapping(address, length) {
|
||||
mmap_ = xe_mmap_retain(mmap);
|
||||
}
|
||||
virtual ~HostPathMemoryMapping() {
|
||||
xe_mmap_release(mmap_);
|
||||
}
|
||||
private:
|
||||
xe_mmap_ref mmap_;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
HostPathEntry::HostPathEntry(Type type, Device* device, const char* path,
|
||||
const xechar_t* local_path) :
|
||||
Entry(type, device, path) {
|
||||
local_path_ = xestrdup(local_path);
|
||||
}
|
||||
|
||||
HostPathEntry::~HostPathEntry() {
|
||||
xe_free(local_path_);
|
||||
}
|
||||
|
||||
X_STATUS HostPathEntry::QueryInfo(XFileInfo* out_info) {
|
||||
XEASSERTNOTNULL(out_info);
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
||||
if (!GetFileAttributesEx(
|
||||
local_path_, GetFileExInfoStandard, &data)) {
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
#define COMBINE_TIME(t) (((uint64_t)t.dwHighDateTime << 32) | t.dwLowDateTime)
|
||||
out_info->creation_time = COMBINE_TIME(data.ftCreationTime);
|
||||
out_info->last_access_time = COMBINE_TIME(data.ftLastAccessTime);
|
||||
out_info->last_write_time = COMBINE_TIME(data.ftLastWriteTime);
|
||||
out_info->change_time = COMBINE_TIME(data.ftLastWriteTime);
|
||||
out_info->allocation_size = 4096;
|
||||
out_info->file_length = ((uint64_t)data.nFileSizeHigh << 32) | data.nFileSizeLow;
|
||||
out_info->attributes = (X_FILE_ATTRIBUTES)data.dwFileAttributes;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
MemoryMapping* HostPathEntry::CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) {
|
||||
xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length);
|
||||
if (!mmap) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HostPathMemoryMapping* lfmm = new HostPathMemoryMapping(
|
||||
(uint8_t*)xe_mmap_get_addr(mmap), xe_mmap_get_length(mmap),
|
||||
mmap);
|
||||
xe_mmap_release(mmap);
|
||||
|
||||
return lfmm;
|
||||
}
|
||||
|
||||
X_STATUS HostPathEntry::Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file) {
|
||||
DWORD share_mode = FILE_SHARE_READ;
|
||||
DWORD creation_disposition = OPEN_EXISTING;
|
||||
DWORD flags_and_attributes = async ? FILE_FLAG_OVERLAPPED : 0;
|
||||
HANDLE file = CreateFile(
|
||||
local_path_,
|
||||
desired_access,
|
||||
share_mode,
|
||||
NULL,
|
||||
creation_disposition,
|
||||
flags_and_attributes,
|
||||
NULL);
|
||||
if (!file) {
|
||||
// TODO(benvanik): pick correct response.
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
*out_file = new HostPathFile(kernel_state, desired_access, this, file);
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -1,54 +1,54 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class HostPathEntry : public Entry {
|
||||
public:
|
||||
HostPathEntry(Type type, Device* device, const char* path,
|
||||
const xechar_t* local_path);
|
||||
virtual ~HostPathEntry();
|
||||
|
||||
const xechar_t* local_path() { return local_path_; }
|
||||
|
||||
virtual X_STATUS QueryInfo(XFileInfo* out_info);
|
||||
|
||||
virtual MemoryMapping* CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length);
|
||||
|
||||
virtual X_STATUS Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file);
|
||||
|
||||
private:
|
||||
xechar_t* local_path_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
namespace fs {
|
||||
|
||||
|
||||
class HostPathEntry : public Entry {
|
||||
public:
|
||||
HostPathEntry(Type type, Device* device, const char* path,
|
||||
const xechar_t* local_path);
|
||||
virtual ~HostPathEntry();
|
||||
|
||||
const xechar_t* local_path() { return local_path_; }
|
||||
|
||||
virtual X_STATUS QueryInfo(XFileInfo* out_info);
|
||||
|
||||
virtual MemoryMapping* CreateMemoryMapping(
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length);
|
||||
|
||||
virtual X_STATUS Open(
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file);
|
||||
|
||||
private:
|
||||
xechar_t* local_path_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace fs
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_ENTRY_H_
|
||||
@@ -1,38 +1,38 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/fs/devices/host_path_file.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
HostPathFile::HostPathFile(
|
||||
KernelState* kernel_state, uint32_t desired_access,
|
||||
HostPathEntry* entry, HANDLE file_handle) :
|
||||
entry_(entry), file_handle_(file_handle),
|
||||
XFile(kernel_state, desired_access) {
|
||||
}
|
||||
|
||||
HostPathFile::~HostPathFile() {
|
||||
CloseHandle(file_handle_);
|
||||
}
|
||||
|
||||
X_STATUS HostPathFile::QueryInfo(XFileInfo* out_info) {
|
||||
return entry_->QueryInfo(out_info);
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/fs/devices/host_path_file.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/host_path_entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
using namespace xe::kernel::xboxkrnl::fs;
|
||||
|
||||
|
||||
HostPathFile::HostPathFile(
|
||||
KernelState* kernel_state, uint32_t desired_access,
|
||||
HostPathEntry* entry, HANDLE file_handle) :
|
||||
entry_(entry), file_handle_(file_handle),
|
||||
XFile(kernel_state, desired_access) {
|
||||
}
|
||||
|
||||
HostPathFile::~HostPathFile() {
|
||||
CloseHandle(file_handle_);
|
||||
}
|
||||
|
||||
X_STATUS HostPathFile::QueryInfo(XFileInfo* out_info) {
|
||||
return entry_->QueryInfo(out_info);
|
||||
}
|
||||
|
||||
X_STATUS HostPathFile::ReadSync(
|
||||
void* buffer, size_t buffer_length, size_t byte_offset,
|
||||
size_t* out_bytes_read) {
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xfile.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xfile.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -49,4 +49,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_DEVICES_HOST_PATH_FILE_H_
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,21 +7,23 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_ENTRY_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_ENTRY_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_ENTRY_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_ENTRY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
XEDECLARECLASS3(xe, kernel, xboxkrnl, KernelState);
|
||||
XEDECLARECLASS3(xe, kernel, xboxkrnl, XFile);
|
||||
XEDECLARECLASS3(xe, kernel, xboxkrnl, XFileInfo);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
class KernelState;
|
||||
class XFile;
|
||||
class XFileInfo;
|
||||
namespace fs {
|
||||
|
||||
class Device;
|
||||
@@ -62,7 +64,7 @@ public:
|
||||
xe_file_mode file_mode, const size_t offset, const size_t length) = 0;
|
||||
|
||||
virtual X_STATUS Open(
|
||||
KernelState* kernel_state,
|
||||
KernelState* kernel_state,
|
||||
uint32_t desired_access, bool async,
|
||||
XFile** out_file) = 0;
|
||||
|
||||
@@ -80,4 +82,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_ENTRY_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_ENTRY_H_
|
||||
@@ -7,10 +7,10 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/filesystem.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/filesystem.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/disc_image_device.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/devices/host_path_device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/disc_image_device.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/devices/host_path_device.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,15 +7,15 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -53,4 +53,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_FILESYSTEM_H_
|
||||
@@ -9,7 +9,7 @@
|
||||
* - abgx360
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/gdfx.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/gdfx.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,16 +7,16 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_FS_GDFX_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_FS_GDFX_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_FS_GDFX_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_FS_GDFX_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/fs/entry.h>
|
||||
#include <xenia/xbox.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/entry.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -95,4 +95,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_FS_GDFX_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_FS_GDFX_H_
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
|
||||
#include <xenia/kernel/runtime.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -21,17 +21,12 @@ using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
}
|
||||
|
||||
|
||||
KernelState::KernelState(Runtime* runtime) :
|
||||
runtime_(runtime),
|
||||
KernelState::KernelState(Emulator* emulator) :
|
||||
emulator_(emulator),
|
||||
executable_module_(NULL) {
|
||||
memory_ = runtime->memory();
|
||||
processor_ = runtime->processor();
|
||||
filesystem_ = runtime->filesystem();
|
||||
memory_ = xe_memory_retain(emulator->memory());
|
||||
processor_ = emulator->processor();
|
||||
file_system_ = emulator->file_system();
|
||||
|
||||
object_table_ = new ObjectTable();
|
||||
object_mutex_ = xe_mutex_alloc(10000);
|
||||
@@ -44,8 +39,6 @@ KernelState::~KernelState() {
|
||||
xe_mutex_free(object_mutex_);
|
||||
delete object_table_;
|
||||
|
||||
filesystem_.reset();
|
||||
processor_.reset();
|
||||
xe_memory_release(memory_);
|
||||
}
|
||||
|
||||
@@ -53,26 +46,6 @@ KernelState* KernelState::shared() {
|
||||
return shared_kernel_state_;
|
||||
}
|
||||
|
||||
Runtime* KernelState::runtime() {
|
||||
return runtime_;
|
||||
}
|
||||
|
||||
xe_memory_ref KernelState::memory() {
|
||||
return memory_;
|
||||
}
|
||||
|
||||
cpu::Processor* KernelState::processor() {
|
||||
return processor_.get();
|
||||
}
|
||||
|
||||
fs::FileSystem* KernelState::filesystem() {
|
||||
return filesystem_.get();
|
||||
}
|
||||
|
||||
ObjectTable* KernelState::object_table() const {
|
||||
return object_table_;
|
||||
}
|
||||
|
||||
XModule* KernelState::GetModule(const char* name) {
|
||||
// TODO(benvanik): implement lookup. Most games seem to look for xam.xex/etc.
|
||||
XEASSERTALWAYS();
|
||||
71
src/xenia/kernel/xboxkrnl/kernel_state.h
Normal file
71
src/xenia/kernel/xboxkrnl/kernel_state.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_KERNEL_STATE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_KERNEL_STATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/xbox.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
#include <xenia/kernel/xboxkrnl/object_table.h>
|
||||
#include <xenia/kernel/xboxkrnl/fs/filesystem.h>
|
||||
|
||||
|
||||
XEDECLARECLASS2(xe, cpu, Processor);
|
||||
XEDECLARECLASS3(xe, kernel, fs, FileSystem);
|
||||
XEDECLARECLASS3(xe, kernel, xboxkrnl, XModule);
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
class KernelState {
|
||||
public:
|
||||
KernelState(Emulator* emulator);
|
||||
~KernelState();
|
||||
|
||||
static KernelState* shared();
|
||||
|
||||
Emulator* emulator() const { return emulator_; }
|
||||
xe_memory_ref memory() const { return memory_; }
|
||||
cpu::Processor* processor() const { return processor_; }
|
||||
fs::FileSystem* file_system() const { return file_system_; }
|
||||
|
||||
ObjectTable* object_table() const { return object_table_; }
|
||||
|
||||
XModule* GetModule(const char* name);
|
||||
XModule* GetExecutableModule();
|
||||
void SetExecutableModule(XModule* module);
|
||||
|
||||
private:
|
||||
Emulator* emulator_;
|
||||
xe_memory_ref memory_;
|
||||
cpu::Processor* processor_;
|
||||
fs::FileSystem* file_system_;
|
||||
|
||||
ObjectTable* object_table_;
|
||||
xe_mutex_t* object_mutex_;
|
||||
|
||||
XModule* executable_module_;
|
||||
|
||||
friend class XObject;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_KERNEL_STATE_H_
|
||||
@@ -1,194 +1,194 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/object_table.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
ObjectTable::ObjectTable() :
|
||||
table_capacity_(0),
|
||||
table_(NULL),
|
||||
last_free_entry_(0) {
|
||||
table_mutex_ = xe_mutex_alloc(0);
|
||||
XEASSERTNOTNULL(table_mutex_);
|
||||
}
|
||||
|
||||
ObjectTable::~ObjectTable() {
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Release all objects.
|
||||
for (uint32_t n = 0; n < table_capacity_; n++) {
|
||||
ObjectTableEntry& entry = table_[n];
|
||||
if (entry.object) {
|
||||
entry.object->ReleaseHandle();
|
||||
entry.object->Release();
|
||||
}
|
||||
}
|
||||
|
||||
table_capacity_ = 0;
|
||||
last_free_entry_ = 0;
|
||||
xe_free(table_);
|
||||
table_ = NULL;
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
xe_mutex_free(table_mutex_);
|
||||
table_mutex_ = NULL;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) {
|
||||
// Find a free slot.
|
||||
uint32_t slot = last_free_entry_;
|
||||
uint32_t scan_count = 0;
|
||||
while (scan_count < table_capacity_) {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (!entry.object) {
|
||||
*out_slot = slot;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
scan_count++;
|
||||
slot = (slot + 1) % table_capacity_;
|
||||
if (slot == 0) {
|
||||
// Never allow 0 handles.
|
||||
scan_count++;
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
// Table out of slots, expand.
|
||||
uint32_t new_table_capacity = MAX(16 * 1024, table_capacity_ * 2);
|
||||
ObjectTableEntry* new_table = (ObjectTableEntry*)xe_recalloc(
|
||||
table_,
|
||||
table_capacity_ * sizeof(ObjectTableEntry),
|
||||
new_table_capacity * sizeof(ObjectTableEntry));
|
||||
if (!new_table) {
|
||||
return X_STATUS_NO_MEMORY;
|
||||
}
|
||||
last_free_entry_ = table_capacity_;
|
||||
table_capacity_ = new_table_capacity;
|
||||
table_ = new_table;
|
||||
|
||||
// Never allow 0 handles.
|
||||
slot = ++last_free_entry_;
|
||||
*out_slot = slot;
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
|
||||
XEASSERTNOTNULL(out_handle);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Find a free slot.
|
||||
uint32_t slot = 0;
|
||||
result = FindFreeSlot(&slot);
|
||||
|
||||
// Stash.
|
||||
if (XSUCCEEDED(result)) {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
entry.object = object;
|
||||
|
||||
// Retain so long as the object is in the table.
|
||||
object->RetainHandle();
|
||||
object->Retain();
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
*out_handle = slot << 2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Lower 2 bits are ignored.
|
||||
uint32_t slot = handle >> 2;
|
||||
|
||||
// Verify slot.
|
||||
XObject* object = NULL;
|
||||
if (slot > table_capacity_) {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
} else {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
// Release after we lose the lock.
|
||||
object = entry.object;
|
||||
} else {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
if (object) {
|
||||
// Release the object handle now that it is out of the table.
|
||||
object->ReleaseHandle();
|
||||
object->Release();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::GetObject(X_HANDLE handle, XObject** out_object) {
|
||||
XEASSERTNOTNULL(out_object);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
if (handle == 0xFFFFFFFF) {
|
||||
// CurrentProcess
|
||||
XEASSERTALWAYS();
|
||||
} else if (handle == 0xFFFFFFFE) {
|
||||
// CurrentThread
|
||||
handle = XThread::GetCurrentThreadHandle();
|
||||
}
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Lower 2 bits are ignored.
|
||||
uint32_t slot = handle >> 2;
|
||||
|
||||
// Verify slot.
|
||||
XObject* object = NULL;
|
||||
if (slot > table_capacity_) {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
} else {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
object = entry.object;
|
||||
} else {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
// Retain the object pointer.
|
||||
if (object) {
|
||||
object->Retain();
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
*out_object = object;
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/object_table.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
ObjectTable::ObjectTable() :
|
||||
table_capacity_(0),
|
||||
table_(NULL),
|
||||
last_free_entry_(0) {
|
||||
table_mutex_ = xe_mutex_alloc(0);
|
||||
XEASSERTNOTNULL(table_mutex_);
|
||||
}
|
||||
|
||||
ObjectTable::~ObjectTable() {
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Release all objects.
|
||||
for (uint32_t n = 0; n < table_capacity_; n++) {
|
||||
ObjectTableEntry& entry = table_[n];
|
||||
if (entry.object) {
|
||||
entry.object->ReleaseHandle();
|
||||
entry.object->Release();
|
||||
}
|
||||
}
|
||||
|
||||
table_capacity_ = 0;
|
||||
last_free_entry_ = 0;
|
||||
xe_free(table_);
|
||||
table_ = NULL;
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
xe_mutex_free(table_mutex_);
|
||||
table_mutex_ = NULL;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::FindFreeSlot(uint32_t* out_slot) {
|
||||
// Find a free slot.
|
||||
uint32_t slot = last_free_entry_;
|
||||
uint32_t scan_count = 0;
|
||||
while (scan_count < table_capacity_) {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (!entry.object) {
|
||||
*out_slot = slot;
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
scan_count++;
|
||||
slot = (slot + 1) % table_capacity_;
|
||||
if (slot == 0) {
|
||||
// Never allow 0 handles.
|
||||
scan_count++;
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
// Table out of slots, expand.
|
||||
uint32_t new_table_capacity = MAX(16 * 1024, table_capacity_ * 2);
|
||||
ObjectTableEntry* new_table = (ObjectTableEntry*)xe_recalloc(
|
||||
table_,
|
||||
table_capacity_ * sizeof(ObjectTableEntry),
|
||||
new_table_capacity * sizeof(ObjectTableEntry));
|
||||
if (!new_table) {
|
||||
return X_STATUS_NO_MEMORY;
|
||||
}
|
||||
last_free_entry_ = table_capacity_;
|
||||
table_capacity_ = new_table_capacity;
|
||||
table_ = new_table;
|
||||
|
||||
// Never allow 0 handles.
|
||||
slot = ++last_free_entry_;
|
||||
*out_slot = slot;
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
|
||||
XEASSERTNOTNULL(out_handle);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Find a free slot.
|
||||
uint32_t slot = 0;
|
||||
result = FindFreeSlot(&slot);
|
||||
|
||||
// Stash.
|
||||
if (XSUCCEEDED(result)) {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
entry.object = object;
|
||||
|
||||
// Retain so long as the object is in the table.
|
||||
object->RetainHandle();
|
||||
object->Retain();
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
if (XSUCCEEDED(result)) {
|
||||
*out_handle = slot << 2;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) {
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Lower 2 bits are ignored.
|
||||
uint32_t slot = handle >> 2;
|
||||
|
||||
// Verify slot.
|
||||
XObject* object = NULL;
|
||||
if (slot > table_capacity_) {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
} else {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
// Release after we lose the lock.
|
||||
object = entry.object;
|
||||
} else {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
if (object) {
|
||||
// Release the object handle now that it is out of the table.
|
||||
object->ReleaseHandle();
|
||||
object->Release();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
X_STATUS ObjectTable::GetObject(X_HANDLE handle, XObject** out_object) {
|
||||
XEASSERTNOTNULL(out_object);
|
||||
|
||||
X_STATUS result = X_STATUS_SUCCESS;
|
||||
|
||||
if (handle == 0xFFFFFFFF) {
|
||||
// CurrentProcess
|
||||
XEASSERTALWAYS();
|
||||
} else if (handle == 0xFFFFFFFE) {
|
||||
// CurrentThread
|
||||
handle = XThread::GetCurrentThreadHandle();
|
||||
}
|
||||
|
||||
xe_mutex_lock(table_mutex_);
|
||||
|
||||
// Lower 2 bits are ignored.
|
||||
uint32_t slot = handle >> 2;
|
||||
|
||||
// Verify slot.
|
||||
XObject* object = NULL;
|
||||
if (slot > table_capacity_) {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
} else {
|
||||
ObjectTableEntry& entry = table_[slot];
|
||||
if (entry.object) {
|
||||
object = entry.object;
|
||||
} else {
|
||||
result = X_STATUS_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
// Retain the object pointer.
|
||||
if (object) {
|
||||
object->Retain();
|
||||
}
|
||||
|
||||
xe_mutex_unlock(table_mutex_);
|
||||
|
||||
*out_object = object;
|
||||
return result;
|
||||
}
|
||||
@@ -1,55 +1,55 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_OBJECT_TABLE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_OBJECT_TABLE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
class XObject;
|
||||
|
||||
|
||||
class ObjectTable {
|
||||
public:
|
||||
ObjectTable();
|
||||
~ObjectTable();
|
||||
|
||||
X_STATUS AddHandle(XObject* object, X_HANDLE* out_handle);
|
||||
X_STATUS RemoveHandle(X_HANDLE handle);
|
||||
X_STATUS GetObject(X_HANDLE handle, XObject** out_object);
|
||||
|
||||
private:
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot);
|
||||
|
||||
typedef struct {
|
||||
XObject* object;
|
||||
} ObjectTableEntry;
|
||||
|
||||
xe_mutex_t* table_mutex_;
|
||||
uint32_t table_capacity_;
|
||||
ObjectTableEntry* table_;
|
||||
uint32_t last_free_entry_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_OBJECT_TABLE_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_OBJECT_TABLE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_OBJECT_TABLE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
class XObject;
|
||||
|
||||
|
||||
class ObjectTable {
|
||||
public:
|
||||
ObjectTable();
|
||||
~ObjectTable();
|
||||
|
||||
X_STATUS AddHandle(XObject* object, X_HANDLE* out_handle);
|
||||
X_STATUS RemoveHandle(X_HANDLE handle);
|
||||
X_STATUS GetObject(X_HANDLE handle, XObject** out_object);
|
||||
|
||||
private:
|
||||
X_STATUS FindFreeSlot(uint32_t* out_slot);
|
||||
|
||||
typedef struct {
|
||||
XObject* object;
|
||||
} ObjectTableEntry;
|
||||
|
||||
xe_mutex_t* table_mutex_;
|
||||
uint32_t table_capacity_;
|
||||
ObjectTableEntry* table_;
|
||||
uint32_t last_free_entry_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_OBJECT_TABLE_H_
|
||||
@@ -1,67 +1,67 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
XEvent::XEvent(KernelState* kernel_state) :
|
||||
XObject(kernel_state, kTypeEvent),
|
||||
handle_(NULL) {
|
||||
}
|
||||
|
||||
XEvent::~XEvent() {
|
||||
}
|
||||
|
||||
void XEvent::Initialize(bool manual_reset, bool initial_state) {
|
||||
XEASSERTNULL(handle_);
|
||||
|
||||
handle_ = CreateEvent(NULL, manual_reset, initial_state, NULL);
|
||||
}
|
||||
|
||||
void XEvent::InitializeNative(void* native_ptr, DISPATCH_HEADER& header) {
|
||||
XEASSERTNULL(handle_);
|
||||
|
||||
bool manual_reset;
|
||||
switch (header.type_flags >> 24) {
|
||||
case 0x00: // EventNotificationObject (manual reset)
|
||||
manual_reset = true;
|
||||
break;
|
||||
case 0x01: // EventSynchronizationObject (auto reset)
|
||||
manual_reset = false;
|
||||
break;
|
||||
default:
|
||||
XEASSERTALWAYS();
|
||||
return;
|
||||
}
|
||||
|
||||
bool initial_state = header.signal_state ? true : false;
|
||||
|
||||
handle_ = CreateEvent(NULL, manual_reset, initial_state, NULL);
|
||||
}
|
||||
|
||||
int32_t XEvent::Set(uint32_t priority_increment, bool wait) {
|
||||
return SetEvent(handle_) ? 1 : 0;
|
||||
}
|
||||
|
||||
int32_t XEvent::Reset() {
|
||||
return ResetEvent(handle_) ? 1 : 0;
|
||||
}
|
||||
|
||||
void XEvent::Clear() {
|
||||
ResetEvent(handle_);
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/objects/xevent.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
XEvent::XEvent(KernelState* kernel_state) :
|
||||
XObject(kernel_state, kTypeEvent),
|
||||
handle_(NULL) {
|
||||
}
|
||||
|
||||
XEvent::~XEvent() {
|
||||
}
|
||||
|
||||
void XEvent::Initialize(bool manual_reset, bool initial_state) {
|
||||
XEASSERTNULL(handle_);
|
||||
|
||||
handle_ = CreateEvent(NULL, manual_reset, initial_state, NULL);
|
||||
}
|
||||
|
||||
void XEvent::InitializeNative(void* native_ptr, DISPATCH_HEADER& header) {
|
||||
XEASSERTNULL(handle_);
|
||||
|
||||
bool manual_reset;
|
||||
switch (header.type_flags >> 24) {
|
||||
case 0x00: // EventNotificationObject (manual reset)
|
||||
manual_reset = true;
|
||||
break;
|
||||
case 0x01: // EventSynchronizationObject (auto reset)
|
||||
manual_reset = false;
|
||||
break;
|
||||
default:
|
||||
XEASSERTALWAYS();
|
||||
return;
|
||||
}
|
||||
|
||||
bool initial_state = header.signal_state ? true : false;
|
||||
|
||||
handle_ = CreateEvent(NULL, manual_reset, initial_state, NULL);
|
||||
}
|
||||
|
||||
int32_t XEvent::Set(uint32_t priority_increment, bool wait) {
|
||||
return SetEvent(handle_) ? 1 : 0;
|
||||
}
|
||||
|
||||
int32_t XEvent::Reset() {
|
||||
return ResetEvent(handle_) ? 1 : 0;
|
||||
}
|
||||
|
||||
void XEvent::Clear() {
|
||||
ResetEvent(handle_);
|
||||
}
|
||||
|
||||
X_STATUS XEvent::Wait(uint32_t wait_reason, uint32_t processor_mode,
|
||||
uint32_t alertable, uint64_t* opt_timeout) {
|
||||
DWORD timeout_ms;
|
||||
@@ -96,4 +96,4 @@ X_STATUS XEvent::Wait(uint32_t wait_reason, uint32_t processor_mode,
|
||||
case WAIT_ABANDONED:
|
||||
return X_STATUS_ABANDONED_WAIT_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,48 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_XEVENT_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_XEVENT_H_
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
class XEvent : public XObject {
|
||||
public:
|
||||
XEvent(KernelState* kernel_state);
|
||||
virtual ~XEvent();
|
||||
|
||||
void Initialize(bool manual_reset, bool initial_state);
|
||||
void InitializeNative(void* native_ptr, DISPATCH_HEADER& header);
|
||||
|
||||
int32_t Set(uint32_t priority_increment, bool wait);
|
||||
int32_t Reset();
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_XEVENT_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_XEVENT_H_
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
class XEvent : public XObject {
|
||||
public:
|
||||
XEvent(KernelState* kernel_state);
|
||||
virtual ~XEvent();
|
||||
|
||||
void Initialize(bool manual_reset, bool initial_state);
|
||||
void InitializeNative(void* native_ptr, DISPATCH_HEADER& header);
|
||||
|
||||
int32_t Set(uint32_t priority_increment, bool wait);
|
||||
int32_t Reset();
|
||||
void Clear();
|
||||
|
||||
virtual X_STATUS Wait(uint32_t wait_reason, uint32_t processor_mode,
|
||||
uint32_t alertable, uint64_t* opt_timeout);
|
||||
|
||||
private:
|
||||
HANDLE handle_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_XEVENT_H_
|
||||
uint32_t alertable, uint64_t* opt_timeout);
|
||||
|
||||
private:
|
||||
HANDLE handle_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_XEVENT_H_
|
||||
@@ -7,10 +7,10 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xfile.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xfile.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/async_request.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/xboxkrnl/async_request.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xevent.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_XFILE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_XFILE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_XFILE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_XFILE_H_
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -84,4 +84,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_XFILE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_XFILE_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/cpu/cpu.h>
|
||||
#include <xenia/kernel/runtime.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -59,7 +59,7 @@ const xe_xex2_header_t* XModule::xex_header() {
|
||||
X_STATUS XModule::LoadFromFile(const char* path) {
|
||||
// Resolve the file to open.
|
||||
// TODO(benvanik): make this code shared?
|
||||
fs::Entry* fs_entry = kernel_state()->filesystem()->ResolvePath(path);
|
||||
fs::Entry* fs_entry = kernel_state()->file_system()->ResolvePath(path);
|
||||
if (!fs_entry) {
|
||||
XELOGE("File not found: %s", path);
|
||||
return X_STATUS_NO_SUCH_FILE;
|
||||
@@ -152,7 +152,8 @@ X_STATUS XModule::Launch(uint32_t flags) {
|
||||
}
|
||||
|
||||
void XModule::Dump() {
|
||||
ExportResolver* export_resolver = runtime()->export_resolver().get();
|
||||
ExportResolver* export_resolver =
|
||||
kernel_state_->emulator()->export_resolver();
|
||||
const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
|
||||
|
||||
// XEX info.
|
||||
@@ -7,15 +7,15 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_XMODULE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_XMODULE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_XMODULE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_XMODULE_H_
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/xbox.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
|
||||
|
||||
@@ -59,4 +59,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_XMODULE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_XMODULE_H_
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
#include <xenia/cpu/cpu.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_threading.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -192,7 +192,7 @@ X_STATUS XThread::Create() {
|
||||
|
||||
X_STATUS XThread::Exit(int exit_code) {
|
||||
// TODO(benvanik): set exit code in thread state block
|
||||
|
||||
|
||||
// TODO(benvanik); dispatch events? waiters? etc?
|
||||
event_->Set(0, false);
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_XTHREAD_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_XTHREAD_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_XTHREAD_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_XTHREAD_H_
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -94,4 +94,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_XTHREAD_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_XTHREAD_H_
|
||||
@@ -5,8 +5,6 @@
|
||||
'async_request.h',
|
||||
'kernel_state.cc',
|
||||
'kernel_state.h',
|
||||
'module.cc',
|
||||
'module.h',
|
||||
'object_table.cc',
|
||||
'object_table.h',
|
||||
'xboxkrnl_debug.cc',
|
||||
@@ -21,6 +19,8 @@
|
||||
'xboxkrnl_misc.h',
|
||||
'xboxkrnl_module.cc',
|
||||
'xboxkrnl_module.h',
|
||||
'xboxkrnl_modules.cc',
|
||||
'xboxkrnl_modules.h',
|
||||
'xboxkrnl_nt.cc',
|
||||
'xboxkrnl_nt.h',
|
||||
'xboxkrnl_ob.cc',
|
||||
@@ -1,242 +1,242 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/xboxkrnl_debug.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL DbgPrint_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(0);
|
||||
if (format_ptr == 0) {
|
||||
SHIM_SET_RETURN(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *format = (const char *)SHIM_MEM_ADDR(format_ptr);
|
||||
|
||||
int arg_index = 0;
|
||||
|
||||
char buffer[512]; // TODO: ensure it never writes past the end of the buffer...
|
||||
char *b = buffer;
|
||||
for (; *format != '\0'; ++format) {
|
||||
const char *start = format;
|
||||
|
||||
if (*format != '%') {
|
||||
*b++ = *format;
|
||||
continue;
|
||||
}
|
||||
|
||||
++format;
|
||||
if (*format == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (*format == '%') {
|
||||
*b++ = *format;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *end;
|
||||
end = format;
|
||||
|
||||
// skip flags
|
||||
while (*end == '-' ||
|
||||
*end == '+' ||
|
||||
*end == ' ' ||
|
||||
*end == '#' ||
|
||||
*end == '0') {
|
||||
++end;
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
int arg_extras = 0;
|
||||
|
||||
// skip width
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
arg_extras++;
|
||||
}
|
||||
else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
// skip precision
|
||||
if (*end == '.') {
|
||||
++end;
|
||||
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
++arg_extras;
|
||||
}
|
||||
else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
// get length
|
||||
int arg_size = 4;
|
||||
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
else if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 8;
|
||||
}
|
||||
}
|
||||
else if (*end == 'j') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'z') {
|
||||
arg_size = 4;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 't') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'L') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (*end == 'd' ||
|
||||
*end == 'i' ||
|
||||
*end == 'u' ||
|
||||
*end == 'o' ||
|
||||
*end == 'x' ||
|
||||
*end == 'X' ||
|
||||
*end == 'f' ||
|
||||
*end == 'F' ||
|
||||
*end == 'e' ||
|
||||
*end == 'E' ||
|
||||
*end == 'g' ||
|
||||
*end == 'G' ||
|
||||
*end == 'a' ||
|
||||
*end == 'A' ||
|
||||
*end == 'c') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
XEASSERT(arg_size == 8 || arg_size == 4);
|
||||
if (arg_size == 8) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_64(1 + arg_index)
|
||||
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
else if (arg_size == 4) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_64(1 + arg_index)
|
||||
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
int result = sprintf(b, local, (uint32_t)value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*end == 's' ||
|
||||
*end == 'p' ||
|
||||
*end == 'n') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
XEASSERT(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_32(1 + arg_index)
|
||||
: (uint32_t)SHIM_MEM_64(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
const char *pointer = (const char *)SHIM_MEM_ADDR(value);
|
||||
int result = sprintf(b, local, pointer);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
format = end;
|
||||
}
|
||||
*b++ = '\0';
|
||||
|
||||
XELOGD("(DbgPrint) %s", buffer);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterDebugExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", DbgPrint, state);
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/xboxkrnl_debug.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// TODO: clean me up!
|
||||
SHIM_CALL DbgPrint_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
|
||||
uint32_t format_ptr = SHIM_GET_ARG_32(0);
|
||||
if (format_ptr == 0) {
|
||||
SHIM_SET_RETURN(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *format = (const char *)SHIM_MEM_ADDR(format_ptr);
|
||||
|
||||
int arg_index = 0;
|
||||
|
||||
char buffer[512]; // TODO: ensure it never writes past the end of the buffer...
|
||||
char *b = buffer;
|
||||
for (; *format != '\0'; ++format) {
|
||||
const char *start = format;
|
||||
|
||||
if (*format != '%') {
|
||||
*b++ = *format;
|
||||
continue;
|
||||
}
|
||||
|
||||
++format;
|
||||
if (*format == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (*format == '%') {
|
||||
*b++ = *format;
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *end;
|
||||
end = format;
|
||||
|
||||
// skip flags
|
||||
while (*end == '-' ||
|
||||
*end == '+' ||
|
||||
*end == ' ' ||
|
||||
*end == '#' ||
|
||||
*end == '0') {
|
||||
++end;
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
int arg_extras = 0;
|
||||
|
||||
// skip width
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
arg_extras++;
|
||||
}
|
||||
else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
// skip precision
|
||||
if (*end == '.') {
|
||||
++end;
|
||||
|
||||
if (*end == '*') {
|
||||
++end;
|
||||
++arg_extras;
|
||||
}
|
||||
else {
|
||||
while (*end >= '0' && *end <= '9') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
// get length
|
||||
int arg_size = 4;
|
||||
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'h') {
|
||||
++end;
|
||||
}
|
||||
}
|
||||
else if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 4;
|
||||
if (*end == 'l') {
|
||||
++end;
|
||||
arg_size = 8;
|
||||
}
|
||||
}
|
||||
else if (*end == 'j') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'z') {
|
||||
arg_size = 4;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 't') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
else if (*end == 'L') {
|
||||
arg_size = 8;
|
||||
++end;
|
||||
}
|
||||
|
||||
if (*end == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (*end == 'd' ||
|
||||
*end == 'i' ||
|
||||
*end == 'u' ||
|
||||
*end == 'o' ||
|
||||
*end == 'x' ||
|
||||
*end == 'X' ||
|
||||
*end == 'f' ||
|
||||
*end == 'F' ||
|
||||
*end == 'e' ||
|
||||
*end == 'E' ||
|
||||
*end == 'g' ||
|
||||
*end == 'G' ||
|
||||
*end == 'a' ||
|
||||
*end == 'A' ||
|
||||
*end == 'c') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
XEASSERT(arg_size == 8 || arg_size == 4);
|
||||
if (arg_size == 8) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_64(1 + arg_index)
|
||||
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
int result = sprintf(b, local, value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
else if (arg_size == 4) {
|
||||
if (arg_extras == 0) {
|
||||
uint64_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_64(1 + arg_index)
|
||||
: SHIM_MEM_32(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
int result = sprintf(b, local, (uint32_t)value);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (*end == 's' ||
|
||||
*end == 'p' ||
|
||||
*end == 'n') {
|
||||
char local[512];
|
||||
local[0] = '\0';
|
||||
strncat(local, start, end + 1 - start);
|
||||
|
||||
XEASSERT(arg_size == 4);
|
||||
if (arg_extras == 0) {
|
||||
uint32_t value = arg_index < 7
|
||||
? SHIM_GET_ARG_32(1 + arg_index)
|
||||
: (uint32_t)SHIM_MEM_64(SHIM_GPR_32(1) + 16 + ((1 + arg_index) * 8));
|
||||
const char *pointer = (const char *)SHIM_MEM_ADDR(value);
|
||||
int result = sprintf(b, local, pointer);
|
||||
b += result;
|
||||
arg_index++;
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
XEASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
format = end;
|
||||
}
|
||||
*b++ = '\0';
|
||||
|
||||
XELOGD("(DbgPrint) %s", buffer);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterDebugExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", DbgPrint, state);
|
||||
}
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_DEBUG_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_DEBUG_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_DEBUG_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_DEBUG_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -26,4 +26,4 @@ namespace xboxkrnl {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_DEBUG_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_DEBUG_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_hal.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_hal.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_HAL_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_HAL_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -29,4 +29,4 @@ void xeHalReturnToFirmware(uint32_t routine);
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_HAL_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_HAL_H_
|
||||
@@ -7,14 +7,14 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_io.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_io.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/async_request.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xfile.h>
|
||||
#include <xenia/kernel/xboxkrnl/async_request.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xfile.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -63,7 +63,7 @@ SHIM_CALL NtCreateFile_shim(
|
||||
uint32_t handle;
|
||||
|
||||
// Resolve the file using the virtual file system.
|
||||
FileSystem* fs = state->filesystem();
|
||||
FileSystem* fs = state->file_system();
|
||||
Entry* entry = fs->ResolvePath(attrs.object_name.buffer);
|
||||
XFile* file = NULL;
|
||||
if (entry && entry->type() == Entry::kTypeFile) {
|
||||
@@ -312,15 +312,15 @@ SHIM_CALL NtQueryInformationFile_shim(
|
||||
SHIM_SET_MEM_64(file_info_ptr, file->position());
|
||||
break;
|
||||
case XFileNetworkOpenInformation:
|
||||
// struct FILE_NETWORK_OPEN_INFORMATION {
|
||||
// LARGE_INTEGER CreationTime;
|
||||
// LARGE_INTEGER LastAccessTime;
|
||||
// LARGE_INTEGER LastWriteTime;
|
||||
// LARGE_INTEGER ChangeTime;
|
||||
// LARGE_INTEGER AllocationSize;
|
||||
// LARGE_INTEGER EndOfFile;
|
||||
// ULONG FileAttributes;
|
||||
// ULONG Unknown;
|
||||
// struct FILE_NETWORK_OPEN_INFORMATION {
|
||||
// LARGE_INTEGER CreationTime;
|
||||
// LARGE_INTEGER LastAccessTime;
|
||||
// LARGE_INTEGER LastWriteTime;
|
||||
// LARGE_INTEGER ChangeTime;
|
||||
// LARGE_INTEGER AllocationSize;
|
||||
// LARGE_INTEGER EndOfFile;
|
||||
// ULONG FileAttributes;
|
||||
// ULONG Unknown;
|
||||
// };
|
||||
XEASSERT(length == 56);
|
||||
XFileInfo file_info;
|
||||
@@ -369,7 +369,7 @@ SHIM_CALL NtQueryFullAttributesFile_shim(
|
||||
X_STATUS result = X_STATUS_NO_SUCH_FILE;
|
||||
|
||||
// Resolve the file using the virtual file system.
|
||||
FileSystem* fs = state->filesystem();
|
||||
FileSystem* fs = state->file_system();
|
||||
Entry* entry = fs->ResolvePath(attrs.object_name.buffer);
|
||||
if (entry && entry->type() == Entry::kTypeFile) {
|
||||
// Found.
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_IO_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_IO_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_IO_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_IO_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -26,4 +26,4 @@ namespace xboxkrnl {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_IO_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_IO_H_
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_memory.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_MEMORY_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_MEMORY_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -42,4 +42,4 @@ uint32_t xeMmGetPhysicalAddress(uint32_t base_address);
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_MEMORY_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_MEMORY_H_
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_misc.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_misc.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MISC_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_MISC_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_MISC_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_MISC_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -26,4 +26,4 @@ namespace xboxkrnl {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_MISC_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_MISC_H_
|
||||
@@ -7,14 +7,14 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/module.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_module.h>
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -29,39 +29,37 @@ DEFINE_bool(abort_before_entry, false,
|
||||
KernelState* xe::kernel::xboxkrnl::shared_kernel_state_ = NULL;
|
||||
|
||||
|
||||
XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
KernelModule(runtime) {
|
||||
ExportResolver* resolver = export_resolver_.get();
|
||||
|
||||
XboxkrnlModule::XboxkrnlModule(Emulator* emulator) :
|
||||
KernelModule(emulator) {
|
||||
// Build the export table used for resolution.
|
||||
#include <xenia/kernel/util/export_table_pre.inc>
|
||||
static KernelExport xboxkrnl_export_table[] = {
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_table.inc>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_table.inc>
|
||||
};
|
||||
#include <xenia/kernel/util/export_table_post.inc>
|
||||
resolver->RegisterTable(
|
||||
export_resolver_->RegisterTable(
|
||||
"xboxkrnl.exe", xboxkrnl_export_table, XECOUNT(xboxkrnl_export_table));
|
||||
|
||||
// Setup the kernel state instance.
|
||||
// This is where all kernel objects are kept while running.
|
||||
kernel_state_ = auto_ptr<KernelState>(new KernelState(runtime));
|
||||
kernel_state_ = new KernelState(emulator);
|
||||
|
||||
// Setup the shared global state object.
|
||||
XEASSERTNULL(shared_kernel_state_);
|
||||
shared_kernel_state_ = kernel_state_.get();
|
||||
shared_kernel_state_ = kernel_state_;
|
||||
|
||||
// Register all exported functions.
|
||||
RegisterDebugExports(resolver, kernel_state_.get());
|
||||
RegisterHalExports(resolver, kernel_state_.get());
|
||||
RegisterIoExports(resolver, kernel_state_.get());
|
||||
RegisterMemoryExports(resolver, kernel_state_.get());
|
||||
RegisterMiscExports(resolver, kernel_state_.get());
|
||||
RegisterModuleExports(resolver, kernel_state_.get());
|
||||
RegisterNtExports(resolver, kernel_state_.get());
|
||||
RegisterObExports(resolver, kernel_state_.get());
|
||||
RegisterRtlExports(resolver, kernel_state_.get());
|
||||
RegisterThreadingExports(resolver, kernel_state_.get());
|
||||
RegisterVideoExports(resolver, kernel_state_.get());
|
||||
RegisterDebugExports(export_resolver_, kernel_state_);
|
||||
RegisterHalExports(export_resolver_, kernel_state_);
|
||||
RegisterIoExports(export_resolver_, kernel_state_);
|
||||
RegisterMemoryExports(export_resolver_, kernel_state_);
|
||||
RegisterMiscExports(export_resolver_, kernel_state_);
|
||||
RegisterModuleExports(export_resolver_, kernel_state_);
|
||||
RegisterNtExports(export_resolver_, kernel_state_);
|
||||
RegisterObExports(export_resolver_, kernel_state_);
|
||||
RegisterRtlExports(export_resolver_, kernel_state_);
|
||||
RegisterThreadingExports(export_resolver_, kernel_state_);
|
||||
RegisterVideoExports(export_resolver_, kernel_state_);
|
||||
|
||||
uint8_t* mem = xe_memory_addr(memory_);
|
||||
|
||||
@@ -70,7 +68,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// Offset 0x18 is a 4b pointer to a handler function that seems to take two
|
||||
// arguments. If we wanted to see what would happen we could fake that.
|
||||
uint32_t pKeDebugMonitorData = xe_memory_heap_alloc(memory_, 0, 256, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeDebugMonitorData,
|
||||
pKeDebugMonitorData);
|
||||
XESETUINT32BE(mem + pKeDebugMonitorData, 0);
|
||||
@@ -78,7 +76,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// KeCertMonitorData (?*)
|
||||
// Always set to zero, ignored.
|
||||
uint32_t pKeCertMonitorData = xe_memory_heap_alloc(memory_, 0, 4, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeCertMonitorData,
|
||||
pKeCertMonitorData);
|
||||
XESETUINT32BE(mem + pKeCertMonitorData, 0);
|
||||
@@ -89,7 +87,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// Games seem to check if bit 26 (0x20) is set, which at least for xbox1
|
||||
// was whether an HDD was present. Not sure what the other flags are.
|
||||
uint32_t pXboxHardwareInfo = xe_memory_heap_alloc(memory_, 0, 16, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XboxHardwareInfo,
|
||||
pXboxHardwareInfo);
|
||||
XESETUINT32BE(mem + pXboxHardwareInfo + 0, 0x00000000); // flags
|
||||
@@ -107,7 +105,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// 0x80101100 <- xex header base
|
||||
uint32_t ppXexExecutableModuleHandle =
|
||||
xe_memory_heap_alloc(memory_, 0, 4, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle,
|
||||
ppXexExecutableModuleHandle);
|
||||
uint32_t pXexExecutableModuleHandle =
|
||||
@@ -120,7 +118,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// Perhaps it's how swap disc/etc data is sent?
|
||||
// Always set to "default.xex" (with quotes) for now.
|
||||
uint32_t pExLoadedCommandLine = xe_memory_heap_alloc(memory_, 0, 1024, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::ExLoadedCommandLine,
|
||||
pExLoadedCommandLine);
|
||||
char command_line[] = "\"default.xex\"";
|
||||
@@ -131,7 +129,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
// Kernel version, looks like 2b.2b.2b.2b.
|
||||
// I've only seen games check >=, so we just fake something here.
|
||||
uint32_t pXboxKrnlVersion = xe_memory_heap_alloc(memory_, 0, 8, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::XboxKrnlVersion,
|
||||
pXboxKrnlVersion);
|
||||
XESETUINT16BE(mem + pXboxKrnlVersion + 0, 2);
|
||||
@@ -141,7 +139,7 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
|
||||
// KeTimeStampBundle (ad)
|
||||
uint32_t pKeTimeStampBundle = xe_memory_heap_alloc(memory_, 0, 24, 0);
|
||||
resolver->SetVariableMapping(
|
||||
export_resolver_->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::KeTimeStampBundle,
|
||||
pKeTimeStampBundle);
|
||||
XESETUINT64BE(mem + pKeTimeStampBundle + 0, 0);
|
||||
@@ -150,6 +148,8 @@ XboxkrnlModule::XboxkrnlModule(Runtime* runtime) :
|
||||
}
|
||||
|
||||
XboxkrnlModule::~XboxkrnlModule() {
|
||||
delete kernel_state_;
|
||||
|
||||
// Clear the shared kernel state.
|
||||
shared_kernel_state_ = NULL;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ XboxkrnlModule::~XboxkrnlModule() {
|
||||
int XboxkrnlModule::LaunchModule(const char* path) {
|
||||
// Create and register the module. We keep it local to this function and
|
||||
// dispose it on exit.
|
||||
XModule* module = new XModule(kernel_state_.get(), path);
|
||||
XModule* module = new XModule(kernel_state_, path);
|
||||
|
||||
// Load the module into memory from the filesystem.
|
||||
X_STATUS result_code = module->LoadFromFile(path);
|
||||
@@ -7,24 +7,24 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
#include <xenia/export_resolver.h>
|
||||
#include <xenia/kernel/kernel_module.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_ordinals.h>
|
||||
|
||||
// All of the exported functions:
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_debug.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_hal.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_memory.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_module.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_video.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_debug.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_hal.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_memory.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_module.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_rtl.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_threading.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_video.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -36,13 +36,13 @@ class KernelState;
|
||||
|
||||
class XboxkrnlModule : public KernelModule {
|
||||
public:
|
||||
XboxkrnlModule(Runtime* runtime);
|
||||
XboxkrnlModule(Emulator* emulator);
|
||||
virtual ~XboxkrnlModule();
|
||||
|
||||
int LaunchModule(const char* path);
|
||||
|
||||
private:
|
||||
auto_ptr<KernelState> kernel_state_;
|
||||
KernelState* kernel_state_;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,4 +51,4 @@ private:
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_MODULE_H_
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_module.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_modules.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_MODULES_IMPL_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_MODULES_IMPL_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -35,4 +35,4 @@ int xeXexGetModuleHandle(const char* module_name,
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_MODULE_IMPL_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_MODULES_IMPL_H_
|
||||
@@ -7,12 +7,12 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_nt.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_nt.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_NT_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_NT_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_NT_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_NT_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -26,4 +26,4 @@ namespace xboxkrnl {
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_NT_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_NT_H_
|
||||
@@ -1,101 +1,101 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/xboxkrnl_ob.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL ObReferenceObjectByHandle_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t object_type_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t out_object_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
XELOGD(
|
||||
"ObReferenceObjectByHandle(%.8X, %.8X, %.8X)",
|
||||
handle,
|
||||
object_type_ptr,
|
||||
out_object_ptr);
|
||||
|
||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||
|
||||
XObject* object = NULL;
|
||||
result = state->object_table()->GetObject(handle, &object);
|
||||
if (XSUCCEEDED(result)) {
|
||||
// TODO(benvanik): verify type with object_type_ptr
|
||||
|
||||
// TODO(benvanik): get native value, if supported.
|
||||
uint32_t native_ptr = 0xDEADF00D;
|
||||
switch (object_type_ptr) {
|
||||
case 0xD01BBEEF: // ExThreadObjectType
|
||||
{
|
||||
XThread* thread = (XThread*)object;
|
||||
native_ptr = thread->thread_state();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (out_object_ptr) {
|
||||
SHIM_SET_MEM_32(out_object_ptr, native_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
SHIM_SET_RETURN(result);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL ObDereferenceObject_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t native_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"ObDereferenceObject(%.8X)",
|
||||
native_ptr);
|
||||
|
||||
// Check if a dummy value from ObReferenceObjectByHandle.
|
||||
if (native_ptr == 0xDEADF00D) {
|
||||
SHIM_SET_RETURN(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void* object_ptr = SHIM_MEM_ADDR(native_ptr);
|
||||
XObject* object = XObject::GetObject(state, object_ptr);
|
||||
if (object) {
|
||||
object->Release();
|
||||
}
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterObExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", ObReferenceObjectByHandle, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", ObDereferenceObject, state);
|
||||
}
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/xboxkrnl_ob.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/xobject.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
SHIM_CALL ObReferenceObjectByHandle_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t handle = SHIM_GET_ARG_32(0);
|
||||
uint32_t object_type_ptr = SHIM_GET_ARG_32(1);
|
||||
uint32_t out_object_ptr = SHIM_GET_ARG_32(2);
|
||||
|
||||
XELOGD(
|
||||
"ObReferenceObjectByHandle(%.8X, %.8X, %.8X)",
|
||||
handle,
|
||||
object_type_ptr,
|
||||
out_object_ptr);
|
||||
|
||||
X_STATUS result = X_STATUS_INVALID_HANDLE;
|
||||
|
||||
XObject* object = NULL;
|
||||
result = state->object_table()->GetObject(handle, &object);
|
||||
if (XSUCCEEDED(result)) {
|
||||
// TODO(benvanik): verify type with object_type_ptr
|
||||
|
||||
// TODO(benvanik): get native value, if supported.
|
||||
uint32_t native_ptr = 0xDEADF00D;
|
||||
switch (object_type_ptr) {
|
||||
case 0xD01BBEEF: // ExThreadObjectType
|
||||
{
|
||||
XThread* thread = (XThread*)object;
|
||||
native_ptr = thread->thread_state();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (out_object_ptr) {
|
||||
SHIM_SET_MEM_32(out_object_ptr, native_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
SHIM_SET_RETURN(result);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL ObDereferenceObject_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t native_ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"ObDereferenceObject(%.8X)",
|
||||
native_ptr);
|
||||
|
||||
// Check if a dummy value from ObReferenceObjectByHandle.
|
||||
if (native_ptr == 0xDEADF00D) {
|
||||
SHIM_SET_RETURN(0);
|
||||
return;
|
||||
}
|
||||
|
||||
void* object_ptr = SHIM_MEM_ADDR(native_ptr);
|
||||
XObject* object = XObject::GetObject(state, object_ptr);
|
||||
if (object) {
|
||||
object->Release();
|
||||
}
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterObExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", ObReferenceObjectByHandle, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", ObDereferenceObject, state);
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_OB_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_OB_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_OB_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_OB_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_OB_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_OB_H_
|
||||
@@ -1,29 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_ORDINALS_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_ORDINALS_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/export.h>
|
||||
|
||||
|
||||
// Build an ordinal enum to make it easy to lookup ordinals.
|
||||
#include <xenia/kernel/util/ordinal_table_pre.inc>
|
||||
namespace ordinals {
|
||||
enum {
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_table.inc>
|
||||
};
|
||||
} // namespace ordinals
|
||||
#include <xenia/kernel/util/ordinal_table_post.inc>
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_ORDINALS_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/export_resolver.h>
|
||||
|
||||
|
||||
// Build an ordinal enum to make it easy to lookup ordinals.
|
||||
#include <xenia/kernel/util/ordinal_table_pre.inc>
|
||||
namespace ordinals {
|
||||
enum {
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_table.inc>
|
||||
};
|
||||
} // namespace ordinals
|
||||
#include <xenia/kernel/util/ordinal_table_post.inc>
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_ORDINALS_H_
|
||||
@@ -1,51 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_PRIVATE_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_PRIVATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_ordinals.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
class KernelState;
|
||||
|
||||
|
||||
// This is a global object initialized with the XboxkrnlModule.
|
||||
// It references the current kernel state object that all kernel methods should
|
||||
// be using to stash their variables.
|
||||
extern KernelState* shared_kernel_state_;
|
||||
|
||||
// Registration functions, one per file.
|
||||
void RegisterDebugExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterHalExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterIoExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterMemoryExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterMiscExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterModuleExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterNtExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterObExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterRtlExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterThreadingExports(ExportResolver* export_resolver,
|
||||
KernelState* state);
|
||||
void RegisterVideoExports(ExportResolver* export_resolver, KernelState* state);
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_PRIVATE_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_ordinals.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
class KernelState;
|
||||
|
||||
|
||||
// This is a global object initialized with the XboxkrnlModule.
|
||||
// It references the current kernel state object that all kernel methods should
|
||||
// be using to stash their variables.
|
||||
extern KernelState* shared_kernel_state_;
|
||||
|
||||
// Registration functions, one per file.
|
||||
void RegisterDebugExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterHalExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterIoExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterMemoryExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterMiscExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterModuleExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterNtExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterObExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterRtlExports(ExportResolver* export_resolver, KernelState* state);
|
||||
void RegisterThreadingExports(ExportResolver* export_resolver,
|
||||
KernelState* state);
|
||||
void RegisterVideoExports(ExportResolver* export_resolver, KernelState* state);
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_PRIVATE_H_
|
||||
@@ -7,14 +7,14 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_rtl.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xex2.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xmodule.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -54,4 +54,4 @@ void xeRtlLeaveCriticalSection(uint32_t cs_ptr);
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_RTL_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_RTL_H_
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_threading.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_threading.h>
|
||||
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/objects/xthread.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xevent.h>
|
||||
#include <xenia/kernel/xboxkrnl/objects/xthread.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
|
||||
#ifndef XENIA_KERNEL_XBOXKRNL_THREADING_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_THREADING_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
@@ -62,4 +62,4 @@ void xeKeLeaveCriticalRegion();
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_THREADING_H_
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_THREADING_H_
|
||||
@@ -1,443 +1,444 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/modules/xboxkrnl/xboxkrnl_video.h>
|
||||
|
||||
#include <xenia/cpu/cpu.h>
|
||||
#include <xenia/gpu/gpu.h>
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/modules/xboxkrnl/xboxkrnl_rtl.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// http://www.tweakoz.com/orkid/
|
||||
// http://www.tweakoz.com/orkid/dox/d3/d52/xb360init_8cpp_source.html
|
||||
// https://github.com/Free60Project/xenosfb/
|
||||
// https://github.com/Free60Project/xenosfb/blob/master/src/xe.h
|
||||
// https://github.com/gligli/libxemit
|
||||
// http://web.archive.org/web/20090428095215/http://msdn.microsoft.com/en-us/library/bb313877.aspx
|
||||
// http://web.archive.org/web/20100423054747/http://msdn.microsoft.com/en-us/library/bb313961.aspx
|
||||
// http://web.archive.org/web/20100423054747/http://msdn.microsoft.com/en-us/library/bb313878.aspx
|
||||
// http://web.archive.org/web/20090510235238/http://msdn.microsoft.com/en-us/library/bb313942.aspx
|
||||
// http://svn.dd-wrt.com/browser/src/linux/universal/linux-3.8/drivers/gpu/drm/radeon/radeon_ring.c
|
||||
// http://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped Down Direct3D: Xbox 360 Command Buffer and Resource Management"
|
||||
|
||||
|
||||
void xeVdGetCurrentDisplayGamma(uint32_t* arg0, float* arg1) {
|
||||
*arg0 = 2;
|
||||
*arg1 = 2.22222233f;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayGamma_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t arg0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t arg1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdGetCurrentDisplayGamma(%.8X, %.8X)",
|
||||
arg0_ptr, arg1_ptr);
|
||||
|
||||
uint32_t arg0 = 0;
|
||||
union {
|
||||
float float_value;
|
||||
uint32_t uint_value;
|
||||
} arg1;
|
||||
xeVdGetCurrentDisplayGamma(&arg0, &arg1.float_value);
|
||||
SHIM_SET_MEM_32(arg0_ptr, arg0);
|
||||
SHIM_SET_MEM_32(arg1_ptr, arg1.uint_value);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayInformation_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdGetCurrentDisplayInformation(%.8X)",
|
||||
ptr);
|
||||
|
||||
// Expecting a length 0x58 struct of stuff.
|
||||
SHIM_SET_MEM_32(ptr + 0x10, 1280);
|
||||
SHIM_SET_MEM_32(ptr + 0x14, 720);
|
||||
SHIM_SET_MEM_16(ptr + 0x48, 1280);
|
||||
SHIM_SET_MEM_16(ptr + 0x4A, 720);
|
||||
SHIM_SET_MEM_16(ptr + 0x56, 1280);
|
||||
}
|
||||
|
||||
|
||||
uint32_t xeVdQueryVideoFlags() {
|
||||
// ?
|
||||
return 0x00000007;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoFlags_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdQueryVideoFlags()");
|
||||
|
||||
SHIM_SET_RETURN(xeVdQueryVideoFlags());
|
||||
}
|
||||
|
||||
|
||||
void xeVdQueryVideoMode(X_VIDEO_MODE *video_mode, bool swap) {
|
||||
if (video_mode == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: get info from actual display
|
||||
video_mode->display_width = 1280;
|
||||
video_mode->display_height = 720;
|
||||
video_mode->is_interlaced = 0;
|
||||
video_mode->is_widescreen = 1;
|
||||
video_mode->is_hi_def = 1;
|
||||
video_mode->refresh_rate = 60.0f;
|
||||
video_mode->video_standard = 1; // NTSC
|
||||
video_mode->unknown_0x8a = 0x8A;
|
||||
video_mode->unknown_0x01 = 0x01;
|
||||
|
||||
if (swap) {
|
||||
video_mode->display_width = XESWAP32BE(video_mode->display_width);
|
||||
video_mode->display_height = XESWAP32BE(video_mode->display_height);
|
||||
video_mode->is_interlaced = XESWAP32BE(video_mode->is_interlaced);
|
||||
video_mode->is_widescreen = XESWAP32BE(video_mode->is_widescreen);
|
||||
video_mode->is_hi_def = XESWAP32BE(video_mode->is_hi_def);
|
||||
video_mode->refresh_rate = XESWAPF32BE(video_mode->refresh_rate);
|
||||
video_mode->video_standard = XESWAP32BE(video_mode->video_standard);
|
||||
video_mode->unknown_0x8a = XESWAP32BE(video_mode->unknown_0x8a);
|
||||
video_mode->unknown_0x01 = XESWAP32BE(video_mode->unknown_0x01);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
|
||||
X_VIDEO_MODE *video_mode = (X_VIDEO_MODE*)SHIM_MEM_ADDR(video_mode_ptr);
|
||||
|
||||
XELOGD(
|
||||
"VdQueryVideoMode(%.8X)",
|
||||
video_mode_ptr);
|
||||
|
||||
xeVdQueryVideoMode(video_mode, true);
|
||||
}
|
||||
|
||||
|
||||
void xeVdInitializeEngines(uint32_t unk0, uint32_t callback, uint32_t unk1,
|
||||
uint32_t unk2_ptr, uint32_t unk3_ptr) {
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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/kernel/xboxkrnl/xboxkrnl_video.h>
|
||||
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/cpu/cpu.h>
|
||||
#include <xenia/gpu/gpu.h>
|
||||
#include <xenia/kernel/shim_utils.h>
|
||||
#include <xenia/kernel/xboxkrnl/kernel_state.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_private.h>
|
||||
#include <xenia/kernel/xboxkrnl/xboxkrnl_rtl.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::kernel;
|
||||
using namespace xe::kernel::xboxkrnl;
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// http://www.tweakoz.com/orkid/
|
||||
// http://www.tweakoz.com/orkid/dox/d3/d52/xb360init_8cpp_source.html
|
||||
// https://github.com/Free60Project/xenosfb/
|
||||
// https://github.com/Free60Project/xenosfb/blob/master/src/xe.h
|
||||
// https://github.com/gligli/libxemit
|
||||
// http://web.archive.org/web/20090428095215/http://msdn.microsoft.com/en-us/library/bb313877.aspx
|
||||
// http://web.archive.org/web/20100423054747/http://msdn.microsoft.com/en-us/library/bb313961.aspx
|
||||
// http://web.archive.org/web/20100423054747/http://msdn.microsoft.com/en-us/library/bb313878.aspx
|
||||
// http://web.archive.org/web/20090510235238/http://msdn.microsoft.com/en-us/library/bb313942.aspx
|
||||
// http://svn.dd-wrt.com/browser/src/linux/universal/linux-3.8/drivers/gpu/drm/radeon/radeon_ring.c
|
||||
// http://www.microsoft.com/en-za/download/details.aspx?id=5313 -- "Stripped Down Direct3D: Xbox 360 Command Buffer and Resource Management"
|
||||
|
||||
|
||||
void xeVdGetCurrentDisplayGamma(uint32_t* arg0, float* arg1) {
|
||||
*arg0 = 2;
|
||||
*arg1 = 2.22222233f;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayGamma_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t arg0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t arg1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdGetCurrentDisplayGamma(%.8X, %.8X)",
|
||||
arg0_ptr, arg1_ptr);
|
||||
|
||||
uint32_t arg0 = 0;
|
||||
union {
|
||||
float float_value;
|
||||
uint32_t uint_value;
|
||||
} arg1;
|
||||
xeVdGetCurrentDisplayGamma(&arg0, &arg1.float_value);
|
||||
SHIM_SET_MEM_32(arg0_ptr, arg0);
|
||||
SHIM_SET_MEM_32(arg1_ptr, arg1.uint_value);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetCurrentDisplayInformation_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdGetCurrentDisplayInformation(%.8X)",
|
||||
ptr);
|
||||
|
||||
// Expecting a length 0x58 struct of stuff.
|
||||
SHIM_SET_MEM_32(ptr + 0x10, 1280);
|
||||
SHIM_SET_MEM_32(ptr + 0x14, 720);
|
||||
SHIM_SET_MEM_16(ptr + 0x48, 1280);
|
||||
SHIM_SET_MEM_16(ptr + 0x4A, 720);
|
||||
SHIM_SET_MEM_16(ptr + 0x56, 1280);
|
||||
}
|
||||
|
||||
|
||||
uint32_t xeVdQueryVideoFlags() {
|
||||
// ?
|
||||
return 0x00000007;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoFlags_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdQueryVideoFlags()");
|
||||
|
||||
SHIM_SET_RETURN(xeVdQueryVideoFlags());
|
||||
}
|
||||
|
||||
|
||||
void xeVdQueryVideoMode(X_VIDEO_MODE *video_mode, bool swap) {
|
||||
if (video_mode == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: get info from actual display
|
||||
video_mode->display_width = 1280;
|
||||
video_mode->display_height = 720;
|
||||
video_mode->is_interlaced = 0;
|
||||
video_mode->is_widescreen = 1;
|
||||
video_mode->is_hi_def = 1;
|
||||
video_mode->refresh_rate = 60.0f;
|
||||
video_mode->video_standard = 1; // NTSC
|
||||
video_mode->unknown_0x8a = 0x8A;
|
||||
video_mode->unknown_0x01 = 0x01;
|
||||
|
||||
if (swap) {
|
||||
video_mode->display_width = XESWAP32BE(video_mode->display_width);
|
||||
video_mode->display_height = XESWAP32BE(video_mode->display_height);
|
||||
video_mode->is_interlaced = XESWAP32BE(video_mode->is_interlaced);
|
||||
video_mode->is_widescreen = XESWAP32BE(video_mode->is_widescreen);
|
||||
video_mode->is_hi_def = XESWAP32BE(video_mode->is_hi_def);
|
||||
video_mode->refresh_rate = XESWAPF32BE(video_mode->refresh_rate);
|
||||
video_mode->video_standard = XESWAP32BE(video_mode->video_standard);
|
||||
video_mode->unknown_0x8a = XESWAP32BE(video_mode->unknown_0x8a);
|
||||
video_mode->unknown_0x01 = XESWAP32BE(video_mode->unknown_0x01);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdQueryVideoMode_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t video_mode_ptr = SHIM_GET_ARG_32(0);
|
||||
X_VIDEO_MODE *video_mode = (X_VIDEO_MODE*)SHIM_MEM_ADDR(video_mode_ptr);
|
||||
|
||||
XELOGD(
|
||||
"VdQueryVideoMode(%.8X)",
|
||||
video_mode_ptr);
|
||||
|
||||
xeVdQueryVideoMode(video_mode, true);
|
||||
}
|
||||
|
||||
|
||||
void xeVdInitializeEngines(uint32_t unk0, uint32_t callback, uint32_t unk1,
|
||||
uint32_t unk2_ptr, uint32_t unk3_ptr) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = 0x4F810000
|
||||
// r4 = function ptr (cleanup callback?)
|
||||
// r5 = 0
|
||||
// r6/r7 = some binary data in .data
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeEngines_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t callback = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk2_ptr = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk3_ptr = SHIM_GET_ARG_32(4);
|
||||
|
||||
XELOGD(
|
||||
"VdInitializeEngines(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, callback, unk1, unk2_ptr, unk3_ptr);
|
||||
|
||||
xeVdInitializeEngines(unk0, callback, unk1, unk2_ptr, unk3_ptr);
|
||||
}
|
||||
|
||||
|
||||
void xeVdSetGraphicsInterruptCallback(uint32_t callback, uint32_t user_data) {
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = 0x4F810000
|
||||
// r4 = function ptr (cleanup callback?)
|
||||
// r5 = 0
|
||||
// r6/r7 = some binary data in .data
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeEngines_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t callback = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk2_ptr = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk3_ptr = SHIM_GET_ARG_32(4);
|
||||
|
||||
XELOGD(
|
||||
"VdInitializeEngines(%.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, callback, unk1, unk2_ptr, unk3_ptr);
|
||||
|
||||
xeVdInitializeEngines(unk0, callback, unk1, unk2_ptr, unk3_ptr);
|
||||
}
|
||||
|
||||
|
||||
void xeVdSetGraphicsInterruptCallback(uint32_t callback, uint32_t user_data) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// callback takes 2 params
|
||||
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
|
||||
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
|
||||
|
||||
gs->SetInterruptCallback(callback, user_data);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSetGraphicsInterruptCallback_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t callback = SHIM_GET_ARG_32(0);
|
||||
uint32_t user_data = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdSetGraphicsInterruptCallback(%.8X, %.8X)",
|
||||
callback, user_data);
|
||||
|
||||
xeVdSetGraphicsInterruptCallback(callback, user_data);
|
||||
}
|
||||
|
||||
|
||||
void xeVdInitializeRingBuffer(uint32_t ptr, uint32_t page_count) {
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// callback takes 2 params
|
||||
// r3 = bool 0/1 - 0 is normal interrupt, 1 is some acquire/lock mumble
|
||||
// r4 = user_data (r4 of VdSetGraphicsInterruptCallback)
|
||||
|
||||
gs->SetInterruptCallback(callback, user_data);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSetGraphicsInterruptCallback_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t callback = SHIM_GET_ARG_32(0);
|
||||
uint32_t user_data = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdSetGraphicsInterruptCallback(%.8X, %.8X)",
|
||||
callback, user_data);
|
||||
|
||||
xeVdSetGraphicsInterruptCallback(callback, user_data);
|
||||
}
|
||||
|
||||
|
||||
void xeVdInitializeRingBuffer(uint32_t ptr, uint32_t page_count) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = result of MmGetPhysicalAddress
|
||||
// r4 = number of pages? page size?
|
||||
// 0x8000 -> cntlzw=16 -> 0x1C - 16 = 12
|
||||
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
|
||||
// Sizes could be zero? XBLA games seem to do this. Default sizes?
|
||||
// D3D does size / region_count - must be > 1024
|
||||
|
||||
gs->InitializeRingBuffer(ptr, page_count);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeRingBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t page_count = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdInitializeRingBuffer(%.8X, %.8X)",
|
||||
ptr, page_count);
|
||||
|
||||
xeVdInitializeRingBuffer(ptr, page_count);
|
||||
}
|
||||
|
||||
|
||||
void xeVdEnableRingBufferRPtrWriteBack(uint32_t ptr, uint32_t block_size) {
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = result of MmGetPhysicalAddress
|
||||
// r4 = number of pages? page size?
|
||||
// 0x8000 -> cntlzw=16 -> 0x1C - 16 = 12
|
||||
// Buffer pointers are from MmAllocatePhysicalMemory with WRITE_COMBINE.
|
||||
// Sizes could be zero? XBLA games seem to do this. Default sizes?
|
||||
// D3D does size / region_count - must be > 1024
|
||||
|
||||
gs->InitializeRingBuffer(ptr, page_count);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdInitializeRingBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t page_count = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdInitializeRingBuffer(%.8X, %.8X)",
|
||||
ptr, page_count);
|
||||
|
||||
xeVdInitializeRingBuffer(ptr, page_count);
|
||||
}
|
||||
|
||||
|
||||
void xeVdEnableRingBufferRPtrWriteBack(uint32_t ptr, uint32_t block_size) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r4 = 6, usually --- <=19
|
||||
gs->EnableReadPointerWriteBack(ptr, block_size);
|
||||
|
||||
ptr += 0x20000000;
|
||||
printf("%.8X", ptr);
|
||||
// 0x0110343c
|
||||
|
||||
// r3 = 0x2B10(d3d?) + 0x3C
|
||||
|
||||
//((p + 0x3C) & 0x1FFFFFFF) + ((((p + 0x3C) >> 20) + 0x200) & 0x1000)
|
||||
//also 0x3C offset into WriteBacks is PrimaryRingBufferReadIndex
|
||||
//(1:17:38 AM) Rick: .text:8201B348 lwz r11, 0x2B10(r31)
|
||||
//(1:17:38 AM) Rick: .text:8201B34C addi r11, r11, 0x3C
|
||||
//(1:17:38 AM) Rick: .text:8201B350 srwi r10, r11, 20 # r10 = r11 >> 20
|
||||
//(1:17:38 AM) Rick: .text:8201B354 clrlwi r11, r11, 3 # r11 = r11 & 0x1FFFFFFF
|
||||
//(1:17:38 AM) Rick: .text:8201B358 addi r10, r10, 0x200
|
||||
//(1:17:39 AM) Rick: .text:8201B35C rlwinm r10, r10, 0,19,19 # r10 = r10 & 0x1000
|
||||
//(1:17:39 AM) Rick: .text:8201B360 add r3, r10, r11
|
||||
//(1:17:39 AM) Rick: .text:8201B364 bl VdEnableRingBufferRPtrWriteBack
|
||||
// TODO(benvanik): something?
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdEnableRingBufferRPtrWriteBack_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t block_size = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdEnableRingBufferRPtrWriteBack(%.8X, %.8X)",
|
||||
ptr, block_size);
|
||||
|
||||
xeVdEnableRingBufferRPtrWriteBack(ptr, block_size);
|
||||
}
|
||||
|
||||
|
||||
void xeVdGetSystemCommandBuffer(uint32_t* p0, uint32_t* p1) {
|
||||
*p0 = 0xBEEF0000;
|
||||
*p1 = 0xBEEF0001;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetSystemCommandBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t p0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t p1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdGetSystemCommandBuffer(%.8X, %.8X)",
|
||||
p0_ptr,
|
||||
p1_ptr);
|
||||
|
||||
uint32_t p0 = 0;
|
||||
uint32_t p1 = 0;
|
||||
xeVdGetSystemCommandBuffer(&p0, &p1);
|
||||
SHIM_SET_MEM_32(p0_ptr, p0);
|
||||
SHIM_SET_MEM_32(p1_ptr, p1);
|
||||
}
|
||||
|
||||
|
||||
void xeVdSetSystemCommandBufferGpuIdentifierAddress(uint32_t unk) {
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r4 = 6, usually --- <=19
|
||||
gs->EnableReadPointerWriteBack(ptr, block_size);
|
||||
|
||||
ptr += 0x20000000;
|
||||
printf("%.8X", ptr);
|
||||
// 0x0110343c
|
||||
|
||||
// r3 = 0x2B10(d3d?) + 0x3C
|
||||
|
||||
//((p + 0x3C) & 0x1FFFFFFF) + ((((p + 0x3C) >> 20) + 0x200) & 0x1000)
|
||||
//also 0x3C offset into WriteBacks is PrimaryRingBufferReadIndex
|
||||
//(1:17:38 AM) Rick: .text:8201B348 lwz r11, 0x2B10(r31)
|
||||
//(1:17:38 AM) Rick: .text:8201B34C addi r11, r11, 0x3C
|
||||
//(1:17:38 AM) Rick: .text:8201B350 srwi r10, r11, 20 # r10 = r11 >> 20
|
||||
//(1:17:38 AM) Rick: .text:8201B354 clrlwi r11, r11, 3 # r11 = r11 & 0x1FFFFFFF
|
||||
//(1:17:38 AM) Rick: .text:8201B358 addi r10, r10, 0x200
|
||||
//(1:17:39 AM) Rick: .text:8201B35C rlwinm r10, r10, 0,19,19 # r10 = r10 & 0x1000
|
||||
//(1:17:39 AM) Rick: .text:8201B360 add r3, r10, r11
|
||||
//(1:17:39 AM) Rick: .text:8201B364 bl VdEnableRingBufferRPtrWriteBack
|
||||
// TODO(benvanik): something?
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdEnableRingBufferRPtrWriteBack_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t block_size = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdEnableRingBufferRPtrWriteBack(%.8X, %.8X)",
|
||||
ptr, block_size);
|
||||
|
||||
xeVdEnableRingBufferRPtrWriteBack(ptr, block_size);
|
||||
}
|
||||
|
||||
|
||||
void xeVdGetSystemCommandBuffer(uint32_t* p0, uint32_t* p1) {
|
||||
*p0 = 0xBEEF0000;
|
||||
*p1 = 0xBEEF0001;
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdGetSystemCommandBuffer_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t p0_ptr = SHIM_GET_ARG_32(0);
|
||||
uint32_t p1_ptr = SHIM_GET_ARG_32(1);
|
||||
|
||||
XELOGD(
|
||||
"VdGetSystemCommandBuffer(%.8X, %.8X)",
|
||||
p0_ptr,
|
||||
p1_ptr);
|
||||
|
||||
uint32_t p0 = 0;
|
||||
uint32_t p1 = 0;
|
||||
xeVdGetSystemCommandBuffer(&p0, &p1);
|
||||
SHIM_SET_MEM_32(p0_ptr, p0);
|
||||
SHIM_SET_MEM_32(p1_ptr, p1);
|
||||
}
|
||||
|
||||
|
||||
void xeVdSetSystemCommandBufferGpuIdentifierAddress(uint32_t unk) {
|
||||
KernelState* state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = 0x2B10(d3d?) + 8
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSetSystemCommandBufferGpuIdentifierAddress_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdSetSystemCommandBufferGpuIdentifierAddress(%.8X)",
|
||||
unk);
|
||||
|
||||
xeVdSetSystemCommandBufferGpuIdentifierAddress(unk);
|
||||
}
|
||||
|
||||
|
||||
// VdVerifyMEInitCommand
|
||||
// r3
|
||||
// r4 = 19
|
||||
// no op?
|
||||
|
||||
|
||||
// VdCallGraphicsNotificationRoutines
|
||||
// r3 = 1
|
||||
// r4 = ?
|
||||
// callbacks get 0, r3, r4
|
||||
|
||||
|
||||
SHIM_CALL VdIsHSIOTrainingSucceeded_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdIsHSIOTrainingSucceeded()");
|
||||
|
||||
// Not really sure what this should be - code does weird stuff here:
|
||||
// (cntlzw r11, r3 / extrwi r11, r11, 1, 26)
|
||||
SHIM_SET_RETURN(1);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdPersistDisplay_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdPersistDisplay(?)");
|
||||
|
||||
// ?
|
||||
SHIM_SET_RETURN(1);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAMWorker_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdRetrainEDRAMWorker(%.8X)",
|
||||
unk0);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAM_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
|
||||
XELOGD(
|
||||
"VdRetrainEDRAM(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, unk1, unk2, unk3, unk4, unk5);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSwap_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
uint32_t unk6 = SHIM_GET_ARG_32(6);
|
||||
uint32_t unk7 = SHIM_GET_ARG_32(7);
|
||||
|
||||
XELOGD(
|
||||
"VdSwap(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0,
|
||||
unk1,
|
||||
unk2,
|
||||
unk3,
|
||||
unk4,
|
||||
unk5,
|
||||
unk6,
|
||||
unk7);
|
||||
|
||||
XEASSERTNOTNULL(state);
|
||||
GraphicsSystem* gs = state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
// r3 = 0x2B10(d3d?) + 8
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSetSystemCommandBufferGpuIdentifierAddress_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdSetSystemCommandBufferGpuIdentifierAddress(%.8X)",
|
||||
unk);
|
||||
|
||||
xeVdSetSystemCommandBufferGpuIdentifierAddress(unk);
|
||||
}
|
||||
|
||||
|
||||
// VdVerifyMEInitCommand
|
||||
// r3
|
||||
// r4 = 19
|
||||
// no op?
|
||||
|
||||
|
||||
// VdCallGraphicsNotificationRoutines
|
||||
// r3 = 1
|
||||
// r4 = ?
|
||||
// callbacks get 0, r3, r4
|
||||
|
||||
|
||||
SHIM_CALL VdIsHSIOTrainingSucceeded_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdIsHSIOTrainingSucceeded()");
|
||||
|
||||
// Not really sure what this should be - code does weird stuff here:
|
||||
// (cntlzw r11, r3 / extrwi r11, r11, 1, 26)
|
||||
SHIM_SET_RETURN(1);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdPersistDisplay_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
XELOGD(
|
||||
"VdPersistDisplay(?)");
|
||||
|
||||
// ?
|
||||
SHIM_SET_RETURN(1);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAMWorker_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
|
||||
XELOGD(
|
||||
"VdRetrainEDRAMWorker(%.8X)",
|
||||
unk0);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdRetrainEDRAM_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
|
||||
XELOGD(
|
||||
"VdRetrainEDRAM(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0, unk1, unk2, unk3, unk4, unk5);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
SHIM_CALL VdSwap_shim(
|
||||
xe_ppc_state_t* ppc_state, KernelState* state) {
|
||||
uint32_t unk0 = SHIM_GET_ARG_32(0);
|
||||
uint32_t unk1 = SHIM_GET_ARG_32(1);
|
||||
uint32_t unk2 = SHIM_GET_ARG_32(2);
|
||||
uint32_t unk3 = SHIM_GET_ARG_32(3);
|
||||
uint32_t unk4 = SHIM_GET_ARG_32(4);
|
||||
uint32_t unk5 = SHIM_GET_ARG_32(5);
|
||||
uint32_t unk6 = SHIM_GET_ARG_32(6);
|
||||
uint32_t unk7 = SHIM_GET_ARG_32(7);
|
||||
|
||||
XELOGD(
|
||||
"VdSwap(%.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X, %.8X)",
|
||||
unk0,
|
||||
unk1,
|
||||
unk2,
|
||||
unk3,
|
||||
unk4,
|
||||
unk5,
|
||||
unk6,
|
||||
unk7);
|
||||
|
||||
KernelState* kernel_state = shared_kernel_state_;
|
||||
XEASSERTNOTNULL(kernel_state);
|
||||
GraphicsSystem* gs = kernel_state->processor()->graphics_system().get();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
gs->set_swap_pending(true);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdGetCurrentDisplayGamma, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdGetCurrentDisplayInformation, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdQueryVideoFlags, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdQueryVideoMode, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdInitializeEngines, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdSetGraphicsInterruptCallback, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdInitializeRingBuffer, state);
|
||||
XEASSERTNOTNULL(kernel_state);
|
||||
GraphicsSystem* gs = kernel_state->emulator()->graphics_system();
|
||||
if (!gs) {
|
||||
return;
|
||||
}
|
||||
|
||||
gs->set_swap_pending(true);
|
||||
|
||||
SHIM_SET_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
ExportResolver* export_resolver, KernelState* state) {
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdGetCurrentDisplayGamma, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdGetCurrentDisplayInformation, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdQueryVideoFlags, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdQueryVideoMode, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdInitializeEngines, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdSetGraphicsInterruptCallback, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdInitializeRingBuffer, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdEnableRingBufferRPtrWriteBack, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdGetSystemCommandBuffer, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe",
|
||||
@@ -447,40 +448,40 @@ void xe::kernel::xboxkrnl::RegisterVideoExports(
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdRetrainEDRAMWorker, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdRetrainEDRAM, state);
|
||||
SHIM_SET_MAPPING("xboxkrnl.exe", VdSwap, state);
|
||||
|
||||
xe_memory_ref memory = state->memory();
|
||||
uint8_t* mem = xe_memory_addr(memory);
|
||||
|
||||
// VdGlobalDevice (4b)
|
||||
// Pointer to a global D3D device. Games only seem to set this, so we don't
|
||||
// have to do anything. We may want to read it back later, though.
|
||||
uint32_t pVdGlobalDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalDevice,
|
||||
pVdGlobalDevice);
|
||||
XESETUINT32BE(mem + pVdGlobalDevice, 0);
|
||||
|
||||
// VdGlobalXamDevice (4b)
|
||||
// Pointer to the XAM D3D device, which we don't have.
|
||||
uint32_t pVdGlobalXamDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalXamDevice,
|
||||
pVdGlobalXamDevice);
|
||||
XESETUINT32BE(mem + pVdGlobalXamDevice, 0);
|
||||
|
||||
// VdGpuClockInMHz (4b)
|
||||
// GPU clock. Xenos is 500MHz. Hope nothing is relying on this timing...
|
||||
uint32_t pVdGpuClockInMHz = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGpuClockInMHz,
|
||||
pVdGpuClockInMHz);
|
||||
XESETUINT32BE(mem + pVdGpuClockInMHz, 500);
|
||||
|
||||
// VdHSIOCalibrationLock (28b)
|
||||
// CriticalSection.
|
||||
uint32_t pVdHSIOCalibrationLock = xe_memory_heap_alloc(memory, 0, 28, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdHSIOCalibrationLock,
|
||||
pVdHSIOCalibrationLock);
|
||||
xeRtlInitializeCriticalSectionAndSpinCount(pVdHSIOCalibrationLock, 10000);
|
||||
}
|
||||
|
||||
xe_memory_ref memory = state->memory();
|
||||
uint8_t* mem = xe_memory_addr(memory);
|
||||
|
||||
// VdGlobalDevice (4b)
|
||||
// Pointer to a global D3D device. Games only seem to set this, so we don't
|
||||
// have to do anything. We may want to read it back later, though.
|
||||
uint32_t pVdGlobalDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalDevice,
|
||||
pVdGlobalDevice);
|
||||
XESETUINT32BE(mem + pVdGlobalDevice, 0);
|
||||
|
||||
// VdGlobalXamDevice (4b)
|
||||
// Pointer to the XAM D3D device, which we don't have.
|
||||
uint32_t pVdGlobalXamDevice = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGlobalXamDevice,
|
||||
pVdGlobalXamDevice);
|
||||
XESETUINT32BE(mem + pVdGlobalXamDevice, 0);
|
||||
|
||||
// VdGpuClockInMHz (4b)
|
||||
// GPU clock. Xenos is 500MHz. Hope nothing is relying on this timing...
|
||||
uint32_t pVdGpuClockInMHz = xe_memory_heap_alloc(memory, 0, 4, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdGpuClockInMHz,
|
||||
pVdGpuClockInMHz);
|
||||
XESETUINT32BE(mem + pVdGpuClockInMHz, 500);
|
||||
|
||||
// VdHSIOCalibrationLock (28b)
|
||||
// CriticalSection.
|
||||
uint32_t pVdHSIOCalibrationLock = xe_memory_heap_alloc(memory, 0, 28, 0);
|
||||
export_resolver->SetVariableMapping(
|
||||
"xboxkrnl.exe", ordinals::VdHSIOCalibrationLock,
|
||||
pVdHSIOCalibrationLock);
|
||||
xeRtlInitializeCriticalSectionAndSpinCount(pVdHSIOCalibrationLock, 10000);
|
||||
}
|
||||
@@ -1,57 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_MODULES_XBOXKRNL_VIDEO_H_
|
||||
#define XENIA_KERNEL_MODULES_XBOXKRNL_VIDEO_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/kernel/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// http://ffplay360.googlecode.com/svn/trunk/Common/XTLOnPC.h
|
||||
#pragma pack(push, 1)
|
||||
typedef struct {
|
||||
uint32_t display_width;
|
||||
uint32_t display_height;
|
||||
uint32_t is_interlaced;
|
||||
uint32_t is_widescreen;
|
||||
uint32_t is_hi_def;
|
||||
float refresh_rate;
|
||||
uint32_t video_standard;
|
||||
uint32_t unknown_0x8a;
|
||||
uint32_t unknown_0x01;
|
||||
uint32_t reserved[3];
|
||||
}
|
||||
X_VIDEO_MODE;
|
||||
#pragma pack(pop)
|
||||
XEASSERTSTRUCTSIZE(X_VIDEO_MODE, 48);
|
||||
|
||||
void xeVdGetCurrentDisplayGamma(uint32_t* arg0, float* arg1);
|
||||
uint32_t xeVdQueryVideoFlags();
|
||||
void xeVdQueryVideoMode(X_VIDEO_MODE *video_mode, bool swap);
|
||||
|
||||
void xeVdInitializeEngines(uint32_t unk0, uint32_t callback, uint32_t unk1,
|
||||
uint32_t unk2_ptr, uint32_t unk3_ptr);
|
||||
void xeVdSetGraphicsInterruptCallback(uint32_t callback, uint32_t user_data);
|
||||
void xeVdEnableRingBufferRPtrWriteBack(uint32_t ptr, uint32_t block_size);
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_MODULES_XBOXKRNL_VIDEO_H_
|
||||
/**
|
||||
******************************************************************************
|
||||
* 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_KERNEL_XBOXKRNL_VIDEO_H_
|
||||
#define XENIA_KERNEL_XBOXKRNL_VIDEO_H_
|
||||
|
||||
#include <xenia/common.h>
|
||||
#include <xenia/core.h>
|
||||
|
||||
#include <xenia/xbox.h>
|
||||
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
namespace xboxkrnl {
|
||||
|
||||
|
||||
// http://ffplay360.googlecode.com/svn/trunk/Common/XTLOnPC.h
|
||||
#pragma pack(push, 1)
|
||||
typedef struct {
|
||||
uint32_t display_width;
|
||||
uint32_t display_height;
|
||||
uint32_t is_interlaced;
|
||||
uint32_t is_widescreen;
|
||||
uint32_t is_hi_def;
|
||||
float refresh_rate;
|
||||
uint32_t video_standard;
|
||||
uint32_t unknown_0x8a;
|
||||
uint32_t unknown_0x01;
|
||||
uint32_t reserved[3];
|
||||
}
|
||||
X_VIDEO_MODE;
|
||||
#pragma pack(pop)
|
||||
XEASSERTSTRUCTSIZE(X_VIDEO_MODE, 48);
|
||||
|
||||
void xeVdGetCurrentDisplayGamma(uint32_t* arg0, float* arg1);
|
||||
uint32_t xeVdQueryVideoFlags();
|
||||
void xeVdQueryVideoMode(X_VIDEO_MODE *video_mode, bool swap);
|
||||
|
||||
void xeVdInitializeEngines(uint32_t unk0, uint32_t callback, uint32_t unk1,
|
||||
uint32_t unk2_ptr, uint32_t unk3_ptr);
|
||||
void xeVdSetGraphicsInterruptCallback(uint32_t callback, uint32_t user_data);
|
||||
void xeVdEnableRingBufferRPtrWriteBack(uint32_t ptr, uint32_t block_size);
|
||||
|
||||
|
||||
} // namespace xboxkrnl
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
||||
|
||||
#endif // XENIA_KERNEL_XBOXKRNL_VIDEO_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user