Kernel: add KernelSystem class

master
Weiyi Wang 2018-10-11 14:49:52 +07:00
parent 1de63f9b16
commit f446fd1fe5
4 changed files with 29 additions and 9 deletions

@ -196,7 +196,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
archive_manager = std::make_unique<Service::FS::ArchiveManager>(); archive_manager = std::make_unique<Service::FS::ArchiveManager>();
HW::Init(); HW::Init();
Kernel::Init(system_mode); kernel = std::make_unique<Kernel::KernelSystem>(system_mode);
Service::Init(*this, service_manager); Service::Init(*this, service_manager);
GDBStub::Init(); GDBStub::Init();
@ -230,6 +230,14 @@ const Service::FS::ArchiveManager& System::ArchiveManager() const {
return *archive_manager; return *archive_manager;
} }
Kernel::KernelSystem& System::Kernel() {
return *kernel;
}
const Kernel::KernelSystem& System::Kernel() const {
return *kernel;
}
void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd) { void System::RegisterSoftwareKeyboard(std::shared_ptr<Frontend::SoftwareKeyboard> swkbd) {
registered_swkbd = std::move(swkbd); registered_swkbd = std::move(swkbd);
} }
@ -248,7 +256,7 @@ void System::Shutdown() {
GDBStub::Shutdown(); GDBStub::Shutdown();
VideoCore::Shutdown(); VideoCore::Shutdown();
Service::Shutdown(); Service::Shutdown();
Kernel::Shutdown(); kernel.reset();
HW::Shutdown(); HW::Shutdown();
telemetry_session.reset(); telemetry_session.reset();
#ifdef ENABLE_SCRIPTING #ifdef ENABLE_SCRIPTING

@ -36,6 +36,10 @@ class ArchiveManager;
} }
} // namespace Service } // namespace Service
namespace Kernel {
class KernelSystem;
}
namespace Core { namespace Core {
class System { class System {
@ -167,6 +171,12 @@ public:
/// Gets a const reference to the archive manager /// Gets a const reference to the archive manager
const Service::FS::ArchiveManager& ArchiveManager() const; const Service::FS::ArchiveManager& ArchiveManager() const;
/// Gets a reference to the kernel
Kernel::KernelSystem& Kernel();
/// Gets a const reference to the kernel
const Kernel::KernelSystem& Kernel() const;
PerfStats perf_stats; PerfStats perf_stats;
FrameLimiter frame_limiter; FrameLimiter frame_limiter;
@ -241,6 +251,8 @@ private:
std::unique_ptr<Service::FS::ArchiveManager> archive_manager; std::unique_ptr<Service::FS::ArchiveManager> archive_manager;
std::unique_ptr<Kernel::KernelSystem> kernel;
static System s_instance; static System s_instance;
ResultStatus status = ResultStatus::Success; ResultStatus status = ResultStatus::Success;

@ -17,7 +17,7 @@ namespace Kernel {
std::atomic<u32> Object::next_object_id{0}; std::atomic<u32> Object::next_object_id{0};
/// Initialize the kernel /// Initialize the kernel
void Init(u32 system_mode) { KernelSystem::KernelSystem(u32 system_mode) {
ConfigMem::Init(); ConfigMem::Init();
Kernel::MemoryInit(system_mode); Kernel::MemoryInit(system_mode);
@ -33,7 +33,7 @@ void Init(u32 system_mode) {
} }
/// Shutdown the kernel /// Shutdown the kernel
void Shutdown() { KernelSystem::~KernelSystem() {
g_handle_table.Clear(); // Free all kernel objects g_handle_table.Clear(); // Free all kernel objects
Kernel::ThreadingShutdown(); Kernel::ThreadingShutdown();

@ -8,10 +8,10 @@
namespace Kernel { namespace Kernel {
/// Initialize the kernel with the specified system mode. class KernelSystem {
void Init(u32 system_mode); public:
explicit KernelSystem(u32 system_mode);
/// Shutdown the kernel ~KernelSystem();
void Shutdown(); };
} // namespace Kernel } // namespace Kernel