2013-10-24 03:42:24 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* 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. *
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
2014-01-05 01:12:46 +00:00
|
|
|
#ifndef XENIA_KERNEL_KERNEL_STATE_H_
|
|
|
|
#define XENIA_KERNEL_KERNEL_STATE_H_
|
2013-10-24 03:42:24 +00:00
|
|
|
|
2014-08-03 21:38:04 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
#include <xenia/common.h>
|
|
|
|
#include <xenia/core.h>
|
|
|
|
|
|
|
|
#include <xenia/export_resolver.h>
|
|
|
|
#include <xenia/xbox.h>
|
2014-08-03 21:38:04 +00:00
|
|
|
#include <xenia/kernel/app.h>
|
2014-01-05 01:12:46 +00:00
|
|
|
#include <xenia/kernel/object_table.h>
|
|
|
|
#include <xenia/kernel/fs/filesystem.h>
|
2013-10-24 03:42:24 +00:00
|
|
|
|
|
|
|
|
2014-01-12 01:24:09 +00:00
|
|
|
XEDECLARECLASS1(xe, Emulator);
|
2013-10-24 03:42:24 +00:00
|
|
|
XEDECLARECLASS2(xe, cpu, Processor);
|
2014-01-12 05:40:23 +00:00
|
|
|
XEDECLARECLASS2(xe, kernel, Dispatcher);
|
2014-01-05 01:12:46 +00:00
|
|
|
XEDECLARECLASS2(xe, kernel, XModule);
|
2014-06-23 02:41:26 +00:00
|
|
|
XEDECLARECLASS2(xe, kernel, XNotifyListener);
|
2014-01-08 04:54:47 +00:00
|
|
|
XEDECLARECLASS2(xe, kernel, XThread);
|
2014-01-12 01:24:09 +00:00
|
|
|
XEDECLARECLASS2(xe, kernel, XUserModule);
|
2013-10-24 03:42:24 +00:00
|
|
|
XEDECLARECLASS3(xe, kernel, fs, FileSystem);
|
|
|
|
|
|
|
|
|
|
|
|
namespace xe {
|
|
|
|
namespace kernel {
|
|
|
|
|
|
|
|
|
|
|
|
class KernelState {
|
|
|
|
public:
|
|
|
|
KernelState(Emulator* emulator);
|
|
|
|
~KernelState();
|
|
|
|
|
|
|
|
static KernelState* shared();
|
|
|
|
|
|
|
|
Emulator* emulator() const { return emulator_; }
|
2013-12-07 06:57:16 +00:00
|
|
|
Memory* memory() const { return memory_; }
|
2013-10-24 03:42:24 +00:00
|
|
|
cpu::Processor* processor() const { return processor_; }
|
|
|
|
fs::FileSystem* file_system() const { return file_system_; }
|
|
|
|
|
2014-01-12 05:40:23 +00:00
|
|
|
Dispatcher* dispatcher() const { return dispatcher_; }
|
|
|
|
|
2014-08-03 21:38:04 +00:00
|
|
|
XAppManager* app_manager() const { return app_manager_.get(); }
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
ObjectTable* object_table() const { return object_table_; }
|
|
|
|
|
|
|
|
XModule* GetModule(const char* name);
|
2014-01-12 01:24:09 +00:00
|
|
|
XUserModule* GetExecutableModule();
|
|
|
|
void SetExecutableModule(XUserModule* module);
|
2013-10-24 03:42:24 +00:00
|
|
|
|
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);
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
private:
|
|
|
|
Emulator* emulator_;
|
2013-12-07 06:57:16 +00:00
|
|
|
Memory* memory_;
|
2013-10-24 03:42:24 +00:00
|
|
|
cpu::Processor* processor_;
|
|
|
|
fs::FileSystem* file_system_;
|
|
|
|
|
2014-01-12 05:40:23 +00:00
|
|
|
Dispatcher* dispatcher_;
|
|
|
|
|
2014-08-03 21:38:04 +00:00
|
|
|
std::unique_ptr<XAppManager> app_manager_;
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
ObjectTable* object_table_;
|
|
|
|
xe_mutex_t* 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_;
|
2013-10-24 03:42:24 +00:00
|
|
|
|
2014-01-12 01:24:09 +00:00
|
|
|
XUserModule* executable_module_;
|
2013-10-24 03:42:24 +00:00
|
|
|
|
|
|
|
friend class XObject;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-05 01:12:46 +00:00
|
|
|
// This is a global object initialized with the KernelState ctor.
|
|
|
|
// It references the current kernel state object that all kernel methods should
|
|
|
|
// be using to stash their variables.
|
|
|
|
// This sucks, but meh.
|
|
|
|
extern KernelState* shared_kernel_state_;
|
|
|
|
|
|
|
|
|
2013-10-24 03:42:24 +00:00
|
|
|
} // namespace kernel
|
|
|
|
} // namespace xe
|
|
|
|
|
|
|
|
|
2014-01-05 01:12:46 +00:00
|
|
|
#endif // XENIA_KERNEL_KERNEL_STATE_H_
|