mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-24 16:49:50 +00:00
Add state saving to tertiary kernel modules.
This commit is contained in:
parent
91d727a65a
commit
3ed2045f6b
@ -114,6 +114,43 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<class K, class T>
|
||||
void Do(std::multimap<K, T> &x)
|
||||
{
|
||||
unsigned int number = (unsigned int)x.size();
|
||||
Do(number);
|
||||
switch (mode) {
|
||||
case MODE_READ:
|
||||
{
|
||||
x.clear();
|
||||
while (number > 0)
|
||||
{
|
||||
K first;
|
||||
Do(first);
|
||||
T second;
|
||||
Do(second);
|
||||
x.insert(std::make_pair(first, second));
|
||||
--number;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MODE_WRITE:
|
||||
case MODE_MEASURE:
|
||||
case MODE_VERIFY:
|
||||
{
|
||||
typename std::multimap<K, T>::iterator itr = x.begin();
|
||||
while (number > 0)
|
||||
{
|
||||
Do(itr->first);
|
||||
Do(itr->second);
|
||||
--number;
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store vectors.
|
||||
template<class T>
|
||||
void Do(std::vector<T> &x)
|
||||
|
@ -59,8 +59,6 @@
|
||||
|
||||
#include "../Util/PPGeDraw.h"
|
||||
|
||||
extern MetaFileSystem pspFileSystem;
|
||||
|
||||
/*
|
||||
17: [MIPS32 R4K 00000000 ]: Loader: Type: 1 Vaddr: 00000000 Filesz: 2856816 Memsz: 2856816
|
||||
18: [MIPS32 R4K 00000000 ]: Loader: Loadable Segment Copied to 0898dab0, size 002b9770
|
||||
@ -69,6 +67,7 @@ extern MetaFileSystem pspFileSystem;
|
||||
*/
|
||||
|
||||
static bool kernelRunning = false;
|
||||
KernelObjectPool kernelObjects;
|
||||
|
||||
void __KernelInit()
|
||||
{
|
||||
@ -140,13 +139,19 @@ void __KernelShutdown()
|
||||
|
||||
void __KernelDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(kernelRunning);
|
||||
kernelObjects.DoState(p);
|
||||
p.DoMarker("KernelObjects");
|
||||
// TODO
|
||||
// modules
|
||||
// core timing
|
||||
// memstick
|
||||
// filesystem
|
||||
|
||||
// TODO: Put these in the correct order...
|
||||
__KernelAlarmDoState(p);
|
||||
__KernelEventFlagDoState(p);
|
||||
__KernelMbxDoState(p);
|
||||
__KernelMemoryDoState(p);
|
||||
__KernelModuleDoState(p);
|
||||
__KernelMutexDoState(p);
|
||||
__KernelSemaDoState(p);
|
||||
// TODO: more modules
|
||||
}
|
||||
|
||||
bool __KernelIsRunning() {
|
||||
@ -232,8 +237,6 @@ void sceKernelDcacheWritebackInvalidateAll()
|
||||
gpu->InvalidateCache(0, -1);
|
||||
}
|
||||
|
||||
KernelObjectPool kernelObjects;
|
||||
|
||||
KernelObjectPool::KernelObjectPool()
|
||||
{
|
||||
memset(occupied, 0, sizeof(bool)*maxCount);
|
||||
|
@ -111,6 +111,13 @@ void __KernelAlarmInit()
|
||||
alarmTimer = CoreTiming::RegisterEvent("Alarm", __KernelTriggerAlarm);
|
||||
}
|
||||
|
||||
void __KernelAlarmDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(alarmTimer);
|
||||
CoreTiming::RestoreRegisterEvent(alarmTimer, "Alarm", __KernelTriggerAlarm);
|
||||
p.DoMarker("sceKernelAlarm");
|
||||
}
|
||||
|
||||
KernelObject *__KernelAlarmObject()
|
||||
{
|
||||
// Default object to load from state.
|
||||
|
@ -23,4 +23,5 @@ int sceKernelCancelAlarm(SceUID uid);
|
||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr);
|
||||
|
||||
void __KernelAlarmInit();
|
||||
void __KernelAlarmDoState(PointerWrap &p);
|
||||
KernelObject *__KernelAlarmObject();
|
||||
|
@ -101,7 +101,14 @@ int eventFlagWaitTimer = 0;
|
||||
|
||||
void __KernelEventFlagInit()
|
||||
{
|
||||
eventFlagWaitTimer = CoreTiming::RegisterEvent("EventFlagTimeout", &__KernelEventFlagTimeout);
|
||||
eventFlagWaitTimer = CoreTiming::RegisterEvent("EventFlagTimeout", __KernelEventFlagTimeout);
|
||||
}
|
||||
|
||||
void __KernelEventFlagDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(eventFlagWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(eventFlagWaitTimer, "EventFlagTimeout", __KernelEventFlagTimeout);
|
||||
p.DoMarker("sceKernelEventFlag");
|
||||
}
|
||||
|
||||
KernelObject *__KernelEventFlagObject()
|
||||
|
@ -28,4 +28,5 @@ u32 sceKernelReferEventFlagStatus(SceUID id, u32 statusPtr);
|
||||
u32 sceKernelCancelEventFlag(SceUID uid, u32 pattern, u32 numWaitThreadsPtr);
|
||||
|
||||
void __KernelEventFlagInit();
|
||||
void __KernelEventFlagDoState(PointerWrap &p);
|
||||
KernelObject *__KernelEventFlagObject();
|
||||
|
@ -167,7 +167,14 @@ struct Mbx : public KernelObject
|
||||
|
||||
void __KernelMbxInit()
|
||||
{
|
||||
mbxWaitTimer = CoreTiming::RegisterEvent("MbxTimeout", &__KernelMbxTimeout);
|
||||
mbxWaitTimer = CoreTiming::RegisterEvent("MbxTimeout", __KernelMbxTimeout);
|
||||
}
|
||||
|
||||
void __KernelMbxDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mbxWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(mbxWaitTimer, "MbxTimeout", __KernelMbxTimeout);
|
||||
p.DoMarker("sceKernelMbx");
|
||||
}
|
||||
|
||||
KernelObject *__KernelMbxObject()
|
||||
|
@ -34,4 +34,5 @@ int sceKernelCancelReceiveMbx(SceUID id, u32 numWaitingThreadsAddr);
|
||||
int sceKernelReferMbxStatus(SceUID id, u32 infoAddr);
|
||||
|
||||
void __KernelMbxInit();
|
||||
void __KernelMbxDoState(PointerWrap &p);
|
||||
KernelObject *__KernelMbxObject();
|
||||
|
@ -135,6 +135,13 @@ void __KernelMemoryInit()
|
||||
INFO_LOG(HLE, "Kernel and user memory pools initialized");
|
||||
}
|
||||
|
||||
void __KernelMemoryDoState(PointerWrap &p)
|
||||
{
|
||||
kernelMemory.DoState(p);
|
||||
userMemory.DoState(p);
|
||||
p.DoMarker("sceKernelMemory");
|
||||
}
|
||||
|
||||
void __KernelMemoryShutdown()
|
||||
{
|
||||
INFO_LOG(HLE,"Shutting down user memory pool: ");
|
||||
|
@ -30,6 +30,7 @@ extern BlockAllocator userMemory;
|
||||
extern BlockAllocator kernelMemory;
|
||||
|
||||
void __KernelMemoryInit();
|
||||
void __KernelMemoryDoState(PointerWrap &p);
|
||||
void __KernelMemoryShutdown();
|
||||
KernelObject *__KernelMemoryFPLObject();
|
||||
KernelObject *__KernelMemoryVPLObject();
|
||||
|
@ -172,6 +172,12 @@ static SceUID mainModuleID; // hack
|
||||
// STATE END
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void __KernelModuleDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mainModuleID);
|
||||
p.DoMarker("sceKernelModule");
|
||||
}
|
||||
|
||||
Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *error_string)
|
||||
{
|
||||
Module *module = new Module;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "HLE.h"
|
||||
|
||||
KernelObject *__KernelModuleObject();
|
||||
void __KernelModuleDoState(PointerWrap &p);
|
||||
|
||||
u32 __KernelGetModuleGP(SceUID module);
|
||||
bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param, std::string *error_string);
|
||||
|
@ -131,12 +131,22 @@ static MutexMap mutexHeldLocks;
|
||||
|
||||
void __KernelMutexInit()
|
||||
{
|
||||
mutexWaitTimer = CoreTiming::RegisterEvent("MutexTimeout", &__KernelMutexTimeout);
|
||||
lwMutexWaitTimer = CoreTiming::RegisterEvent("LwMutexTimeout", &__KernelLwMutexTimeout);
|
||||
mutexWaitTimer = CoreTiming::RegisterEvent("MutexTimeout", __KernelMutexTimeout);
|
||||
lwMutexWaitTimer = CoreTiming::RegisterEvent("LwMutexTimeout", __KernelLwMutexTimeout);
|
||||
|
||||
__KernelListenThreadEnd(&__KernelMutexThreadEnd);
|
||||
}
|
||||
|
||||
void __KernelMutexDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(mutexWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(mutexWaitTimer, "MutexTimeout", __KernelMutexTimeout);
|
||||
p.Do(lwMutexWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(lwMutexWaitTimer, "LwMutexTimeout", __KernelLwMutexTimeout);
|
||||
p.Do(mutexHeldLocks);
|
||||
p.DoMarker("sceKernelMutex");
|
||||
}
|
||||
|
||||
KernelObject *__KernelMutexObject()
|
||||
{
|
||||
return new Mutex;
|
||||
|
@ -37,6 +37,7 @@ void __KernelLwMutexTimeout(u64 userdata, int cyclesLate);
|
||||
void __KernelMutexThreadEnd(SceUID thread);
|
||||
|
||||
void __KernelMutexInit();
|
||||
void __KernelMutexDoState(PointerWrap &p);
|
||||
void __KernelMutexShutdown();
|
||||
KernelObject *__KernelMutexObject();
|
||||
KernelObject *__KernelLwMutexObject();
|
||||
|
@ -72,7 +72,14 @@ static int semaWaitTimer = 0;
|
||||
|
||||
void __KernelSemaInit()
|
||||
{
|
||||
semaWaitTimer = CoreTiming::RegisterEvent("SemaphoreTimeout", &__KernelSemaTimeout);
|
||||
semaWaitTimer = CoreTiming::RegisterEvent("SemaphoreTimeout", __KernelSemaTimeout);
|
||||
}
|
||||
|
||||
void __KernelSemaDoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(semaWaitTimer);
|
||||
CoreTiming::RestoreRegisterEvent(semaWaitTimer, "SemaphoreTimeout", __KernelSemaTimeout);
|
||||
p.DoMarker("sceKernelSema");
|
||||
}
|
||||
|
||||
KernelObject *__KernelSemaphoreObject()
|
||||
|
@ -29,4 +29,5 @@ int sceKernelWaitSemaCB(SceUID semaid, int signal, u32 timeoutPtr);
|
||||
void __KernelSemaTimeout(u64 userdata, int cycleslate);
|
||||
|
||||
void __KernelSemaInit();
|
||||
void __KernelSemaDoState(PointerWrap &p);
|
||||
KernelObject *__KernelSemaphoreObject();
|
||||
|
Loading…
Reference in New Issue
Block a user