From 669f5b061f2e2221c6c59a4f2a2e5458fe48351e Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 6 Sep 2015 09:36:39 -0700 Subject: [PATCH] Moving DPC list into KernelState and removing unused file. --- src/xenia/app/xenia_main.cc | 1 - src/xenia/emulator.cc | 1 - src/xenia/kernel/dispatcher.cc | 26 ----------------- src/xenia/kernel/dispatcher.h | 39 -------------------------- src/xenia/kernel/kernel.h | 15 ---------- src/xenia/kernel/kernel_state.cc | 12 ++------ src/xenia/kernel/kernel_state.h | 16 +++++------ src/xenia/kernel/xboxkrnl_threading.cc | 8 ++---- 8 files changed, 12 insertions(+), 106 deletions(-) delete mode 100644 src/xenia/kernel/dispatcher.cc delete mode 100644 src/xenia/kernel/dispatcher.h delete mode 100644 src/xenia/kernel/kernel.h diff --git a/src/xenia/app/xenia_main.cc b/src/xenia/app/xenia_main.cc index b1b1d62a2..ec5dc137a 100644 --- a/src/xenia/app/xenia_main.cc +++ b/src/xenia/app/xenia_main.cc @@ -13,7 +13,6 @@ #include "xenia/base/logging.h" #include "xenia/base/main.h" #include "xenia/emulator.h" -#include "xenia/kernel/kernel.h" #include "xenia/profiling.h" #include "xenia/ui/file_picker.h" diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 62873c454..833a5a50b 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -18,7 +18,6 @@ #include "xenia/base/string.h" #include "xenia/gpu/graphics_system.h" #include "xenia/hid/input_system.h" -#include "xenia/kernel/kernel.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/modules.h" #include "xenia/memory.h" diff --git a/src/xenia/kernel/dispatcher.cc b/src/xenia/kernel/dispatcher.cc deleted file mode 100644 index 0a9867881..000000000 --- a/src/xenia/kernel/dispatcher.cc +++ /dev/null @@ -1,26 +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/dispatcher.h" - -#include "xenia/kernel/kernel_state.h" -#include "xenia/kernel/native_list.h" - -namespace xe { -namespace kernel { - -Dispatcher::Dispatcher(KernelState* kernel_state) - : kernel_state_(kernel_state) { - dpc_list_ = new NativeList(kernel_state->memory()); -} - -Dispatcher::~Dispatcher() { delete dpc_list_; } - -} // namespace kernel -} // namespace xe diff --git a/src/xenia/kernel/dispatcher.h b/src/xenia/kernel/dispatcher.h deleted file mode 100644 index b8cb07c2c..000000000 --- a/src/xenia/kernel/dispatcher.h +++ /dev/null @@ -1,39 +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_DISPATCHER_H_ -#define XENIA_KERNEL_DISPATCHER_H_ - -#include "xenia/xbox.h" - -namespace xe { -namespace kernel { - -class KernelState; -class NativeList; - -// All access must be guarded by the global critical section. -class Dispatcher { - public: - explicit Dispatcher(KernelState* kernel_state); - virtual ~Dispatcher(); - - KernelState* kernel_state() const { return kernel_state_; } - - NativeList* dpc_list() const { return dpc_list_; } - - private: - KernelState* kernel_state_; - NativeList* dpc_list_; -}; - -} // namespace kernel -} // namespace xe - -#endif // XENIA_KERNEL_DISPATCHER_H_ diff --git a/src/xenia/kernel/kernel.h b/src/xenia/kernel/kernel.h deleted file mode 100644 index e8a096cb0..000000000 --- a/src/xenia/kernel/kernel.h +++ /dev/null @@ -1,15 +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_KERNEL_H_ -#define XENIA_KERNEL_KERNEL_H_ - -#include "xenia/kernel/modules.h" - -#endif // XENIA_KERNEL_KERNEL_H_ diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 94e59f7a1..bc6abe507 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -18,7 +18,6 @@ #include "xenia/cpu/processor.h" #include "xenia/emulator.h" #include "xenia/kernel/apps/apps.h" -#include "xenia/kernel/dispatcher.h" #include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xmodule.h" #include "xenia/kernel/objects/xnotify_listener.h" @@ -50,16 +49,11 @@ KernelState* kernel_state() { return shared_kernel_state_; } KernelState::KernelState(Emulator* emulator) : emulator_(emulator), memory_(emulator->memory()), - object_table_(nullptr), - has_notified_startup_(false), - process_type_(X_PROCTYPE_USER), - process_info_block_address_(0), - dispatch_thread_running_(false) { + dispatch_thread_running_(false), + dpc_list_(emulator->memory()) { processor_ = emulator->processor(); file_system_ = emulator->file_system(); - dispatcher_ = new Dispatcher(this); - app_manager_ = std::make_unique(); user_profile_ = std::make_unique(); @@ -109,8 +103,6 @@ KernelState::~KernelState() { // Shutdown apps. app_manager_.reset(); - delete dispatcher_; - if (process_info_block_address_) { memory_->SystemHeapFree(process_info_block_address_); } diff --git a/src/xenia/kernel/kernel_state.h b/src/xenia/kernel/kernel_state.h index 4a42c308d..2f32bf02d 100644 --- a/src/xenia/kernel/kernel_state.h +++ b/src/xenia/kernel/kernel_state.h @@ -23,6 +23,7 @@ #include "xenia/cpu/export_resolver.h" #include "xenia/kernel/app.h" #include "xenia/kernel/content_manager.h" +#include "xenia/kernel/native_list.h" #include "xenia/kernel/object_table.h" #include "xenia/kernel/user_profile.h" #include "xenia/memory.h" @@ -98,8 +99,6 @@ class KernelState { uint32_t title_id() const; - Dispatcher* dispatcher() const { return dispatcher_; } - XAppManager* app_manager() const { return app_manager_.get(); } UserProfile* user_profile() const { return user_profile_.get(); } ContentManager* content_manager() const { return content_manager_.get(); } @@ -151,6 +150,8 @@ class KernelState { void UnregisterNotifyListener(XNotifyListener* listener); void BroadcastNotification(XNotificationID id, uint32_t data); + NativeList* dpc_list() { return &dpc_list_; } + void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result); void CompleteOverlappedEx(uint32_t overlapped_ptr, X_RESULT result, uint32_t extended_error, uint32_t length); @@ -171,8 +172,6 @@ class KernelState { cpu::Processor* processor_; vfs::VirtualFileSystem* file_system_; - Dispatcher* dispatcher_; - std::unique_ptr app_manager_; std::unique_ptr user_profile_; std::unique_ptr content_manager_; @@ -180,22 +179,23 @@ class KernelState { xe::global_critical_region global_critical_region_; // Must be guarded by the global critical region. - ObjectTable* object_table_; + ObjectTable* object_table_ = nullptr; std::unordered_map threads_by_id_; std::vector> notify_listeners_; - bool has_notified_startup_; + bool has_notified_startup_ = false; - uint32_t process_type_; + uint32_t process_type_ = X_PROCTYPE_USER; object_ref executable_module_; std::vector> kernel_modules_; std::vector> user_modules_; std::vector terminate_notifications; - uint32_t process_info_block_address_; + uint32_t process_info_block_address_ = 0; std::atomic dispatch_thread_running_; object_ref dispatch_thread_; // Must be guarded by the global critical region. + NativeList dpc_list_; std::condition_variable_any dispatch_cond_; std::list> dispatch_queue_; diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index b4af69042..4478bebc5 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -12,7 +12,6 @@ #include "xenia/base/logging.h" #include "xenia/base/mutex.h" #include "xenia/cpu/processor.h" -#include "xenia/kernel/dispatcher.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/native_list.h" #include "xenia/kernel/objects/xevent.h" @@ -1275,8 +1274,7 @@ SHIM_CALL KeInsertQueueDpc_shim(PPCContext* ppc_context, // Lock dispatcher. auto global_lock = xe::global_critical_region::AcquireDirect(); - auto dispatcher = kernel_state->dispatcher(); - auto dpc_list = dispatcher->dpc_list(); + auto dpc_list = kernel_state->dpc_list(); // If already in a queue, abort. if (dpc_list->IsQueued(list_entry_ptr)) { @@ -1304,9 +1302,7 @@ SHIM_CALL KeRemoveQueueDpc_shim(PPCContext* ppc_context, uint32_t list_entry_ptr = dpc_ptr + 4; auto global_lock = xe::global_critical_region::AcquireDirect(); - auto dispatcher = kernel_state->dispatcher(); - - auto dpc_list = dispatcher->dpc_list(); + auto dpc_list = kernel_state->dpc_list(); if (dpc_list->IsQueued(list_entry_ptr)) { dpc_list->Remove(list_entry_ptr); result = true;