mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-25 09:09:49 +00:00
Add basic DoState() to tertiary kernel objects.
This commit is contained in:
parent
a2f4c83c90
commit
991243fffd
@ -315,8 +315,7 @@ public:
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
// TODO
|
||||
//_dbg_assert_msg_(HLE, false, "Bad kernel object");
|
||||
_dbg_assert_msg_(HLE, false, "Unable to save state: bad kernel object.");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,6 +37,13 @@ struct Alarm : public KernelObject
|
||||
const char *GetTypeName() {return "Alarm";}
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_ALMID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Alarm; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(alm);
|
||||
p.DoMarker("Alarm");
|
||||
}
|
||||
|
||||
NativeAlarm alm;
|
||||
};
|
||||
|
||||
@ -47,7 +54,7 @@ class AlarmIntrHandler : public SubIntrHandler
|
||||
public:
|
||||
AlarmIntrHandler(Alarm *alarm)
|
||||
{
|
||||
this->alarm = alarm;
|
||||
alarmID = alarm->GetUID();
|
||||
handlerAddress = alarm->alm.handlerPtr;
|
||||
enabled = true;
|
||||
}
|
||||
@ -56,26 +63,35 @@ public:
|
||||
{
|
||||
SubIntrHandler::copyArgsToCPU(pend);
|
||||
|
||||
currentMIPS->r[MIPS_REG_A0] = alarm->alm.commonPtr;
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
if (alarm)
|
||||
currentMIPS->r[MIPS_REG_A0] = alarm->alm.commonPtr;
|
||||
else
|
||||
ERROR_LOG(HLE, "sceKernelAlarm: Unable to send interrupt args: alarm deleted?");
|
||||
}
|
||||
|
||||
virtual void handleResult(int result)
|
||||
{
|
||||
// A non-zero result means to reschedule.
|
||||
if (result > 0)
|
||||
{
|
||||
u32 error;
|
||||
Alarm *alarm = kernelObjects.Get<Alarm>(alarmID, error);
|
||||
__KernelScheduleAlarm(alarm, (u64) usToCycles(result));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result < 0)
|
||||
WARN_LOG(HLE, "Alarm requested reschedule for negative value %u, ignoring", (unsigned) result);
|
||||
|
||||
// Delete the alarm if it's not rescheduled.
|
||||
__ReleaseSubInterruptHandler(PSP_SYSTIMER0_INTR, alarm->GetUID());
|
||||
kernelObjects.Destroy<Alarm>(alarm->GetUID());
|
||||
kernelObjects.Destroy<Alarm>(alarmID);
|
||||
__ReleaseSubInterruptHandler(PSP_SYSTIMER0_INTR, alarmID);
|
||||
}
|
||||
}
|
||||
|
||||
Alarm *alarm;
|
||||
SceUID alarmID;
|
||||
};
|
||||
|
||||
static int alarmTimer = 0;
|
||||
|
@ -63,6 +63,13 @@ public:
|
||||
}
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_EventFlag; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nef);
|
||||
p.Do(waitingThreads);
|
||||
p.DoMarker("EventFlag");
|
||||
}
|
||||
|
||||
NativeEventFlag nef;
|
||||
std::vector<EventFlagTh> waitingThreads;
|
||||
};
|
||||
|
@ -153,6 +153,13 @@ struct Mbx : public KernelObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nmb);
|
||||
p.Do(waitingThreads);
|
||||
p.DoMarker("Mbx");
|
||||
}
|
||||
|
||||
NativeMbx nmb;
|
||||
|
||||
std::vector<MbxWaitingThread> waitingThreads;
|
||||
|
@ -56,11 +56,6 @@ struct MsgPipe : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_MPPID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Mpipe; }
|
||||
|
||||
NativeMsgPipe nmp;
|
||||
|
||||
std::vector<MsgPipeWaitingThread> sendWaitingThreads;
|
||||
std::vector<MsgPipeWaitingThread> receiveWaitingThreads;
|
||||
|
||||
void AddWaitingThread(std::vector<MsgPipeWaitingThread> &list, SceUID id, u32 addr, u32 size, int waitMode, u32 transferredBytesAddr, bool usePrio)
|
||||
{
|
||||
MsgPipeWaitingThread thread = { id, addr, size, size, waitMode, transferredBytesAddr };
|
||||
@ -150,6 +145,20 @@ struct MsgPipe : public KernelObject
|
||||
}
|
||||
}
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nmp);
|
||||
p.Do(sendWaitingThreads);
|
||||
p.Do(receiveWaitingThreads);
|
||||
p.DoArray(buffer, nmp.bufSize);
|
||||
p.DoMarker("MsgPipe");
|
||||
}
|
||||
|
||||
NativeMsgPipe nmp;
|
||||
|
||||
std::vector<MsgPipeWaitingThread> sendWaitingThreads;
|
||||
std::vector<MsgPipeWaitingThread> receiveWaitingThreads;
|
||||
|
||||
u8 *buffer;
|
||||
};
|
||||
|
||||
|
@ -62,6 +62,14 @@ struct Mutex : public KernelObject
|
||||
const char *GetTypeName() {return "Mutex";}
|
||||
static u32 GetMissingErrorCode() { return PSP_MUTEX_ERROR_NO_SUCH_MUTEX; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Mutex; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nm);
|
||||
p.Do(waitingThreads);
|
||||
p.DoMarker("Mutex");
|
||||
}
|
||||
|
||||
NativeMutex nm;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
@ -103,6 +111,14 @@ struct LwMutex : public KernelObject
|
||||
const char *GetTypeName() {return "LwMutex";}
|
||||
static u32 GetMissingErrorCode() { return PSP_LWMUTEX_ERROR_NO_SUCH_LWMUTEX; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_LwMutex; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(nm);
|
||||
p.Do(waitingThreads);
|
||||
p.DoMarker("LwMutex");
|
||||
}
|
||||
|
||||
NativeLwMutex nm;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
|
@ -57,6 +57,13 @@ struct Semaphore : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_SEMID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_Semaphore; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(ns);
|
||||
p.Do(waitingThreads);
|
||||
p.DoMarker("Semaphore");
|
||||
}
|
||||
|
||||
NativeSemaphore ns;
|
||||
std::vector<SceUID> waitingThreads;
|
||||
};
|
||||
|
@ -30,6 +30,18 @@ struct VTimer : public KernelObject
|
||||
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_VTID; }
|
||||
int GetIDType() const { return SCE_KERNEL_TMID_VTimer; }
|
||||
|
||||
virtual void DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(size);
|
||||
p.Do(name);
|
||||
p.Do(startTime);
|
||||
p.Do(running);
|
||||
p.Do(handler);
|
||||
p.Do(handlerTime);
|
||||
p.Do(argument);
|
||||
p.DoMarker("VTimer");
|
||||
}
|
||||
|
||||
SceSize size;
|
||||
char name[KERNELOBJECT_MAX_NAME_LENGTH+1];
|
||||
u64 startTime;
|
||||
|
Loading…
Reference in New Issue
Block a user