unique_ptr'ing things and removing some XECLEANUP.
This commit is contained in:
parent
244e8a8745
commit
c59d053404
|
@ -10,22 +10,16 @@
|
||||||
#include <xenia/apu/apu.h>
|
#include <xenia/apu/apu.h>
|
||||||
#include <xenia/apu/apu-private.h>
|
#include <xenia/apu/apu-private.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::apu;
|
using namespace xe::apu;
|
||||||
|
|
||||||
|
DEFINE_string(apu, "any", "Audio system. Use: [any, nop, xaudio2]");
|
||||||
DEFINE_string(apu, "any",
|
|
||||||
"Audio system. Use: [any, nop, xaudio2]");
|
|
||||||
|
|
||||||
|
|
||||||
#include <xenia/apu/nop/nop_apu.h>
|
#include <xenia/apu/nop/nop_apu.h>
|
||||||
AudioSystem* xe::apu::CreateNop(Emulator* emulator) {
|
std::unique_ptr<AudioSystem> xe::apu::CreateNop(Emulator* emulator) {
|
||||||
return xe::apu::nop::Create(emulator);
|
return xe::apu::nop::Create(emulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
#include <xenia/apu/xaudio2/xaudio2_apu.h>
|
#include <xenia/apu/xaudio2/xaudio2_apu.h>
|
||||||
AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||||
|
@ -33,17 +27,16 @@ AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||||
}
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
AudioSystem* xe::apu::Create(Emulator* emulator) {
|
std::unique_ptr<AudioSystem> xe::apu::Create(Emulator* emulator) {
|
||||||
if (FLAGS_apu.compare("nop") == 0) {
|
if (FLAGS_apu.compare("nop") == 0) {
|
||||||
return CreateNop(emulator);
|
return CreateNop(emulator);
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
}
|
} else if (FLAGS_apu.compare("xaudio2") == 0) {
|
||||||
else if (FLAGS_apu.compare("xaudio2") == 0) {
|
|
||||||
return CreateXAudio2(emulator);
|
return CreateXAudio2(emulator);
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
} else {
|
} else {
|
||||||
// Create best available.
|
// Create best available.
|
||||||
AudioSystem* best = NULL;
|
std::unique_ptr<AudioSystem> best;
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
best = CreateXAudio2(emulator);
|
best = CreateXAudio2(emulator);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_APU_APU_H_
|
#ifndef XENIA_APU_APU_H_
|
||||||
#define XENIA_APU_APU_H_
|
#define XENIA_APU_APU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/apu/audio_system.h>
|
#include <xenia/apu/audio_system.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -19,12 +21,12 @@ class Emulator;
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace apu {
|
namespace apu {
|
||||||
|
|
||||||
AudioSystem* Create(Emulator* emulator);
|
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
AudioSystem* CreateNop(Emulator* emulator);
|
std::unique_ptr<AudioSystem> CreateNop(Emulator* emulator);
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
AudioSystem* CreateXAudio2(Emulator* emulator);
|
std::unique_ptr<AudioSystem> CreateXAudio2(Emulator* emulator);
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
} // namespace apu
|
} // namespace apu
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
#include <xenia/apu/nop/nop_audio_system.h>
|
#include <xenia/apu/nop/nop_audio_system.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::apu;
|
using namespace xe::apu;
|
||||||
using namespace xe::apu::nop;
|
using namespace xe::apu::nop;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void InitializeIfNeeded();
|
void InitializeIfNeeded();
|
||||||
void CleanupOnShutdown();
|
void CleanupOnShutdown();
|
||||||
|
@ -33,12 +31,10 @@ namespace {
|
||||||
atexit(CleanupOnShutdown);
|
atexit(CleanupOnShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupOnShutdown() {
|
void CleanupOnShutdown() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<AudioSystem> xe::apu::nop::Create(Emulator* emulator) {
|
||||||
AudioSystem* xe::apu::nop::Create(Emulator* emulator) {
|
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new NopAudioSystem(emulator);
|
return std::make_unique<NopAudioSystem>(emulator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_APU_NOP_NOP_APU_H_
|
#ifndef XENIA_APU_NOP_NOP_APU_H_
|
||||||
#define XENIA_APU_NOP_NOP_APU_H_
|
#define XENIA_APU_NOP_NOP_APU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -21,7 +23,7 @@ namespace apu {
|
||||||
class AudioSystem;
|
class AudioSystem;
|
||||||
namespace nop {
|
namespace nop {
|
||||||
|
|
||||||
AudioSystem* Create(Emulator* emulator);
|
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
} // namespace nop
|
} // namespace nop
|
||||||
} // namespace apu
|
} // namespace apu
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
#include <xenia/apu/xaudio2/xaudio2_audio_system.h>
|
#include <xenia/apu/xaudio2/xaudio2_audio_system.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::apu;
|
using namespace xe::apu;
|
||||||
using namespace xe::apu::xaudio2;
|
using namespace xe::apu::xaudio2;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void InitializeIfNeeded();
|
void InitializeIfNeeded();
|
||||||
void CleanupOnShutdown();
|
void CleanupOnShutdown();
|
||||||
|
@ -33,12 +31,10 @@ namespace {
|
||||||
atexit(CleanupOnShutdown);
|
atexit(CleanupOnShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupOnShutdown() {
|
void CleanupOnShutdown() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<AudioSystem> xe::apu::xaudio2::Create(Emulator* emulator) {
|
||||||
AudioSystem* xe::apu::xaudio2::Create(Emulator* emulator) {
|
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new XAudio2AudioSystem(emulator);
|
return std::make_unique<XAudio2AudioSystem>(emulator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,23 @@
|
||||||
#ifndef XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
#ifndef XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||||
#define XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
#define XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
XEDECLARECLASS1(xe, Emulator);
|
class Emulator;
|
||||||
XEDECLARECLASS2(xe, apu, AudioSystem);
|
} // namespace xe
|
||||||
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace apu {
|
namespace apu {
|
||||||
|
class AudioSystem;
|
||||||
namespace xaudio2 {
|
namespace xaudio2 {
|
||||||
|
|
||||||
|
std::unique_ptr<AudioSystem> Create(Emulator* emulator);
|
||||||
AudioSystem* Create(Emulator* emulator);
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace xaudio2
|
} // namespace xaudio2
|
||||||
} // namespace apu
|
} // namespace apu
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
|
|
||||||
#endif // XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
#endif // XENIA_APU_XAUDIO2_XAUDIO2_APU_H_
|
||||||
|
|
|
@ -18,6 +18,5 @@
|
||||||
|
|
||||||
#include <xenia/logging.h>
|
#include <xenia/logging.h>
|
||||||
#include <xenia/profiling.h>
|
#include <xenia/profiling.h>
|
||||||
#include <xenia/types.h>
|
|
||||||
|
|
||||||
#endif // XENIA_COMMON_H_
|
#endif // XENIA_COMMON_H_
|
||||||
|
|
|
@ -17,4 +17,15 @@
|
||||||
#include <xenia/core/socket.h>
|
#include <xenia/core/socket.h>
|
||||||
#include <xenia/memory.h>
|
#include <xenia/memory.h>
|
||||||
|
|
||||||
|
// TODO(benvanik): remove.
|
||||||
|
#define XEFAIL() goto XECLEANUP
|
||||||
|
#define XEEXPECTZERO(expr) \
|
||||||
|
if ((expr) != 0) { \
|
||||||
|
goto XECLEANUP; \
|
||||||
|
}
|
||||||
|
#define XEEXPECTNOTNULL(expr) \
|
||||||
|
if ((expr) == NULL) { \
|
||||||
|
goto XECLEANUP; \
|
||||||
|
}
|
||||||
|
|
||||||
#endif // XENIA_CORE_H_
|
#endif // XENIA_CORE_H_
|
||||||
|
|
|
@ -33,18 +33,7 @@ using namespace xe::kernel::fs;
|
||||||
using namespace xe::ui;
|
using namespace xe::ui;
|
||||||
|
|
||||||
Emulator::Emulator(const std::wstring& command_line)
|
Emulator::Emulator(const std::wstring& command_line)
|
||||||
: command_line_(command_line),
|
: command_line_(command_line) {}
|
||||||
main_window_(0),
|
|
||||||
memory_(0),
|
|
||||||
processor_(0),
|
|
||||||
audio_system_(0),
|
|
||||||
graphics_system_(0),
|
|
||||||
input_system_(0),
|
|
||||||
export_resolver_(0),
|
|
||||||
file_system_(0),
|
|
||||||
kernel_state_(0),
|
|
||||||
xam_(0),
|
|
||||||
xboxkrnl_(0) {}
|
|
||||||
|
|
||||||
Emulator::~Emulator() {
|
Emulator::~Emulator() {
|
||||||
// Note that we delete things in the reverse order they were initialized.
|
// Note that we delete things in the reverse order they were initialized.
|
||||||
|
@ -60,23 +49,23 @@ Emulator::~Emulator() {
|
||||||
|
|
||||||
debug_agent_.reset();
|
debug_agent_.reset();
|
||||||
|
|
||||||
delete xam_;
|
xam_.reset();
|
||||||
delete xboxkrnl_;
|
xboxkrnl_.reset();
|
||||||
delete kernel_state_;
|
kernel_state_.reset();
|
||||||
|
|
||||||
delete file_system_;
|
file_system_.reset();
|
||||||
|
|
||||||
delete input_system_;
|
input_system_.reset();
|
||||||
|
|
||||||
// Give the systems time to shutdown before we delete them.
|
// Give the systems time to shutdown before we delete them.
|
||||||
graphics_system_->Shutdown();
|
graphics_system_->Shutdown();
|
||||||
audio_system_->Shutdown();
|
audio_system_->Shutdown();
|
||||||
delete graphics_system_;
|
graphics_system_.reset();
|
||||||
delete audio_system_;
|
audio_system_.reset();
|
||||||
|
|
||||||
delete processor_;
|
processor_.reset();
|
||||||
|
|
||||||
delete export_resolver_;
|
export_resolver_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS Emulator::Setup() {
|
X_STATUS Emulator::Setup() {
|
||||||
|
@ -84,63 +73,71 @@ X_STATUS Emulator::Setup() {
|
||||||
|
|
||||||
debug_agent_.reset(new DebugAgent(this));
|
debug_agent_.reset(new DebugAgent(this));
|
||||||
result = debug_agent_->Initialize();
|
result = debug_agent_->Initialize();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Create memory system first, as it is required for other systems.
|
// Create memory system first, as it is required for other systems.
|
||||||
memory_ = new Memory();
|
memory_ = std::make_unique<Memory>();
|
||||||
XEEXPECTNOTNULL(memory_);
|
|
||||||
result = memory_->Initialize();
|
result = memory_->Initialize();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
memory_->set_trace_base(debug_agent_->trace_base());
|
memory_->set_trace_base(debug_agent_->trace_base());
|
||||||
|
|
||||||
// Shared export resolver used to attach and query for HLE exports.
|
// Shared export resolver used to attach and query for HLE exports.
|
||||||
export_resolver_ = new ExportResolver();
|
export_resolver_ = std::make_unique<ExportResolver>();
|
||||||
XEEXPECTNOTNULL(export_resolver_);
|
|
||||||
|
|
||||||
// Initialize the CPU.
|
// Initialize the CPU.
|
||||||
processor_ = new Processor(this);
|
processor_ = std::make_unique<Processor>(this);
|
||||||
XEEXPECTNOTNULL(processor_);
|
|
||||||
|
|
||||||
// Initialize the APU.
|
// Initialize the APU.
|
||||||
audio_system_ = xe::apu::Create(this);
|
audio_system_ = std::move(xe::apu::Create(this));
|
||||||
XEEXPECTNOTNULL(audio_system_);
|
if (!audio_system_) {
|
||||||
|
return X_STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the GPU.
|
// Initialize the GPU.
|
||||||
graphics_system_ = xe::gpu::Create(this);
|
graphics_system_ = std::move(xe::gpu::Create(this));
|
||||||
XEEXPECTNOTNULL(graphics_system_);
|
if (!graphics_system_) {
|
||||||
|
return X_STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the HID.
|
// Initialize the HID.
|
||||||
input_system_ = xe::hid::Create(this);
|
input_system_ = std::move(xe::hid::Create(this));
|
||||||
XEEXPECTNOTNULL(input_system_);
|
if (!input_system_) {
|
||||||
|
return X_STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the core components.
|
// Setup the core components.
|
||||||
result = processor_->Setup();
|
result = processor_->Setup();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
result = audio_system_->Setup();
|
result = audio_system_->Setup();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
result = graphics_system_->Setup();
|
result = graphics_system_->Setup();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
result = input_system_->Setup();
|
result = input_system_->Setup();
|
||||||
XEEXPECTZERO(result);
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Bring up the virtual filesystem used by the kernel.
|
// Bring up the virtual filesystem used by the kernel.
|
||||||
file_system_ = new FileSystem();
|
file_system_ = std::make_unique<FileSystem>();
|
||||||
XEEXPECTNOTNULL(file_system_);
|
|
||||||
|
|
||||||
// Shared kernel state.
|
// Shared kernel state.
|
||||||
kernel_state_ = new KernelState(this);
|
kernel_state_ = std::make_unique<KernelState>(this);
|
||||||
XEEXPECTNOTNULL(kernel_state_);
|
|
||||||
|
|
||||||
// HLE kernel modules.
|
// HLE kernel modules.
|
||||||
xboxkrnl_ = new XboxkrnlModule(this, kernel_state_);
|
xboxkrnl_ = std::make_unique<XboxkrnlModule>(this, kernel_state_);
|
||||||
XEEXPECTNOTNULL(xboxkrnl_);
|
xam_ = std::make_unique<XamModule>(this, kernel_state_);
|
||||||
xam_ = new XamModule(this, kernel_state_);
|
|
||||||
XEEXPECTNOTNULL(xam_);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
XECLEANUP:
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::set_main_window(Window* window) {
|
void Emulator::set_main_window(Window* window) {
|
||||||
|
|
|
@ -54,20 +54,22 @@ class Emulator {
|
||||||
ui::Window* main_window() const { return main_window_; }
|
ui::Window* main_window() const { return main_window_; }
|
||||||
void set_main_window(ui::Window* window);
|
void set_main_window(ui::Window* window);
|
||||||
|
|
||||||
Memory* memory() const { return memory_; }
|
Memory* memory() const { return memory_.get(); }
|
||||||
|
|
||||||
DebugAgent* debug_agent() const { return debug_agent_.get(); }
|
DebugAgent* debug_agent() const { return debug_agent_.get(); }
|
||||||
|
|
||||||
cpu::Processor* processor() const { return processor_; }
|
cpu::Processor* processor() const { return processor_.get(); }
|
||||||
apu::AudioSystem* audio_system() const { return audio_system_; }
|
apu::AudioSystem* audio_system() const { return audio_system_.get(); }
|
||||||
gpu::GraphicsSystem* graphics_system() const { return graphics_system_; }
|
gpu::GraphicsSystem* graphics_system() const {
|
||||||
hid::InputSystem* input_system() const { return input_system_; }
|
return graphics_system_.get();
|
||||||
|
}
|
||||||
|
hid::InputSystem* input_system() const { return input_system_.get(); }
|
||||||
|
|
||||||
ExportResolver* export_resolver() const { return export_resolver_; }
|
ExportResolver* export_resolver() const { return export_resolver_.get(); }
|
||||||
kernel::fs::FileSystem* file_system() const { return file_system_; }
|
kernel::fs::FileSystem* file_system() const { return file_system_.get(); }
|
||||||
|
|
||||||
kernel::XboxkrnlModule* xboxkrnl() const { return xboxkrnl_; }
|
kernel::XboxkrnlModule* xboxkrnl() const { return xboxkrnl_.get(); }
|
||||||
kernel::XamModule* xam() const { return xam_; }
|
kernel::XamModule* xam() const { return xam_.get(); }
|
||||||
|
|
||||||
X_STATUS Setup();
|
X_STATUS Setup();
|
||||||
|
|
||||||
|
@ -82,23 +84,24 @@ class Emulator {
|
||||||
|
|
||||||
std::wstring command_line_;
|
std::wstring command_line_;
|
||||||
|
|
||||||
|
// TODO(benvanik): remove from here?
|
||||||
ui::Window* main_window_;
|
ui::Window* main_window_;
|
||||||
|
|
||||||
Memory* memory_;
|
std::unique_ptr<Memory> memory_;
|
||||||
|
|
||||||
std::unique_ptr<DebugAgent> debug_agent_;
|
std::unique_ptr<DebugAgent> debug_agent_;
|
||||||
|
|
||||||
cpu::Processor* processor_;
|
std::unique_ptr<cpu::Processor> processor_;
|
||||||
apu::AudioSystem* audio_system_;
|
std::unique_ptr<apu::AudioSystem> audio_system_;
|
||||||
gpu::GraphicsSystem* graphics_system_;
|
std::unique_ptr<gpu::GraphicsSystem> graphics_system_;
|
||||||
hid::InputSystem* input_system_;
|
std::unique_ptr<hid::InputSystem> input_system_;
|
||||||
|
|
||||||
ExportResolver* export_resolver_;
|
std::unique_ptr<ExportResolver> export_resolver_;
|
||||||
kernel::fs::FileSystem* file_system_;
|
std::unique_ptr<kernel::fs::FileSystem> file_system_;
|
||||||
|
|
||||||
kernel::KernelState* kernel_state_;
|
std::unique_ptr<kernel::KernelState> kernel_state_;
|
||||||
kernel::XamModule* xam_;
|
std::unique_ptr<kernel::XamModule> xam_;
|
||||||
kernel::XboxkrnlModule* xboxkrnl_;
|
std::unique_ptr<kernel::XboxkrnlModule> xboxkrnl_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
#include <xenia/gpu/d3d11/d3d11_graphics_system.h>
|
#include <xenia/gpu/d3d11/d3d11_graphics_system.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::gpu;
|
using namespace xe::gpu;
|
||||||
using namespace xe::gpu::d3d11;
|
using namespace xe::gpu::d3d11;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void InitializeIfNeeded();
|
void InitializeIfNeeded();
|
||||||
void CleanupOnShutdown();
|
void CleanupOnShutdown();
|
||||||
|
@ -33,12 +31,10 @@ namespace {
|
||||||
atexit(CleanupOnShutdown);
|
atexit(CleanupOnShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupOnShutdown() {
|
void CleanupOnShutdown() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GraphicsSystem> xe::gpu::d3d11::Create(Emulator* emulator) {
|
||||||
GraphicsSystem* xe::gpu::d3d11::Create(Emulator* emulator) {
|
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new D3D11GraphicsSystem(emulator);
|
return std::make_unique<D3D11GraphicsSystem>(emulator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,24 +10,23 @@
|
||||||
#ifndef XENIA_GPU_D3D11_D3D11_GPU_H_
|
#ifndef XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||||
#define XENIA_GPU_D3D11_D3D11_GPU_H_
|
#define XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
|
||||||
|
namespace xe {
|
||||||
XEDECLARECLASS1(xe, Emulator);
|
class Emulator;
|
||||||
XEDECLARECLASS2(xe, gpu, GraphicsSystem);
|
} // namespace xe
|
||||||
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
class GraphicsSystem;
|
||||||
namespace d3d11 {
|
namespace d3d11 {
|
||||||
|
|
||||||
|
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||||
GraphicsSystem* Create(Emulator* emulator);
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace d3d11
|
} // namespace d3d11
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
||||||
|
|
||||||
#endif // XENIA_GPU_D3D11_D3D11_GPU_H_
|
#endif // XENIA_GPU_D3D11_D3D11_GPU_H_
|
||||||
|
|
|
@ -10,37 +10,28 @@
|
||||||
#include <xenia/gpu/gpu.h>
|
#include <xenia/gpu/gpu.h>
|
||||||
#include <xenia/gpu/gpu-private.h>
|
#include <xenia/gpu/gpu-private.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::gpu;
|
using namespace xe::gpu;
|
||||||
|
|
||||||
|
DEFINE_string(gpu, "any", "Graphics system. Use: [any, nop, d3d11]");
|
||||||
|
|
||||||
DEFINE_string(gpu, "any",
|
DEFINE_bool(trace_ring_buffer, false, "Trace GPU ring buffer packets.");
|
||||||
"Graphics system. Use: [any, nop, d3d11]");
|
|
||||||
|
|
||||||
|
|
||||||
DEFINE_bool(trace_ring_buffer, false,
|
|
||||||
"Trace GPU ring buffer packets.");
|
|
||||||
DEFINE_string(dump_shaders, "",
|
DEFINE_string(dump_shaders, "",
|
||||||
"Path to write GPU shaders to as they are compiled.");
|
"Path to write GPU shaders to as they are compiled.");
|
||||||
|
|
||||||
|
|
||||||
#include <xenia/gpu/nop/nop_gpu.h>
|
#include <xenia/gpu/nop/nop_gpu.h>
|
||||||
GraphicsSystem* xe::gpu::CreateNop(Emulator* emulator) {
|
std::unique_ptr<GraphicsSystem> xe::gpu::CreateNop(Emulator* emulator) {
|
||||||
return xe::gpu::nop::Create(emulator);
|
return xe::gpu::nop::Create(emulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
#include <xenia/gpu/d3d11/d3d11_gpu.h>
|
#include <xenia/gpu/d3d11/d3d11_gpu.h>
|
||||||
GraphicsSystem* xe::gpu::CreateD3D11(Emulator* emulator) {
|
std::unique_ptr<GraphicsSystem> xe::gpu::CreateD3D11(Emulator* emulator) {
|
||||||
return xe::gpu::d3d11::Create(emulator);
|
return xe::gpu::d3d11::Create(emulator);
|
||||||
}
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
std::unique_ptr<GraphicsSystem> xe::gpu::Create(Emulator* emulator) {
|
||||||
GraphicsSystem* xe::gpu::Create(Emulator* emulator) {
|
|
||||||
if (FLAGS_gpu.compare("nop") == 0) {
|
if (FLAGS_gpu.compare("nop") == 0) {
|
||||||
return CreateNop(emulator);
|
return CreateNop(emulator);
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
|
@ -49,7 +40,7 @@ GraphicsSystem* xe::gpu::Create(Emulator* emulator) {
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
} else {
|
} else {
|
||||||
// Create best available.
|
// Create best available.
|
||||||
GraphicsSystem* best = NULL;
|
std::unique_ptr<GraphicsSystem> best;
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
best = CreateD3D11(emulator);
|
best = CreateD3D11(emulator);
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_GPU_GPU_H_
|
#ifndef XENIA_GPU_GPU_H_
|
||||||
#define XENIA_GPU_GPU_H_
|
#define XENIA_GPU_GPU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/gpu/graphics_system.h>
|
#include <xenia/gpu/graphics_system.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -19,12 +21,12 @@ class Emulator;
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace gpu {
|
namespace gpu {
|
||||||
|
|
||||||
GraphicsSystem* Create(Emulator* emulator);
|
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
GraphicsSystem* CreateNop(Emulator* emulator);
|
std::unique_ptr<GraphicsSystem> CreateNop(Emulator* emulator);
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
GraphicsSystem* CreateD3D11(Emulator* emulator);
|
std::unique_ptr<GraphicsSystem> CreateD3D11(Emulator* emulator);
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
|
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
#include <xenia/gpu/nop/nop_graphics_system.h>
|
#include <xenia/gpu/nop/nop_graphics_system.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::gpu;
|
using namespace xe::gpu;
|
||||||
using namespace xe::gpu::nop;
|
using namespace xe::gpu::nop;
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void InitializeIfNeeded();
|
void InitializeIfNeeded();
|
||||||
void CleanupOnShutdown();
|
void CleanupOnShutdown();
|
||||||
|
@ -33,12 +31,10 @@ namespace {
|
||||||
atexit(CleanupOnShutdown);
|
atexit(CleanupOnShutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CleanupOnShutdown() {
|
void CleanupOnShutdown() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GraphicsSystem> xe::gpu::nop::Create(Emulator* emulator) {
|
||||||
GraphicsSystem* xe::gpu::nop::Create(Emulator* emulator) {
|
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new NopGraphicsSystem(emulator);
|
return std::make_unique<NopGraphicsSystem>(emulator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_GPU_NOP_NOP_GPU_H_
|
#ifndef XENIA_GPU_NOP_NOP_GPU_H_
|
||||||
#define XENIA_GPU_NOP_NOP_GPU_H_
|
#define XENIA_GPU_NOP_NOP_GPU_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -21,7 +23,7 @@ namespace gpu {
|
||||||
class GraphicsSystem;
|
class GraphicsSystem;
|
||||||
namespace nop {
|
namespace nop {
|
||||||
|
|
||||||
GraphicsSystem* Create(Emulator* emulator);
|
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
} // namespace nop
|
} // namespace nop
|
||||||
} // namespace gpu
|
} // namespace gpu
|
||||||
|
|
|
@ -10,15 +10,10 @@
|
||||||
#include <xenia/hid/hid.h>
|
#include <xenia/hid/hid.h>
|
||||||
#include <xenia/hid/hid-private.h>
|
#include <xenia/hid/hid-private.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace xe;
|
using namespace xe;
|
||||||
using namespace xe::hid;
|
using namespace xe::hid;
|
||||||
|
|
||||||
|
DEFINE_string(hid, "any", "Input system. Use: [any, nop, winkey, xinput]");
|
||||||
DEFINE_string(hid, "any",
|
|
||||||
"Input system. Use: [any, nop, winkey, xinput]");
|
|
||||||
|
|
||||||
|
|
||||||
#include <xenia/hid/nop/nop_hid.h>
|
#include <xenia/hid/nop/nop_hid.h>
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
|
@ -26,18 +21,17 @@ DEFINE_string(hid, "any",
|
||||||
#include <xenia/hid/xinput/xinput_hid.h>
|
#include <xenia/hid/xinput/xinput_hid.h>
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
|
std::unique_ptr<InputSystem> xe::hid::Create(Emulator* emulator) {
|
||||||
InputSystem* xe::hid::Create(Emulator* emulator) {
|
std::unique_ptr<InputSystem> input_system =
|
||||||
//return xe::hid::nop::Create(emulator);
|
std::make_unique<InputSystem>(emulator);
|
||||||
InputSystem* input_system = new InputSystem(emulator);
|
|
||||||
|
|
||||||
if (FLAGS_hid.compare("nop") == 0) {
|
if (FLAGS_hid.compare("nop") == 0) {
|
||||||
input_system->AddDriver(xe::hid::nop::Create(input_system));
|
input_system->AddDriver(xe::hid::nop::Create(input_system.get()));
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
} else if (FLAGS_hid.compare("winkey") == 0) {
|
} else if (FLAGS_hid.compare("winkey") == 0) {
|
||||||
input_system->AddDriver(xe::hid::winkey::Create(input_system));
|
input_system->AddDriver(xe::hid::winkey::Create(input_system.get()));
|
||||||
} else if (FLAGS_hid.compare("xinput") == 0) {
|
} else if (FLAGS_hid.compare("xinput") == 0) {
|
||||||
input_system->AddDriver(xe::hid::xinput::Create(input_system));
|
input_system->AddDriver(xe::hid::xinput::Create(input_system.get()));
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
} else {
|
} else {
|
||||||
// Create all available.
|
// Create all available.
|
||||||
|
@ -46,21 +40,21 @@ InputSystem* xe::hid::Create(Emulator* emulator) {
|
||||||
// NOTE: in any mode we create as many as we can, falling back to nop.
|
// NOTE: in any mode we create as many as we can, falling back to nop.
|
||||||
|
|
||||||
#if XE_PLATFORM_WIN32
|
#if XE_PLATFORM_WIN32
|
||||||
InputDriver* xinput_driver = xe::hid::xinput::Create(input_system);
|
auto xinput_driver = xe::hid::xinput::Create(input_system.get());
|
||||||
if (xinput_driver) {
|
if (xinput_driver) {
|
||||||
input_system->AddDriver(xinput_driver);
|
input_system->AddDriver(std::move(xinput_driver));
|
||||||
any_created = true;
|
any_created = true;
|
||||||
}
|
}
|
||||||
InputDriver* winkey_driver = xe::hid::winkey::Create(input_system);
|
auto winkey_driver = xe::hid::winkey::Create(input_system.get());
|
||||||
if (winkey_driver) {
|
if (winkey_driver) {
|
||||||
input_system->AddDriver(winkey_driver);
|
input_system->AddDriver(std::move(winkey_driver));
|
||||||
any_created = true;
|
any_created = true;
|
||||||
}
|
}
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
||||||
// Fallback to nop if none created.
|
// Fallback to nop if none created.
|
||||||
if (!any_created) {
|
if (!any_created) {
|
||||||
input_system->AddDriver(xe::hid::nop::Create(input_system));
|
input_system->AddDriver(xe::hid::nop::Create(input_system.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_HID_HID_H_
|
#ifndef XENIA_HID_HID_H_
|
||||||
#define XENIA_HID_HID_H_
|
#define XENIA_HID_HID_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/hid/input_system.h>
|
#include <xenia/hid/input_system.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -19,7 +21,7 @@ class Emulator;
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace hid {
|
namespace hid {
|
||||||
|
|
||||||
InputSystem* Create(Emulator* emulator);
|
std::unique_ptr<InputSystem> Create(Emulator* emulator);
|
||||||
|
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -32,9 +32,9 @@ void InitializeIfNeeded() {
|
||||||
|
|
||||||
void CleanupOnShutdown() {}
|
void CleanupOnShutdown() {}
|
||||||
|
|
||||||
InputDriver* xe::hid::nop::Create(InputSystem* input_system) {
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system) {
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new NopInputDriver(input_system);
|
return std::make_unique<NopInputDriver>(input_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nop
|
} // namespace nop
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef XENIA_HID_NOP_NOP_HID_H_
|
#ifndef XENIA_HID_NOP_NOP_HID_H_
|
||||||
#define XENIA_HID_NOP_NOP_HID_H_
|
#define XENIA_HID_NOP_NOP_HID_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
|
@ -18,7 +20,7 @@ class InputDriver;
|
||||||
class InputSystem;
|
class InputSystem;
|
||||||
namespace nop {
|
namespace nop {
|
||||||
|
|
||||||
InputDriver* Create(InputSystem* input_system);
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system);
|
||||||
|
|
||||||
} // namespace nop
|
} // namespace nop
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
|
|
|
@ -32,9 +32,9 @@ void InitializeIfNeeded() {
|
||||||
|
|
||||||
void CleanupOnShutdown() {}
|
void CleanupOnShutdown() {}
|
||||||
|
|
||||||
InputDriver* xe::hid::winkey::Create(InputSystem* input_system) {
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system) {
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new WinKeyInputDriver(input_system);
|
return std::make_unique<WinKeyInputDriver>(input_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace winkey
|
} // namespace winkey
|
||||||
|
|
|
@ -10,16 +10,17 @@
|
||||||
#ifndef XENIA_HID_WINKEY_WINKEY_HID_H_
|
#ifndef XENIA_HID_WINKEY_WINKEY_HID_H_
|
||||||
#define XENIA_HID_WINKEY_WINKEY_HID_H_
|
#define XENIA_HID_WINKEY_WINKEY_HID_H_
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <memory>
|
||||||
|
|
||||||
XEDECLARECLASS2(xe, hid, InputDriver);
|
#include <xenia/core.h>
|
||||||
XEDECLARECLASS2(xe, hid, InputSystem);
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace hid {
|
namespace hid {
|
||||||
|
class InputDriver;
|
||||||
|
class InputSystem;
|
||||||
namespace winkey {
|
namespace winkey {
|
||||||
|
|
||||||
InputDriver* Create(InputSystem* input_system);
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system);
|
||||||
|
|
||||||
} // namespace winkey
|
} // namespace winkey
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
|
|
|
@ -32,9 +32,9 @@ void InitializeIfNeeded() {
|
||||||
|
|
||||||
void CleanupOnShutdown() {}
|
void CleanupOnShutdown() {}
|
||||||
|
|
||||||
InputDriver* xe::hid::xinput::Create(InputSystem* input_system) {
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system) {
|
||||||
InitializeIfNeeded();
|
InitializeIfNeeded();
|
||||||
return new XInputInputDriver(input_system);
|
return std::make_unique<XInputInputDriver>(input_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace xinput
|
} // namespace xinput
|
||||||
|
|
|
@ -10,16 +10,17 @@
|
||||||
#ifndef XENIA_HID_XINPUT_XINPUT_HID_H_
|
#ifndef XENIA_HID_XINPUT_XINPUT_HID_H_
|
||||||
#define XENIA_HID_XINPUT_XINPUT_HID_H_
|
#define XENIA_HID_XINPUT_XINPUT_HID_H_
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <memory>
|
||||||
|
|
||||||
XEDECLARECLASS2(xe, hid, InputDriver);
|
#include <xenia/core.h>
|
||||||
XEDECLARECLASS2(xe, hid, InputSystem);
|
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace hid {
|
namespace hid {
|
||||||
|
class InputDriver;
|
||||||
|
class InputSystem;
|
||||||
namespace xinput {
|
namespace xinput {
|
||||||
|
|
||||||
InputDriver* Create(InputSystem* input_system);
|
std::unique_ptr<InputDriver> Create(InputSystem* input_system);
|
||||||
|
|
||||||
} // namespace xinput
|
} // namespace xinput
|
||||||
} // namespace hid
|
} // namespace hid
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#ifndef XENIA_KERNEL_FS_DEVICE_H_
|
#ifndef XENIA_KERNEL_FS_DEVICE_H_
|
||||||
#define XENIA_KERNEL_FS_DEVICE_H_
|
#define XENIA_KERNEL_FS_DEVICE_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
@ -26,7 +27,7 @@ class Device {
|
||||||
|
|
||||||
const std::string& path() const { return path_; }
|
const std::string& path() const { return path_; }
|
||||||
|
|
||||||
virtual Entry* ResolvePath(const char* path) = 0;
|
virtual std::unique_ptr<Entry> ResolvePath(const char* path) = 0;
|
||||||
|
|
||||||
virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0;
|
virtual X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) = 0;
|
||||||
virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
virtual X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||||
|
|
|
@ -42,7 +42,7 @@ int DiscImageDevice::Init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* DiscImageDevice::ResolvePath(const char* path) {
|
std::unique_ptr<Entry> DiscImageDevice::ResolvePath(const char* path) {
|
||||||
// The filesystem will have stripped our prefix off already, so the path will
|
// The filesystem will have stripped our prefix off already, so the path will
|
||||||
// be in the form:
|
// be in the form:
|
||||||
// some\PATH.foo
|
// some\PATH.foo
|
||||||
|
@ -64,7 +64,8 @@ Entry* DiscImageDevice::ResolvePath(const char* path) {
|
||||||
Entry::Type type = gdfx_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY
|
Entry::Type type = gdfx_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY
|
||||||
? Entry::Type::DIRECTORY
|
? Entry::Type::DIRECTORY
|
||||||
: Entry::Type::FILE;
|
: Entry::Type::FILE;
|
||||||
return new DiscImageEntry(type, this, path, mmap_.get(), gdfx_entry);
|
return std::make_unique<DiscImageEntry>(type, this, path, mmap_.get(),
|
||||||
|
gdfx_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS DiscImageDevice::QueryVolume(XVolumeInfo* out_info, size_t length) {
|
X_STATUS DiscImageDevice::QueryVolume(XVolumeInfo* out_info, size_t length) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ class DiscImageDevice : public Device {
|
||||||
|
|
||||||
int Init();
|
int Init();
|
||||||
|
|
||||||
Entry* ResolvePath(const char* path) override;
|
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||||
|
|
||||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||||
|
|
|
@ -96,23 +96,22 @@ X_STATUS DiscImageEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length,
|
||||||
return X_STATUS_SUCCESS;
|
return X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryMapping* DiscImageEntry::CreateMemoryMapping(Mode map_mode,
|
std::unique_ptr<MemoryMapping> DiscImageEntry::CreateMemoryMapping(
|
||||||
const size_t offset,
|
Mode map_mode, const size_t offset, const size_t length) {
|
||||||
const size_t length) {
|
|
||||||
if (map_mode != Mode::READ) {
|
if (map_mode != Mode::READ) {
|
||||||
// Only allow reads.
|
// Only allow reads.
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t real_offset = gdfx_entry_->offset + offset;
|
size_t real_offset = gdfx_entry_->offset + offset;
|
||||||
size_t real_length =
|
size_t real_length =
|
||||||
length ? std::min(length, gdfx_entry_->size) : gdfx_entry_->size;
|
length ? std::min(length, gdfx_entry_->size) : gdfx_entry_->size;
|
||||||
return new DiscImageMemoryMapping(mmap_->data() + real_offset, real_length,
|
return std::make_unique<DiscImageMemoryMapping>(mmap_->data() + real_offset,
|
||||||
mmap_);
|
real_length, mmap_);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS DiscImageEntry::Open(KernelState* kernel_state, Mode mode,
|
X_STATUS DiscImageEntry::Open(KernelState* kernel_state, Mode mode, bool async,
|
||||||
bool async, XFile** out_file) {
|
XFile** out_file) {
|
||||||
*out_file = new DiscImageFile(kernel_state, mode, this);
|
*out_file = new DiscImageFile(kernel_state, mode, this);
|
||||||
return X_STATUS_SUCCESS;
|
return X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@ class DiscImageEntry : public Entry {
|
||||||
const char* file_name, bool restart);
|
const char* file_name, bool restart);
|
||||||
|
|
||||||
virtual bool can_map() { return true; }
|
virtual bool can_map() { return true; }
|
||||||
virtual MemoryMapping* CreateMemoryMapping(Mode map_mode, const size_t offset,
|
virtual std::unique_ptr<MemoryMapping> CreateMemoryMapping(
|
||||||
const size_t length);
|
Mode map_mode, const size_t offset, const size_t length);
|
||||||
|
|
||||||
virtual X_STATUS Open(KernelState* kernel_state, Mode mode,
|
virtual X_STATUS Open(KernelState* kernel_state, Mode mode, bool async,
|
||||||
bool async, XFile** out_file);
|
XFile** out_file);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
poly::MappedMemory* mmap_;
|
poly::MappedMemory* mmap_;
|
||||||
|
|
|
@ -22,7 +22,7 @@ HostPathDevice::HostPathDevice(const std::string& path,
|
||||||
|
|
||||||
HostPathDevice::~HostPathDevice() {}
|
HostPathDevice::~HostPathDevice() {}
|
||||||
|
|
||||||
Entry* HostPathDevice::ResolvePath(const char* path) {
|
std::unique_ptr<Entry> HostPathDevice::ResolvePath(const char* path) {
|
||||||
// The filesystem will have stripped our prefix off already, so the path will
|
// The filesystem will have stripped our prefix off already, so the path will
|
||||||
// be in the form:
|
// be in the form:
|
||||||
// some\PATH.foo
|
// some\PATH.foo
|
||||||
|
@ -38,8 +38,7 @@ Entry* HostPathDevice::ResolvePath(const char* path) {
|
||||||
// TODO(benvanik): switch based on type
|
// TODO(benvanik): switch based on type
|
||||||
|
|
||||||
auto type = Entry::Type::FILE;
|
auto type = Entry::Type::FILE;
|
||||||
HostPathEntry* entry = new HostPathEntry(type, this, path, full_path);
|
return std::make_unique<HostPathEntry>(type, this, path, full_path);
|
||||||
return entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(gibbed): call into HostPathDevice?
|
// TODO(gibbed): call into HostPathDevice?
|
||||||
|
|
|
@ -25,7 +25,7 @@ class HostPathDevice : public Device {
|
||||||
HostPathDevice(const std::string& path, const std::wstring& local_path);
|
HostPathDevice(const std::string& path, const std::wstring& local_path);
|
||||||
~HostPathDevice() override;
|
~HostPathDevice() override;
|
||||||
|
|
||||||
Entry* ResolvePath(const char* path) override;
|
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||||
|
|
||||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||||
|
|
|
@ -121,9 +121,8 @@ X_STATUS HostPathEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length,
|
||||||
return X_STATUS_SUCCESS;
|
return X_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryMapping* HostPathEntry::CreateMemoryMapping(Mode map_mode,
|
std::unique_ptr<MemoryMapping> HostPathEntry::CreateMemoryMapping(
|
||||||
const size_t offset,
|
Mode map_mode, const size_t offset, const size_t length) {
|
||||||
const size_t length) {
|
|
||||||
auto mmap = poly::MappedMemory::Open(
|
auto mmap = poly::MappedMemory::Open(
|
||||||
local_path_,
|
local_path_,
|
||||||
map_mode == Mode::READ ? poly::MappedMemory::Mode::READ
|
map_mode == Mode::READ ? poly::MappedMemory::Mode::READ
|
||||||
|
@ -133,13 +132,11 @@ MemoryMapping* HostPathEntry::CreateMemoryMapping(Mode map_mode,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
HostPathMemoryMapping* lfmm = new HostPathMemoryMapping(std::move(mmap));
|
return std::make_unique<HostPathMemoryMapping>(std::move(mmap));
|
||||||
|
|
||||||
return lfmm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS HostPathEntry::Open(KernelState* kernel_state, Mode mode,
|
X_STATUS HostPathEntry::Open(KernelState* kernel_state, Mode mode, bool async,
|
||||||
bool async, XFile** out_file) {
|
XFile** out_file) {
|
||||||
DWORD desired_access =
|
DWORD desired_access =
|
||||||
mode == Mode::READ ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
|
mode == Mode::READ ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE);
|
||||||
DWORD share_mode = FILE_SHARE_READ;
|
DWORD share_mode = FILE_SHARE_READ;
|
||||||
|
|
|
@ -31,8 +31,8 @@ class HostPathEntry : public Entry {
|
||||||
const char* file_name, bool restart);
|
const char* file_name, bool restart);
|
||||||
|
|
||||||
virtual bool can_map() { return true; }
|
virtual bool can_map() { return true; }
|
||||||
virtual MemoryMapping* CreateMemoryMapping(Mode map_mode, const size_t offset,
|
virtual std::unique_ptr<MemoryMapping> CreateMemoryMapping(
|
||||||
const size_t length);
|
Mode map_mode, const size_t offset, const size_t length);
|
||||||
|
|
||||||
virtual X_STATUS Open(KernelState* kernel_state, Mode mode, bool async,
|
virtual X_STATUS Open(KernelState* kernel_state, Mode mode, bool async,
|
||||||
XFile** out_file);
|
XFile** out_file);
|
||||||
|
|
|
@ -42,7 +42,7 @@ int STFSContainerDevice::Init() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* STFSContainerDevice::ResolvePath(const char* path) {
|
std::unique_ptr<Entry> STFSContainerDevice::ResolvePath(const char* path) {
|
||||||
// The filesystem will have stripped our prefix off already, so the path will
|
// The filesystem will have stripped our prefix off already, so the path will
|
||||||
// be in the form:
|
// be in the form:
|
||||||
// some\PATH.foo
|
// some\PATH.foo
|
||||||
|
@ -64,7 +64,8 @@ Entry* STFSContainerDevice::ResolvePath(const char* path) {
|
||||||
Entry::Type type = stfs_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY
|
Entry::Type type = stfs_entry->attributes & X_FILE_ATTRIBUTE_DIRECTORY
|
||||||
? Entry::Type::DIRECTORY
|
? Entry::Type::DIRECTORY
|
||||||
: Entry::Type::FILE;
|
: Entry::Type::FILE;
|
||||||
return new STFSContainerEntry(type, this, path, mmap_.get(), stfs_entry);
|
return std::make_unique<STFSContainerEntry>(type, this, path, mmap_.get(),
|
||||||
|
stfs_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_STATUS STFSContainerDevice::QueryVolume(XVolumeInfo* out_info,
|
X_STATUS STFSContainerDevice::QueryVolume(XVolumeInfo* out_info,
|
||||||
|
|
|
@ -31,7 +31,7 @@ class STFSContainerDevice : public Device {
|
||||||
|
|
||||||
int Init();
|
int Init();
|
||||||
|
|
||||||
Entry* ResolvePath(const char* path) override;
|
std::unique_ptr<Entry> ResolvePath(const char* path) override;
|
||||||
|
|
||||||
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
X_STATUS QueryVolume(XVolumeInfo* out_info, size_t length) override;
|
||||||
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
X_STATUS QueryFileSystemAttributes(XFileSystemAttributeInfo* out_info,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#ifndef XENIA_KERNEL_FS_ENTRY_H_
|
#ifndef XENIA_KERNEL_FS_ENTRY_H_
|
||||||
#define XENIA_KERNEL_FS_ENTRY_H_
|
#define XENIA_KERNEL_FS_ENTRY_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <xenia/core.h>
|
#include <xenia/core.h>
|
||||||
|
@ -72,8 +73,8 @@ class Entry {
|
||||||
|
|
||||||
virtual bool can_map() { return false; }
|
virtual bool can_map() { return false; }
|
||||||
|
|
||||||
virtual MemoryMapping* CreateMemoryMapping(Mode map_mode, const size_t offset,
|
virtual std::unique_ptr<MemoryMapping> CreateMemoryMapping(
|
||||||
const size_t length) {
|
Mode map_mode, const size_t offset, const size_t length) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ int FileSystem::DeleteSymbolicLink(const std::string& path) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry* FileSystem::ResolvePath(const std::string& path) {
|
std::unique_ptr<Entry> FileSystem::ResolvePath(const std::string& path) {
|
||||||
// Strip off prefix and pass to device.
|
// Strip off prefix and pass to device.
|
||||||
// e.g., d:\some\PATH.foo -> some\PATH.foo
|
// e.g., d:\some\PATH.foo -> some\PATH.foo
|
||||||
// Support both symlinks and device specifiers, like:
|
// Support both symlinks and device specifiers, like:
|
||||||
|
@ -173,7 +173,7 @@ Entry* FileSystem::ResolvePath(const std::string& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
XELOGE("ResolvePath(%s) failed - no root found", path.c_str());
|
XELOGE("ResolvePath(%s) failed - no root found", path.c_str());
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fs
|
} // namespace fs
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#ifndef XENIA_KERNEL_FS_FILESYSTEM_H_
|
#ifndef XENIA_KERNEL_FS_FILESYSTEM_H_
|
||||||
#define XENIA_KERNEL_FS_FILESYSTEM_H_
|
#define XENIA_KERNEL_FS_FILESYSTEM_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -50,7 +51,7 @@ class FileSystem {
|
||||||
int CreateSymbolicLink(const std::string& path, const std::string& target);
|
int CreateSymbolicLink(const std::string& path, const std::string& target);
|
||||||
int DeleteSymbolicLink(const std::string& path);
|
int DeleteSymbolicLink(const std::string& path);
|
||||||
|
|
||||||
Entry* ResolvePath(const std::string& path);
|
std::unique_ptr<Entry> ResolvePath(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Device*> devices_;
|
std::vector<Device*> devices_;
|
||||||
|
|
|
@ -33,41 +33,33 @@ const xe_xex2_header_t* XUserModule::xex_header() {
|
||||||
X_STATUS XUserModule::LoadFromFile(const char* path) {
|
X_STATUS XUserModule::LoadFromFile(const char* path) {
|
||||||
X_STATUS result = X_STATUS_UNSUCCESSFUL;
|
X_STATUS result = X_STATUS_UNSUCCESSFUL;
|
||||||
XFile* file = NULL;
|
XFile* file = NULL;
|
||||||
uint8_t* buffer = 0;
|
|
||||||
|
|
||||||
// Resolve the file to open.
|
// Resolve the file to open.
|
||||||
// TODO(benvanik): make this code shared?
|
// TODO(benvanik): make this code shared?
|
||||||
fs::Entry* fs_entry = kernel_state()->file_system()->ResolvePath(path);
|
auto fs_entry = kernel_state()->file_system()->ResolvePath(path);
|
||||||
if (!fs_entry) {
|
if (!fs_entry) {
|
||||||
XELOGE("File not found: %s", path);
|
XELOGE("File not found: %s", path);
|
||||||
result = X_STATUS_NO_SUCH_FILE;
|
return X_STATUS_NO_SUCH_FILE;
|
||||||
XEFAIL();
|
|
||||||
}
|
}
|
||||||
if (fs_entry->type() != fs::Entry::Type::FILE) {
|
if (fs_entry->type() != fs::Entry::Type::FILE) {
|
||||||
XELOGE("Invalid file type: %s", path);
|
XELOGE("Invalid file type: %s", path);
|
||||||
result = X_STATUS_NO_SUCH_FILE;
|
return X_STATUS_NO_SUCH_FILE;
|
||||||
XEFAIL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the FS supports mapping, map the file in and load from that.
|
// If the FS supports mapping, map the file in and load from that.
|
||||||
if (fs_entry->can_map()) {
|
if (fs_entry->can_map()) {
|
||||||
// Map.
|
// Map.
|
||||||
fs::MemoryMapping* mmap =
|
auto mmap = fs_entry->CreateMemoryMapping(fs::Mode::READ, 0, 0);
|
||||||
fs_entry->CreateMemoryMapping(fs::Mode::READ, 0, 0);
|
|
||||||
XEEXPECTNOTNULL(mmap);
|
XEEXPECTNOTNULL(mmap);
|
||||||
|
|
||||||
// Load the module.
|
// Load the module.
|
||||||
result = LoadFromMemory(mmap->address(), mmap->length());
|
result = LoadFromMemory(mmap->address(), mmap->length());
|
||||||
|
|
||||||
// Unmap memory and cleanup.
|
|
||||||
delete mmap;
|
|
||||||
} else {
|
} else {
|
||||||
XFileInfo file_info;
|
XFileInfo file_info;
|
||||||
result = fs_entry->QueryInfo(&file_info);
|
result = fs_entry->QueryInfo(&file_info);
|
||||||
XEEXPECTZERO(result);
|
XEEXPECTZERO(result);
|
||||||
|
|
||||||
size_t buffer_length = file_info.file_length;
|
std::vector<uint8_t> buffer(file_info.file_length);
|
||||||
buffer = (uint8_t*)malloc(buffer_length);
|
|
||||||
|
|
||||||
// Open file for reading.
|
// Open file for reading.
|
||||||
result = fs_entry->Open(kernel_state(), fs::Mode::READ, false, &file);
|
result = fs_entry->Open(kernel_state(), fs::Mode::READ, false, &file);
|
||||||
|
@ -76,21 +68,17 @@ X_STATUS XUserModule::LoadFromFile(const char* path) {
|
||||||
// Read entire file into memory.
|
// Read entire file into memory.
|
||||||
// Ugh.
|
// Ugh.
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
result = file->Read(buffer, buffer_length, 0, &bytes_read);
|
result = file->Read(buffer.data(), buffer.size(), 0, &bytes_read);
|
||||||
XEEXPECTZERO(result);
|
XEEXPECTZERO(result);
|
||||||
|
|
||||||
// Load the module.
|
// Load the module.
|
||||||
result = LoadFromMemory(buffer, bytes_read);
|
result = LoadFromMemory(buffer.data(), bytes_read);
|
||||||
}
|
}
|
||||||
|
|
||||||
XECLEANUP:
|
XECLEANUP:
|
||||||
if (buffer) {
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
if (file) {
|
if (file) {
|
||||||
file->Release();
|
file->Release();
|
||||||
}
|
}
|
||||||
delete fs_entry;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ SHIM_CALL NtCreateFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
|
||||||
FileSystem* fs = state->file_system();
|
FileSystem* fs = state->file_system();
|
||||||
Entry* entry;
|
std::unique_ptr<Entry> entry;
|
||||||
|
|
||||||
XFile* root_file = NULL;
|
XFile* root_file = NULL;
|
||||||
if (attrs.root_directory != 0xFFFFFFFD && // ObDosDevices
|
if (attrs.root_directory != 0xFFFFFFFD && // ObDosDevices
|
||||||
|
@ -93,10 +93,10 @@ SHIM_CALL NtCreateFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||||
|
|
||||||
auto root_path = root_file->absolute_path();
|
auto root_path = root_file->absolute_path();
|
||||||
auto target_path = root_path + object_name;
|
auto target_path = root_path + object_name;
|
||||||
entry = fs->ResolvePath(target_path);
|
entry = std::move(fs->ResolvePath(target_path));
|
||||||
} else {
|
} else {
|
||||||
// Resolve the file using the virtual file system.
|
// Resolve the file using the virtual file system.
|
||||||
entry = fs->ResolvePath(object_name);
|
entry = std::move(fs->ResolvePath(object_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mode =
|
auto mode =
|
||||||
|
@ -169,7 +169,7 @@ SHIM_CALL NtOpenFile_shim(PPCContext* ppc_state, KernelState* state) {
|
||||||
|
|
||||||
// Resolve the file using the virtual file system.
|
// Resolve the file using the virtual file system.
|
||||||
FileSystem* fs = state->file_system();
|
FileSystem* fs = state->file_system();
|
||||||
Entry* entry = fs->ResolvePath(object_name);
|
auto entry = fs->ResolvePath(object_name);
|
||||||
XFile* file = NULL;
|
XFile* file = NULL;
|
||||||
if (entry && entry->type() == Entry::Type::FILE) {
|
if (entry && entry->type() == Entry::Type::FILE) {
|
||||||
// Open the file.
|
// Open the file.
|
||||||
|
@ -480,7 +480,7 @@ SHIM_CALL NtQueryFullAttributesFile_shim(PPCContext* ppc_state,
|
||||||
|
|
||||||
// Resolve the file using the virtual file system.
|
// Resolve the file using the virtual file system.
|
||||||
FileSystem* fs = state->file_system();
|
FileSystem* fs = state->file_system();
|
||||||
Entry* entry = fs->ResolvePath(object_name);
|
auto entry = fs->ResolvePath(object_name);
|
||||||
if (entry && entry->type() == Entry::Type::FILE) {
|
if (entry && entry->type() == Entry::Type::FILE) {
|
||||||
// Found.
|
// Found.
|
||||||
XFileInfo file_info;
|
XFileInfo file_info;
|
||||||
|
|
|
@ -147,7 +147,6 @@ int Memory::Initialize() {
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = 1;
|
|
||||||
|
|
||||||
// Create main page file-backed mapping. This is all reserved but
|
// Create main page file-backed mapping. This is all reserved but
|
||||||
// uncommitted (so it shouldn't expand page file).
|
// uncommitted (so it shouldn't expand page file).
|
||||||
|
@ -165,7 +164,7 @@ int Memory::Initialize() {
|
||||||
if (!mapping_) {
|
if (!mapping_) {
|
||||||
XELOGE("Unable to reserve the 4gb guest address space.");
|
XELOGE("Unable to reserve the 4gb guest address space.");
|
||||||
assert_not_null(mapping_);
|
assert_not_null(mapping_);
|
||||||
XEFAIL();
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to create our views. This may fail at the first address
|
// Attempt to create our views. This may fail at the first address
|
||||||
|
@ -181,7 +180,7 @@ int Memory::Initialize() {
|
||||||
if (!mapping_base_) {
|
if (!mapping_base_) {
|
||||||
XELOGE("Unable to find a continuous block in the 64bit address space.");
|
XELOGE("Unable to find a continuous block in the 64bit address space.");
|
||||||
assert_always();
|
assert_always();
|
||||||
XEFAIL();
|
return 1;
|
||||||
}
|
}
|
||||||
membase_ = mapping_base_;
|
membase_ = mapping_base_;
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ int Memory::Initialize() {
|
||||||
if (!mmio_handler_) {
|
if (!mmio_handler_) {
|
||||||
XELOGE("Unable to install MMIO handlers");
|
XELOGE("Unable to install MMIO handlers");
|
||||||
assert_always();
|
assert_always();
|
||||||
XEFAIL();
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate dirty page table.
|
// Allocate dirty page table.
|
||||||
|
@ -210,9 +209,6 @@ int Memory::Initialize() {
|
||||||
X_MEM_COMMIT, 16 * 1024);
|
X_MEM_COMMIT, 16 * 1024);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
XECLEANUP:
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const static struct {
|
const static struct {
|
||||||
|
@ -243,14 +239,14 @@ int Memory::MapViews(uint8_t* mapping_base) {
|
||||||
PROT_NONE, MAP_SHARED | MAP_FIXED, mapping_,
|
PROT_NONE, MAP_SHARED | MAP_FIXED, mapping_,
|
||||||
map_info[n].target_address));
|
map_info[n].target_address));
|
||||||
#endif // XE_PLATFORM_WIN32
|
#endif // XE_PLATFORM_WIN32
|
||||||
XEEXPECTNOTNULL(views_.all_views[n]);
|
if (!views_.all_views[n]) {
|
||||||
}
|
// Failed, so bail and try again.
|
||||||
return 0;
|
|
||||||
|
|
||||||
XECLEANUP:
|
|
||||||
UnmapViews();
|
UnmapViews();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Memory::UnmapViews() {
|
void Memory::UnmapViews() {
|
||||||
for (size_t n = 0; n < poly::countof(views_.all_views); n++) {
|
for (size_t n = 0; n < poly::countof(views_.all_views); n++) {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
'memory.h',
|
'memory.h',
|
||||||
'profiling.cc',
|
'profiling.cc',
|
||||||
'profiling.h',
|
'profiling.h',
|
||||||
'types.h',
|
|
||||||
'xbox.h',
|
'xbox.h',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -1,43 +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_TYPES_H_
|
|
||||||
#define XENIA_TYPES_H_
|
|
||||||
|
|
||||||
#define XEFAIL() goto XECLEANUP
|
|
||||||
#define XEEXPECT(expr) \
|
|
||||||
if (!(expr)) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTTRUE(expr) \
|
|
||||||
if (!(expr)) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTFALSE(expr) \
|
|
||||||
if ((expr)) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTZERO(expr) \
|
|
||||||
if ((expr) != 0) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTNOTZERO(expr) \
|
|
||||||
if ((expr) == 0) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTNULL(expr) \
|
|
||||||
if ((expr) != NULL) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
#define XEEXPECTNOTNULL(expr) \
|
|
||||||
if ((expr) == NULL) { \
|
|
||||||
goto XECLEANUP; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XENIA_TYPES_H_
|
|
Loading…
Reference in New Issue