Add basic state for the memory kernel objects.

Not the actual memory partitions quite yet.
This commit is contained in:
Unknown W. Brackets 2012-12-26 21:07:29 -08:00
parent 991243fffd
commit d9efdf548b
4 changed files with 65 additions and 6 deletions

View File

@ -31,6 +31,7 @@
#include <vector>
#include <deque>
#include <string>
#include <list>
#include "Common.h"
#include "FileUtil.h"
@ -134,6 +135,25 @@ public:
DoVoid(&x[i],sizeof(T));
}
// Store STL lists.
template<class T>
void Do(std::list<T> &x)
{
T dv;
Do(x, dv);
}
template<class T>
void Do(std::list<T> &x, T &default_val)
{
u32 list_size = (u32)x.size();
x.resize(list_size, default_val);
typename std::list<T>::iterator itr, end;
for (itr = x.begin(), end = x.end(); itr != end; ++itr)
Do(*itr);
}
// Store strings.
void Do(std::string &x)
{

View File

@ -59,9 +59,6 @@ struct FPL : KernelObject
const char *GetTypeName() {return "FPL";}
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_FPLID; }
int GetIDType() const { return SCE_KERNEL_TMID_Fpl; }
NativeFPL nf;
bool *blocks;
u32 address;
int findFreeBlock() {
for (int i = 0; i < nf.numBlocks; i++) {
@ -85,6 +82,18 @@ struct FPL : KernelObject
}
return false;
}
virtual void DoState(PointerWrap &p)
{
p.Do(nf);
p.DoArray(blocks, nf.numBlocks);
p.Do(address);
p.DoMarker("FPL");
}
NativeFPL nf;
bool *blocks;
u32 address;
};
struct SceKernelVplInfo
@ -103,9 +112,18 @@ struct VPL : KernelObject
const char *GetTypeName() {return "VPL";}
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_VPLID; }
int GetIDType() const { return SCE_KERNEL_TMID_Vpl; }
virtual void DoState(PointerWrap &p)
{
p.Do(nv);
p.Do(size);
p.Do(address);
alloc.DoState(p);
p.DoMarker("VPL");
}
SceKernelVplInfo nv;
u32 size;
bool *freeBlocks;
u32 address;
BlockAllocator alloc;
};
@ -364,6 +382,14 @@ public:
}
bool IsValid() {return address != (u32)-1;}
BlockAllocator *alloc;
virtual void DoState(PointerWrap &p)
{
p.Do(address);
p.Do(name);
p.DoMarker("PMB");
}
u32 address;
char name[32];
};

View File

@ -297,3 +297,13 @@ u32 BlockAllocator::GetTotalFreeBytes()
}
return sum;
}
void BlockAllocator::DoState(PointerWrap &p)
{
Block default_value(0, 0, false);
p.Do(blocks, default_value);
p.Do(rangeStart_);
p.Do(rangeSize_);
p.Do(grain_);
p.DoMarker("BlockAllocator");
}

View File

@ -2,6 +2,7 @@
#pragma once
#include "../../Globals.h"
#include "../../Common/ChunkFile.h"
#include <vector>
#include <list>
@ -42,6 +43,8 @@ public:
u32 GetLargestFreeBlockSize();
u32 GetTotalFreeBytes();
void DoState(PointerWrap &p);
private:
void CheckBlocks();