nsemu/Nsemu.cpp

30 lines
688 B
C++
Raw Normal View History

2017-11-14 07:23:42 -05:00
/* nsemu - LGPL - Copyright 2017 rkx1209<rkx1209dev@gmail.com> */
#include <thread>
2017-11-14 07:23:42 -05:00
#include "Nsemu.hpp"
2018-02-15 08:41:15 -05:00
Nsemu *Nsemu::inst = nullptr;
static std::thread cpu_thread;
2017-11-15 11:54:41 -05:00
2018-03-05 08:20:48 -05:00
static void LoadNso(Nsemu *nsemu, string path) {
2017-12-31 04:12:32 -05:00
Nso nso (path);
2018-03-05 08:20:48 -05:00
nso.load (nsemu);
2017-11-15 11:54:41 -05:00
}
static void CpuThread() {
2018-03-17 05:51:50 -04:00
ns_print ("[CPU]\tLaunching ARMv8::VCPU.....\n");
2018-02-15 08:41:15 -05:00
Cpu::Init ();
Cpu::SetState (Cpu::State::Running);
2018-03-17 05:51:50 -04:00
ns_print ("[CPU]\tRunning.....\n");
2018-02-15 08:41:15 -05:00
Cpu::Run ();
}
2018-02-15 08:41:15 -05:00
bool Nsemu::BootUp(const std::string& path) {
2018-03-17 05:51:50 -04:00
ns_print ("Booting... %s\n", path.c_str ());
2018-02-15 08:41:15 -05:00
Memory::InitMemmap (this);
2018-03-05 08:20:48 -05:00
LoadNso (this, path);
2018-02-15 08:41:15 -05:00
cpu_thread = std::thread (CpuThread);
2017-12-31 04:12:32 -05:00
/* Run cpu */
cpu_thread.join ();
return true;
2017-11-15 11:54:41 -05:00
}