forked from RKX1209/nsemu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nsemu.cpp
33 lines (29 loc) · 831 Bytes
/
Nsemu.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* nsemu - LGPL - Copyright 2017 rkx1209<[email protected]> */
#include <thread>
#include "Nsemu.hpp"
Nsemu *Nsemu::inst = nullptr;
static std::thread cpu_thread;
uint32_t handle_id;
std::unordered_map<uint32_t, KObject *> handles;
static void LoadNso(Nsemu *nsemu, string path) {
Nso nso (path);
nso.load (nsemu);
}
static void CpuThread() {
ns_print ("[CPU]\tLaunching ARMv8::VCPU.....\n");
Cpu::Init ();
Cpu::SetState (Cpu::State::Running);
ns_print ("[CPU]\tRunning.....\n");
Cpu::Run ();
}
bool Nsemu::BootUp(const std::string& path) {
ns_print ("Booting... %s\n", path.c_str ());
Memory::InitMemmap (this);
LoadNso (this, path);
IPC::InitIPC();
handle_id = 0xde00; // XXX: Magic number?
cpu_thread = std::thread (CpuThread);
/* Run cpu */
cpu_thread.join ();
return true;
}