From 1104f8e6874694c2233a2bbc25712e055235b1b2 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 24 May 2015 20:11:19 -0700 Subject: [PATCH] Header cleanups and prep. --- src/xenia/cpu/xex_module.cc | 2 +- src/xenia/gpu/gl4/command_processor.h | 1 + src/xenia/kernel/content_manager.cc | 1 + src/xenia/kernel/object_table.h | 4 ++-- src/xenia/kernel/objects/xenumerator.h | 2 ++ src/xenia/kernel/objects/xfile.h | 1 + src/xenia/kernel/objects/xmodule.cc | 1 + src/xenia/kernel/objects/xnotify_listener.cc | 2 ++ src/xenia/kernel/objects/xnotify_listener.h | 1 + src/xenia/kernel/objects/xthread.cc | 5 ++++- src/xenia/kernel/objects/xuser_module.cc | 11 ++--------- src/xenia/kernel/xobject.cc | 7 ++++++- src/xenia/kernel/xobject.h | 14 ++++++++++---- 13 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 9fda22aaf..65e498826 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -125,7 +125,7 @@ bool XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) { kernel_export = export_resolver->GetExportByOrdinal(library->name, info->ordinal); } else { - XModule* module = kernel_state_->GetModule(library->name); + auto module = kernel_state_->GetModule(library->name); if (module) { user_export_addr = module->GetProcAddressByOrdinal(info->ordinal); } diff --git a/src/xenia/gpu/gl4/command_processor.h b/src/xenia/gpu/gl4/command_processor.h index 583fc317b..db96a2e9a 100644 --- a/src/xenia/gpu/gl4/command_processor.h +++ b/src/xenia/gpu/gl4/command_processor.h @@ -25,6 +25,7 @@ #include "xenia/gpu/register_file.h" #include "xenia/gpu/tracing.h" #include "xenia/gpu/xenos.h" +#include "xenia/kernel/objects/xthread.h" #include "xenia/memory.h" namespace xe { diff --git a/src/xenia/kernel/content_manager.cc b/src/xenia/kernel/content_manager.cc index 3edd28750..bfe00c8a8 100644 --- a/src/xenia/kernel/content_manager.cc +++ b/src/xenia/kernel/content_manager.cc @@ -12,6 +12,7 @@ #include #include "xenia/base/fs.h" +#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xobject.h" namespace xe { diff --git a/src/xenia/kernel/object_table.h b/src/xenia/kernel/object_table.h index 4da6f1a54..d15a4efee 100644 --- a/src/xenia/kernel/object_table.h +++ b/src/xenia/kernel/object_table.h @@ -14,13 +14,13 @@ #include #include +#include "xenia/base/mutex.h" +#include "xenia/kernel/xobject.h" #include "xenia/xbox.h" namespace xe { namespace kernel { -class XObject; - class ObjectTable { public: ObjectTable(); diff --git a/src/xenia/kernel/objects/xenumerator.h b/src/xenia/kernel/objects/xenumerator.h index 85612acbc..58664e5cb 100644 --- a/src/xenia/kernel/objects/xenumerator.h +++ b/src/xenia/kernel/objects/xenumerator.h @@ -10,6 +10,8 @@ #ifndef XENIA_KERNEL_XBOXKRNL_XENUMERATOR_H_ #define XENIA_KERNEL_XBOXKRNL_XENUMERATOR_H_ +#include + #include "xenia/kernel/xobject.h" #include "xenia/xbox.h" diff --git a/src/xenia/kernel/objects/xfile.h b/src/xenia/kernel/objects/xfile.h index f54f73f56..de3bb56af 100644 --- a/src/xenia/kernel/objects/xfile.h +++ b/src/xenia/kernel/objects/xfile.h @@ -10,6 +10,7 @@ #ifndef XENIA_KERNEL_XBOXKRNL_XFILE_H_ #define XENIA_KERNEL_XBOXKRNL_XFILE_H_ +#include "xenia/kernel/fs/entry.h" #include "xenia/kernel/xobject.h" #include "xenia/xbox.h" diff --git a/src/xenia/kernel/objects/xmodule.cc b/src/xenia/kernel/objects/xmodule.cc index fc1e4247d..a4505ab82 100644 --- a/src/xenia/kernel/objects/xmodule.cc +++ b/src/xenia/kernel/objects/xmodule.cc @@ -10,6 +10,7 @@ #include "xenia/kernel/objects/xmodule.h" #include "xenia/base/string.h" +#include "xenia/kernel/kernel_state.h" namespace xe { namespace kernel { diff --git a/src/xenia/kernel/objects/xnotify_listener.cc b/src/xenia/kernel/objects/xnotify_listener.cc index 495e9cfde..650fe5de4 100644 --- a/src/xenia/kernel/objects/xnotify_listener.cc +++ b/src/xenia/kernel/objects/xnotify_listener.cc @@ -9,6 +9,8 @@ #include "xenia/kernel/objects/xnotify_listener.h" +#include "xenia/kernel/kernel_state.h" + namespace xe { namespace kernel { diff --git a/src/xenia/kernel/objects/xnotify_listener.h b/src/xenia/kernel/objects/xnotify_listener.h index 6b5eb7887..581580dbc 100644 --- a/src/xenia/kernel/objects/xnotify_listener.h +++ b/src/xenia/kernel/objects/xnotify_listener.h @@ -11,6 +11,7 @@ #define XENIA_KERNEL_XBOXKRNL_XNOTIFY_LISTENER_H_ #include +#include #include "xenia/kernel/xobject.h" #include "xenia/xbox.h" diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 764b09020..7bdc71a13 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -9,10 +9,13 @@ #include "xenia/kernel/objects/xthread.h" +#include + #include "xenia/base/logging.h" #include "xenia/base/math.h" #include "xenia/base/threading.h" #include "xenia/cpu/cpu.h" +#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/native_list.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xuser_module.h" @@ -153,7 +156,7 @@ X_STATUS XThread::Create() { // Set native info. SetNativePointer(thread_state_address_, true); - XUserModule* module = kernel_state()->GetExecutableModule(); + auto module = kernel_state()->GetExecutableModule(); // Allocate thread scratch. // This is used by interrupts/APCs/etc so we can round-trip pointers through. diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index e9afb1053..4ee9eb13b 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -51,9 +51,6 @@ X_STATUS XUserModule::LoadFromFile(std::string path) { // Map. auto mmap = fs_entry->CreateMemoryMapping(fs::Mode::READ, 0, 0); if (!mmap) { - if (file) { - file->Release(); - } return result; } @@ -63,9 +60,6 @@ X_STATUS XUserModule::LoadFromFile(std::string path) { X_FILE_NETWORK_OPEN_INFORMATION file_info; result = fs_entry->QueryInfo(&file_info); if (result) { - if (file) { - file->Release(); - } return result; } @@ -367,8 +361,7 @@ void XUserModule::Dump() { unimpl_count++; } } else { - // User module - XModule* module = kernel_state_->GetModule(library->name); + auto module = kernel_state_->GetModule(library->name); if (module) { uint32_t export_addr = module->GetProcAddressByOrdinal(info->ordinal); @@ -409,7 +402,7 @@ void XUserModule::Dump() { implemented = kernel_export->is_implemented; } } else { - XModule* module = kernel_state_->GetModule(library->name); + auto module = kernel_state_->GetModule(library->name); if (module && module->GetProcAddressByOrdinal(info->ordinal)) { // TODO: Name lookup implemented = true; diff --git a/src/xenia/kernel/xobject.cc b/src/xenia/kernel/xobject.cc index 3451157bc..5b1e6e27b 100644 --- a/src/xenia/kernel/xobject.cc +++ b/src/xenia/kernel/xobject.cc @@ -9,10 +9,11 @@ #include "xenia/kernel/xobject.h" -#include "xenia/kernel/xboxkrnl_private.h" +#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xmutant.h" #include "xenia/kernel/objects/xsemaphore.h" +#include "xenia/kernel/xboxkrnl_private.h" namespace xe { namespace kernel { @@ -34,6 +35,10 @@ XObject::~XObject() { assert_zero(pointer_ref_count_); } +Emulator* XObject::emulator() const { return kernel_state_->emulator_; } +KernelState* XObject::kernel_state() const { return kernel_state_; } +Memory* XObject::memory() const { return kernel_state_->memory(); } + XObject::Type XObject::type() { return type_; } X_HANDLE XObject::handle() const { return handle_; } diff --git a/src/xenia/kernel/xobject.h b/src/xenia/kernel/xobject.h index dcfb1f43a..00fdafc5b 100644 --- a/src/xenia/kernel/xobject.h +++ b/src/xenia/kernel/xobject.h @@ -12,12 +12,18 @@ #include -#include "xenia/kernel/kernel_state.h" #include "xenia/xbox.h" +namespace xe { +class Emulator; +class Memory; +} // namespace xe + namespace xe { namespace kernel { +class KernelState; + // http://www.nirsoft.net/kernel_struct/vista/DISPATCHER_HEADER.html typedef struct { xe::be type_flags; @@ -43,9 +49,9 @@ class XObject { XObject(KernelState* kernel_state, Type type); virtual ~XObject(); - Emulator* emulator() const { return kernel_state_->emulator_; } - KernelState* kernel_state() const { return kernel_state_; } - Memory* memory() const { return kernel_state_->memory(); } + Emulator* emulator() const; + KernelState* kernel_state() const; + Memory* memory() const; Type type(); X_HANDLE handle() const;