xenia-canary/src/xenia/kernel/kernel_state.h

114 lines
3.3 KiB
C
Raw Normal View History

/**
******************************************************************************
* 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_STATE_H_
#define XENIA_KERNEL_KERNEL_STATE_H_
2014-08-03 21:38:04 +00:00
#include <memory>
2014-08-16 07:56:50 +00:00
#include <mutex>
2014-08-03 21:38:04 +00:00
#include "xenia/cpu/export_resolver.h"
2015-02-01 06:49:47 +00:00
#include "xenia/kernel/app.h"
#include "xenia/kernel/content_manager.h"
2015-02-01 06:49:47 +00:00
#include "xenia/kernel/fs/filesystem.h"
#include "xenia/kernel/object_table.h"
#include "xenia/kernel/user_profile.h"
#include "xenia/memory.h"
#include "xenia/xbox.h"
2014-08-17 02:07:21 +00:00
namespace xe {
class Emulator;
namespace cpu {
class Processor;
} // namespace cpu
} // namespace xe
namespace xe {
namespace kernel {
2014-08-17 02:07:21 +00:00
class Dispatcher;
class XModule;
class XNotifyListener;
class XThread;
class XUserModule;
class KernelState {
2014-08-17 02:07:21 +00:00
public:
KernelState(Emulator* emulator);
~KernelState();
static KernelState* shared();
Emulator* emulator() const { return emulator_; }
Memory* memory() const { return memory_; }
cpu::Processor* processor() const { return processor_; }
fs::FileSystem* file_system() const { return file_system_; }
uint32_t title_id() const;
Dispatcher* dispatcher() const { return dispatcher_; }
2014-08-03 21:38:04 +00:00
XAppManager* app_manager() const { return app_manager_.get(); }
2014-08-04 04:26:10 +00:00
UserProfile* user_profile() const { return user_profile_.get(); }
ContentManager* content_manager() const { return content_manager_.get(); }
2014-08-03 21:38:04 +00:00
ObjectTable* object_table() const { return object_table_; }
2014-08-16 07:56:50 +00:00
std::mutex& object_mutex() { return object_mutex_; }
2014-11-01 18:42:44 +00:00
uint32_t process_type() const { return process_type_; }
void set_process_type(uint32_t value) { process_type_ = value; }
void RegisterModule(XModule* module);
void UnregisterModule(XModule* module);
XModule* GetModule(const char* name);
XUserModule* GetExecutableModule();
void SetExecutableModule(XUserModule* module);
2014-01-08 04:54:47 +00:00
void RegisterThread(XThread* thread);
void UnregisterThread(XThread* thread);
XThread* GetThreadByID(uint32_t thread_id);
2014-06-23 02:41:26 +00:00
void RegisterNotifyListener(XNotifyListener* listener);
void UnregisterNotifyListener(XNotifyListener* listener);
void BroadcastNotification(XNotificationID id, uint32_t data);
2014-08-17 02:07:21 +00:00
void CompleteOverlapped(uint32_t overlapped_ptr, X_RESULT result,
uint32_t length = 0);
void CompleteOverlappedImmediate(uint32_t overlapped_ptr, X_RESULT result,
uint32_t length = 0);
2014-08-04 04:26:10 +00:00
2014-08-17 02:07:21 +00:00
private:
Emulator* emulator_;
Memory* memory_;
cpu::Processor* processor_;
fs::FileSystem* file_system_;
2014-08-17 02:07:21 +00:00
Dispatcher* dispatcher_;
2014-08-03 21:38:04 +00:00
std::unique_ptr<XAppManager> app_manager_;
2014-08-04 04:26:10 +00:00
std::unique_ptr<UserProfile> user_profile_;
std::unique_ptr<ContentManager> content_manager_;
2014-08-03 21:38:04 +00:00
2014-08-17 02:07:21 +00:00
ObjectTable* object_table_;
std::mutex object_mutex_;
2014-01-08 04:54:47 +00:00
std::unordered_map<uint32_t, XThread*> threads_by_id_;
2014-06-23 02:41:26 +00:00
std::vector<XNotifyListener*> notify_listeners_;
bool has_notified_startup_;
2014-11-01 18:42:44 +00:00
uint32_t process_type_;
2014-08-17 02:07:21 +00:00
XUserModule* executable_module_;
friend class XObject;
};
} // namespace kernel
} // namespace xe
#endif // XENIA_KERNEL_KERNEL_STATE_H_