Moving DPC list into KernelState and removing unused file.

This commit is contained in:
Ben Vanik 2015-09-06 09:36:39 -07:00
parent 3c96b6fa0a
commit 669f5b061f
8 changed files with 12 additions and 106 deletions

View File

@ -13,7 +13,6 @@
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
#include "xenia/base/main.h" #include "xenia/base/main.h"
#include "xenia/emulator.h" #include "xenia/emulator.h"
#include "xenia/kernel/kernel.h"
#include "xenia/profiling.h" #include "xenia/profiling.h"
#include "xenia/ui/file_picker.h" #include "xenia/ui/file_picker.h"

View File

@ -18,7 +18,6 @@
#include "xenia/base/string.h" #include "xenia/base/string.h"
#include "xenia/gpu/graphics_system.h" #include "xenia/gpu/graphics_system.h"
#include "xenia/hid/input_system.h" #include "xenia/hid/input_system.h"
#include "xenia/kernel/kernel.h"
#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/kernel_state.h"
#include "xenia/kernel/modules.h" #include "xenia/kernel/modules.h"
#include "xenia/memory.h" #include "xenia/memory.h"

View File

@ -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

View File

@ -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_

View File

@ -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_

View File

@ -18,7 +18,6 @@
#include "xenia/cpu/processor.h" #include "xenia/cpu/processor.h"
#include "xenia/emulator.h" #include "xenia/emulator.h"
#include "xenia/kernel/apps/apps.h" #include "xenia/kernel/apps/apps.h"
#include "xenia/kernel/dispatcher.h"
#include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xevent.h"
#include "xenia/kernel/objects/xmodule.h" #include "xenia/kernel/objects/xmodule.h"
#include "xenia/kernel/objects/xnotify_listener.h" #include "xenia/kernel/objects/xnotify_listener.h"
@ -50,16 +49,11 @@ KernelState* kernel_state() { return shared_kernel_state_; }
KernelState::KernelState(Emulator* emulator) KernelState::KernelState(Emulator* emulator)
: emulator_(emulator), : emulator_(emulator),
memory_(emulator->memory()), memory_(emulator->memory()),
object_table_(nullptr), dispatch_thread_running_(false),
has_notified_startup_(false), dpc_list_(emulator->memory()) {
process_type_(X_PROCTYPE_USER),
process_info_block_address_(0),
dispatch_thread_running_(false) {
processor_ = emulator->processor(); processor_ = emulator->processor();
file_system_ = emulator->file_system(); file_system_ = emulator->file_system();
dispatcher_ = new Dispatcher(this);
app_manager_ = std::make_unique<XAppManager>(); app_manager_ = std::make_unique<XAppManager>();
user_profile_ = std::make_unique<UserProfile>(); user_profile_ = std::make_unique<UserProfile>();
@ -109,8 +103,6 @@ KernelState::~KernelState() {
// Shutdown apps. // Shutdown apps.
app_manager_.reset(); app_manager_.reset();
delete dispatcher_;
if (process_info_block_address_) { if (process_info_block_address_) {
memory_->SystemHeapFree(process_info_block_address_); memory_->SystemHeapFree(process_info_block_address_);
} }

View File

@ -23,6 +23,7 @@
#include "xenia/cpu/export_resolver.h" #include "xenia/cpu/export_resolver.h"
#include "xenia/kernel/app.h" #include "xenia/kernel/app.h"
#include "xenia/kernel/content_manager.h" #include "xenia/kernel/content_manager.h"
#include "xenia/kernel/native_list.h"
#include "xenia/kernel/object_table.h" #include "xenia/kernel/object_table.h"
#include "xenia/kernel/user_profile.h" #include "xenia/kernel/user_profile.h"
#include "xenia/memory.h" #include "xenia/memory.h"
@ -98,8 +99,6 @@ class KernelState {
uint32_t title_id() const; uint32_t title_id() const;
Dispatcher* dispatcher() const { return dispatcher_; }
XAppManager* app_manager() const { return app_manager_.get(); } XAppManager* app_manager() const { return app_manager_.get(); }
UserProfile* user_profile() const { return user_profile_.get(); } UserProfile* user_profile() const { return user_profile_.get(); }
ContentManager* content_manager() const { return content_manager_.get(); } ContentManager* content_manager() const { return content_manager_.get(); }
@ -151,6 +150,8 @@ class KernelState {
void UnregisterNotifyListener(XNotifyListener* listener); void UnregisterNotifyListener(XNotifyListener* listener);
void BroadcastNotification(XNotificationID id, uint32_t data); void BroadcastNotification(XNotificationID id, uint32_t data);
NativeList* dpc_list() { return &dpc_list_; }
void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result); void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result);
void CompleteOverlappedEx(uint32_t overlapped_ptr, X_RESULT result, void CompleteOverlappedEx(uint32_t overlapped_ptr, X_RESULT result,
uint32_t extended_error, uint32_t length); uint32_t extended_error, uint32_t length);
@ -171,8 +172,6 @@ class KernelState {
cpu::Processor* processor_; cpu::Processor* processor_;
vfs::VirtualFileSystem* file_system_; vfs::VirtualFileSystem* file_system_;
Dispatcher* dispatcher_;
std::unique_ptr<XAppManager> app_manager_; std::unique_ptr<XAppManager> app_manager_;
std::unique_ptr<UserProfile> user_profile_; std::unique_ptr<UserProfile> user_profile_;
std::unique_ptr<ContentManager> content_manager_; std::unique_ptr<ContentManager> content_manager_;
@ -180,22 +179,23 @@ class KernelState {
xe::global_critical_region global_critical_region_; xe::global_critical_region global_critical_region_;
// Must be guarded by the global critical region. // Must be guarded by the global critical region.
ObjectTable* object_table_; ObjectTable* object_table_ = nullptr;
std::unordered_map<uint32_t, XThread*> threads_by_id_; std::unordered_map<uint32_t, XThread*> threads_by_id_;
std::vector<object_ref<XNotifyListener>> notify_listeners_; std::vector<object_ref<XNotifyListener>> notify_listeners_;
bool has_notified_startup_; bool has_notified_startup_ = false;
uint32_t process_type_; uint32_t process_type_ = X_PROCTYPE_USER;
object_ref<XUserModule> executable_module_; object_ref<XUserModule> executable_module_;
std::vector<object_ref<XKernelModule>> kernel_modules_; std::vector<object_ref<XKernelModule>> kernel_modules_;
std::vector<object_ref<XUserModule>> user_modules_; std::vector<object_ref<XUserModule>> user_modules_;
std::vector<TerminateNotification> terminate_notifications; std::vector<TerminateNotification> terminate_notifications;
uint32_t process_info_block_address_; uint32_t process_info_block_address_ = 0;
std::atomic<bool> dispatch_thread_running_; std::atomic<bool> dispatch_thread_running_;
object_ref<XHostThread> dispatch_thread_; object_ref<XHostThread> dispatch_thread_;
// Must be guarded by the global critical region. // Must be guarded by the global critical region.
NativeList dpc_list_;
std::condition_variable_any dispatch_cond_; std::condition_variable_any dispatch_cond_;
std::list<std::function<void()>> dispatch_queue_; std::list<std::function<void()>> dispatch_queue_;

View File

@ -12,7 +12,6 @@
#include "xenia/base/logging.h" #include "xenia/base/logging.h"
#include "xenia/base/mutex.h" #include "xenia/base/mutex.h"
#include "xenia/cpu/processor.h" #include "xenia/cpu/processor.h"
#include "xenia/kernel/dispatcher.h"
#include "xenia/kernel/kernel_state.h" #include "xenia/kernel/kernel_state.h"
#include "xenia/kernel/native_list.h" #include "xenia/kernel/native_list.h"
#include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/objects/xevent.h"
@ -1275,8 +1274,7 @@ SHIM_CALL KeInsertQueueDpc_shim(PPCContext* ppc_context,
// Lock dispatcher. // Lock dispatcher.
auto global_lock = xe::global_critical_region::AcquireDirect(); auto global_lock = xe::global_critical_region::AcquireDirect();
auto dispatcher = kernel_state->dispatcher(); auto dpc_list = kernel_state->dpc_list();
auto dpc_list = dispatcher->dpc_list();
// If already in a queue, abort. // If already in a queue, abort.
if (dpc_list->IsQueued(list_entry_ptr)) { 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; uint32_t list_entry_ptr = dpc_ptr + 4;
auto global_lock = xe::global_critical_region::AcquireDirect(); auto global_lock = xe::global_critical_region::AcquireDirect();
auto dispatcher = kernel_state->dispatcher(); auto dpc_list = kernel_state->dpc_list();
auto dpc_list = dispatcher->dpc_list();
if (dpc_list->IsQueued(list_entry_ptr)) { if (dpc_list->IsQueued(list_entry_ptr)) {
dpc_list->Remove(list_entry_ptr); dpc_list->Remove(list_entry_ptr);
result = true; result = true;