mirror of
https://github.com/reswitched/Mephisto.git
synced 2024-06-16 03:16:50 -04:00
38 lines
848 B
C++
38 lines
848 B
C++
#include "Ctu.h"
|
|
|
|
LogLevel g_LogLevel = Info;
|
|
|
|
Ctu::Ctu() : cpu(this), svc(this), ipc(this), tm(this), mmiohandler(this), bridge(this), gdbStub(this), handleId(0xde00), heapsize(0x0) {
|
|
handles[0xffff8001] = make_shared<Process>(this);
|
|
}
|
|
|
|
void Ctu::execProgram(gptr ep) {
|
|
auto sp = 7 << 24;
|
|
auto ss = 8 * 1024 * 1024;
|
|
|
|
cpu.map(sp - ss, ss);
|
|
mmiohandler.MMIOInitialize();
|
|
cpu.setMmio(&mmiohandler);
|
|
|
|
auto mainThread = tm.create(ep, sp);
|
|
mainThread->regs.X1 = mainThread->handle;
|
|
mainThread->resume();
|
|
|
|
tm.start();
|
|
}
|
|
|
|
ghandle Ctu::duplicateHandle(KObject *ptr) {
|
|
for(auto elem : handles)
|
|
if(elem.second.get() == ptr)
|
|
return newHandle(elem.second);
|
|
return 0;
|
|
}
|
|
|
|
void Ctu::deleteHandle(ghandle handle) {
|
|
if(handles.find(handle) != handles.end()) {
|
|
auto hnd = getHandle<KObject>(handle);
|
|
handles.erase(handle);
|
|
hnd->close();
|
|
}
|
|
}
|