Initial state saving for kernelObjects.

This commit is contained in:
Unknown W. Brackets 2012-12-26 20:15:31 -08:00
parent 75ce287213
commit a2f4c83c90
2 changed files with 43 additions and 4 deletions

View File

@ -136,6 +136,18 @@ void __KernelShutdown()
kernelRunning = false;
}
void __KernelDoState(PointerWrap &p)
{
kernelObjects.DoState(p);
p.DoMarker("KernelObjects");
// TODO
// kernelObjects
// modules
// core timing
// memstick
// filesystem
}
bool __KernelIsRunning() {
return kernelRunning;
}
@ -304,6 +316,29 @@ int KernelObjectPool::GetCount()
return count;
}
void KernelObjectPool::DoState(PointerWrap &p)
{
int _maxCount = maxCount;
p.Do(_maxCount);
p.DoArray(occupied, maxCount);
for (int i = 0; i < maxCount; ++i)
{
if (!occupied[i])
continue;
KernelObject *t = pool[i];
if (!t)
{
// TODO: Pass down error?
ERROR_LOG(HLE, "Unable to save state: inconsistent kernel object pool.");
return;
}
t->DoState(p);
}
p.DoMarker("KernelObjectPool");
}
void sceKernelIcacheInvalidateAll()
{
DEBUG_LOG(CPU, "Icache invalidated - should clear JIT someday");

View File

@ -18,6 +18,7 @@
#pragma once
#include "../../Globals.h"
#include "../../Common/ChunkFile.h"
#include <cstring>
enum
@ -263,6 +264,7 @@ struct SceKernelLoadExecParam
void __KernelInit();
void __KernelShutdown();
void __KernelDoState(PointerWrap &p);
bool __KernelIsRunning();
bool __KernelLoadExec(const char *filename, SceKernelLoadExecParam *param);
@ -311,9 +313,11 @@ public:
// Implement this in all subclasses:
// static u32 GetMissingErrorCode()
// Future
// void Serialize(ChunkFile)
// void DeSerialize(ChunkFile)
virtual void DoState(PointerWrap &p)
{
// TODO
//_dbg_assert_msg_(HLE, false, "Bad kernel object");
}
};
@ -325,7 +329,7 @@ public:
// Allocates a UID within the range and inserts the object into the map.
SceUID Create(KernelObject *obj, int rangeBottom = 16, int rangeTop = 0x7fffffff);
// TODO: How will we ever save/restore this pool?
void DoState(PointerWrap &p);
template <class T>
u32 Destroy(SceUID handle)