Fixed value returning for MBXes

This commit is contained in:
Arthur Blot 2012-11-08 16:24:06 +01:00
parent b96d86ab7f
commit 35c7b411aa
4 changed files with 30 additions and 21 deletions

View File

@ -66,6 +66,10 @@ template<int func(int, u32)> void WrapI_IU() {
RETURN(retval);
}
template<void func(int, u32)> void WrapV_IU() {
func(PARAM(0), PARAM(1));
}
template<int func(const char *, u32)> void WrapI_CU() {
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1));
RETURN(retval);
@ -86,9 +90,8 @@ template<u32 func(u32, u32, u32)> void WrapU_UUU() {
RETURN(retval);
}
template<int func(int, u32, u32)> void WrapI_IUU() {
int retval = func(PARAM(0), PARAM(1), PARAM(2));
RETURN(retval);
template<void func(int, u32, u32)> void WrapV_IUU() {
func(PARAM(0), PARAM(1), PARAM(2));
}
template<void func(u32, u32, u32)> void WrapV_UUU() {

View File

@ -389,9 +389,9 @@ const HLEFunction ThreadManForUser[] =
{0x8125221D,&WrapU_CIUIU<sceKernelCreateMbx>,"sceKernelCreateMbx"},
{0x86255ADA,&WrapI_I<sceKernelDeleteMbx>,"sceKernelDeleteMbx"},
{0xE9B3061E,&WrapI_IU<sceKernelSendMbx>,"sceKernelSendMbx"},
{0x18260574,&WrapI_IUU<sceKernelReceiveMbx>,"sceKernelReceiveMbx"},
{0xF3986382,&WrapI_IUU<sceKernelReceiveMbxCB>,"sceKernelReceiveMbxCB"},
{0xE9B3061E,&WrapV_IU<sceKernelSendMbx>,"sceKernelSendMbx"},
{0x18260574,&WrapV_IUU<sceKernelReceiveMbx>,"sceKernelReceiveMbx"},
{0xF3986382,&WrapV_IUU<sceKernelReceiveMbxCB>,"sceKernelReceiveMbxCB"},
{0x0D81716A,&WrapI_IU<sceKernelPollMbx>,"sceKernelPollMbx"},
{0x87D4DD36,&WrapI_IU<sceKernelCancelReceiveMbx>,"sceKernelCancelReceiveMbx"},
{0xA8E8C846,&WrapI_IU<sceKernelReferMbxStatus>,"sceKernelReferMbxStatus"},

View File

@ -90,7 +90,7 @@ int sceKernelDeleteMbx(SceUID id)
return kernelObjects.Destroy<Mbx>(id);
}
int sceKernelSendMbx(SceUID id, u32 packetAddr)
void sceKernelSendMbx(SceUID id, u32 packetAddr)
{
u32 error;
Mbx *m = kernelObjects.Get<Mbx>(id, error);
@ -98,13 +98,15 @@ int sceKernelSendMbx(SceUID id, u32 packetAddr)
if (addPacket == 0)
{
ERROR_LOG(HLE, "sceKernelSendMbx(%i, %08x): invalid packet address", id, packetAddr);
return -1;
RETURN(-1);
return;
}
if (!m)
{
ERROR_LOG(HLE, "sceKernelSendMbx(%i, %08x): invalid mbx id", id, packetAddr);
return error;
RETURN(error);
return;
}
if (m->waitingThreads.empty())
@ -126,6 +128,7 @@ int sceKernelSendMbx(SceUID id, u32 packetAddr)
{
m->messageQueue.push_back(packetAddr);
}
RETURN(0);
}
else if (m->messageQueue.empty())
{
@ -133,16 +136,17 @@ int sceKernelSendMbx(SceUID id, u32 packetAddr)
__KernelResumeThreadFromWait(m->waitingThreads.front().first);
DEBUG_LOG(HLE, "sceKernelSendMbx(%i, %08x): threads waiting, resuming %d", id, packetAddr, m->waitingThreads.front().first);
m->waitingThreads.erase(m->waitingThreads.begin());
RETURN(0);
__KernelReSchedule();
}
else
{
ERROR_LOG(HLE, "sceKernelSendMbx(%i, %08x): WTF!? thread waiting while there is a message in the queue?", id, packetAddr);
RETURN(-1);
}
return 0;
}
int sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
void sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
{
u32 error;
Mbx *m = kernelObjects.Get<Mbx>(id, error);
@ -150,7 +154,8 @@ int sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
if (!m)
{
ERROR_LOG(HLE, "sceKernelReceiveMbx(%i, %08x, %08x): invalid mbx id", id, packetAddrPtr, timeoutPtr);
return error;
RETURN(error);
return;
}
if (!m->messageQueue.empty())
@ -158,18 +163,18 @@ int sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
DEBUG_LOG(HLE, "sceKernelReceiveMbx(%i, %08x, %08x): sending first queue message", id, packetAddrPtr, timeoutPtr);
Memory::Write_U32(m->messageQueue.front(), packetAddrPtr);
m->messageQueue.erase(m->messageQueue.begin());
RETURN(0);
}
else
{
DEBUG_LOG(HLE, "sceKernelReceiveMbx(%i, %08x, %08x): no message in queue, waiting", id, packetAddrPtr, timeoutPtr);
m->AddWaitingThread(__KernelGetCurThread(), packetAddrPtr);
RETURN(0);
__KernelWaitCurThread(WAITTYPE_MBX, 0, 0, 0, false); // ?
}
return 0;
}
int sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
void sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
{
u32 error;
Mbx *m = kernelObjects.Get<Mbx>(id, error);
@ -178,7 +183,8 @@ int sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
if (!m)
{
ERROR_LOG(HLE, "sceKernelReceiveMbxCB(%i, %08x, %08x): invalid mbx id", id, packetAddrPtr, timeoutPtr);
return error;
RETURN(error);
return;
}
if (!m->messageQueue.empty())
@ -186,15 +192,15 @@ int sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr)
DEBUG_LOG(HLE, "sceKernelReceiveMbxCB(%i, %08x, %08x): sending first queue message", id, packetAddrPtr, timeoutPtr);
Memory::Write_U32(m->messageQueue.front(), packetAddrPtr);
m->messageQueue.erase(m->messageQueue.begin());
RETURN(0);
}
else
{
DEBUG_LOG(HLE, "sceKernelReceiveMbxCB(%i, %08x, %08x): no message in queue, waiting", id, packetAddrPtr, timeoutPtr);
m->AddWaitingThread(id, packetAddrPtr);
RETURN(0);
__KernelWaitCurThread(WAITTYPE_MBX, 0, 0, 0, true); // ?
}
return 0;
}
int sceKernelPollMbx(SceUID id, u32 packetAddrPtr)

View File

@ -36,9 +36,9 @@ struct SceKernelMbxInfo
SceUID sceKernelCreateMbx(const char *name, int memoryPartition, SceUInt attr, int size, u32 optAddr);
int sceKernelDeleteMbx(SceUID id);
int sceKernelSendMbx(SceUID id, u32 addPacketAddr);
int sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr);
int sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr);
void sceKernelSendMbx(SceUID id, u32 addPacketAddr);
void sceKernelReceiveMbx(SceUID id, u32 packetAddrPtr, u32 timeoutPtr);
void sceKernelReceiveMbxCB(SceUID id, u32 packetAddrPtr, u32 timeoutPtr);
int sceKernelPollMbx(SceUID id, u32 packetAddrPtr);
int sceKernelCancelReceiveMbx(SceUID id, u32 numWaitingThreadsAddr);
int sceKernelReferMbxStatus(SceUID id, u32 infoAddr);