diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 9f7eb958bf..2d516f8704 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1373,7 +1373,7 @@ void thread_t::set_name(const std::string& name) thread_t::~thread_t() { - if (m_state == TS_JOINABLE) + if (m_state.exchange(TS_NON_EXISTENT) == TS_JOINABLE) { if (m_autojoin) { diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp index 0d1c9baf29..49f07e5509 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.cpp @@ -15,7 +15,7 @@ #define RETURN_ERROR(code) { Emu.Pause(); sceLibKernel.Error("%s() failed: %s", __FUNCTION__, #code); return code; } -s32 sceKernelAllocMemBlock(vm::psv::ptr name, s32 type, u32 vsize, vm::psv::ptr pOpt) +s32 sceKernelAllocMemBlock(vm::ptr name, s32 type, u32 vsize, vm::ptr pOpt) { throw __FUNCTION__; } @@ -25,24 +25,24 @@ s32 sceKernelFreeMemBlock(s32 uid) throw __FUNCTION__; } -s32 sceKernelGetMemBlockBase(s32 uid, vm::psv::pptr ppBase) +s32 sceKernelGetMemBlockBase(s32 uid, vm::pptr ppBase) { throw __FUNCTION__; } -s32 sceKernelGetMemBlockInfoByAddr(vm::psv::ptr vbase, vm::psv::ptr pInfo) +s32 sceKernelGetMemBlockInfoByAddr(vm::ptr vbase, vm::ptr pInfo) { throw __FUNCTION__; } s32 sceKernelCreateThread( - vm::psv::ptr pName, - vm::psv::ptr entry, + vm::ptr pName, + vm::ptr entry, s32 initPriority, u32 stackSize, u32 attr, s32 cpuAffinityMask, - vm::psv::ptr pOptParam) + vm::ptr pOptParam) { sceLibKernel.Warning("sceKernelCreateThread(pName=*0x%x, entry=*0x%x, initPriority=%d, stackSize=0x%x, attr=0x%x, cpuAffinityMask=0x%x, pOptParam=*0x%x)", pName, entry, initPriority, stackSize, attr, cpuAffinityMask, pOptParam); @@ -60,7 +60,7 @@ s32 sceKernelCreateThread( return armv7.GetId(); } -s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr pArgBlock) +s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::ptr pArgBlock) { sceLibKernel.Warning("sceKernelStartThread(threadId=0x%x, argSize=0x%x, pArgBlock=*0x%x)", threadId, argSize, pArgBlock); @@ -183,7 +183,7 @@ s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr) throw __FUNCTION__; } -s32 sceKernelGetThreadExitStatus(s32 threadId, vm::psv::ptr pExitStatus) +s32 sceKernelGetThreadExitStatus(s32 threadId, vm::ptr pExitStatus) { sceLibKernel.Todo("sceKernelGetThreadExitStatus(threadId=0x%x, pExitStatus=*0x%x)", threadId, pExitStatus); @@ -204,21 +204,21 @@ s32 sceKernelCheckWaitableStatus() throw __FUNCTION__; } -s32 sceKernelGetThreadInfo(s32 threadId, vm::psv::ptr pInfo) +s32 sceKernelGetThreadInfo(s32 threadId, vm::ptr pInfo) { sceLibKernel.Todo("sceKernelGetThreadInfo(threadId=0x%x, pInfo=*0x%x)", threadId, pInfo); throw __FUNCTION__; } -s32 sceKernelGetThreadRunStatus(vm::psv::ptr pStatus) +s32 sceKernelGetThreadRunStatus(vm::ptr pStatus) { sceLibKernel.Todo("sceKernelGetThreadRunStatus(pStatus=*0x%x)", pStatus); throw __FUNCTION__; } -s32 sceKernelGetSystemInfo(vm::psv::ptr pInfo) +s32 sceKernelGetSystemInfo(vm::ptr pInfo) { sceLibKernel.Todo("sceKernelGetSystemInfo(pInfo=*0x%x)", pInfo); @@ -260,7 +260,7 @@ s32 sceKernelDelayThreadCB(u32 usec) throw __FUNCTION__; } -s32 sceKernelWaitThreadEnd(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEnd(s32 threadId, vm::ptr pExitStatus, vm::ptr pTimeout) { sceLibKernel.Warning("sceKernelWaitThreadEnd(threadId=0x%x, pExitStatus=*0x%x, pTimeout=*0x%x)", threadId, pExitStatus, pTimeout); @@ -295,7 +295,7 @@ s32 sceKernelWaitThreadEnd(s32 threadId, vm::psv::ptr pExitStatus, vm::psv: return SCE_OK; } -s32 sceKernelWaitThreadEndCB(s32 threadId, vm::psv::ptr pExitStatus, vm::psv::ptr pTimeout) +s32 sceKernelWaitThreadEndCB(s32 threadId, vm::ptr pExitStatus, vm::ptr pTimeout) { sceLibKernel.Todo("sceKernelWaitThreadEndCB(threadId=0x%x, pExitStatus=*0x%x, pTimeout=*0x%x)", threadId, pExitStatus, pTimeout); @@ -304,7 +304,7 @@ s32 sceKernelWaitThreadEndCB(s32 threadId, vm::psv::ptr pExitStatus, vm::ps // Callback functions -s32 sceKernelCreateCallback(vm::psv::ptr pName, u32 attr, vm::psv::ptr callbackFunc, vm::psv::ptr pCommon) +s32 sceKernelCreateCallback(vm::ptr pName, u32 attr, vm::ptr callbackFunc, vm::ptr pCommon) { throw __FUNCTION__; } @@ -334,7 +334,7 @@ s32 sceKernelCheckCallback() throw __FUNCTION__; } -s32 sceKernelGetCallbackInfo(s32 callbackId, vm::psv::ptr pInfo) +s32 sceKernelGetCallbackInfo(s32 callbackId, vm::ptr pInfo) { throw __FUNCTION__; } @@ -356,44 +356,44 @@ s32 sceKernelUnregisterCallbackFromEventAll(s32 eventId) // Event functions -s32 sceKernelWaitEvent(s32 eventId, u32 waitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData, vm::psv::ptr pTimeout) +s32 sceKernelWaitEvent(s32 eventId, u32 waitPattern, vm::ptr pResultPattern, vm::ptr pUserData, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelWaitEventCB(s32 eventId, u32 waitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData, vm::psv::ptr pTimeout) +s32 sceKernelWaitEventCB(s32 eventId, u32 waitPattern, vm::ptr pResultPattern, vm::ptr pUserData, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelPollEvent(s32 eventId, u32 bitPattern, vm::psv::ptr pResultPattern, vm::psv::ptr pUserData) +s32 sceKernelPollEvent(s32 eventId, u32 bitPattern, vm::ptr pResultPattern, vm::ptr pUserData) { throw __FUNCTION__; } -s32 sceKernelCancelEvent(s32 eventId, vm::psv::ptr pNumWaitThreads) +s32 sceKernelCancelEvent(s32 eventId, vm::ptr pNumWaitThreads) { throw __FUNCTION__; } -s32 sceKernelGetEventInfo(s32 eventId, vm::psv::ptr pInfo) +s32 sceKernelGetEventInfo(s32 eventId, vm::ptr pInfo) { throw __FUNCTION__; } -s32 sceKernelWaitMultipleEvents(vm::psv::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::psv::ptr pResultEventList, vm::psv::ptr pTimeout) +s32 sceKernelWaitMultipleEvents(vm::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::ptr pResultEventList, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelWaitMultipleEventsCB(vm::psv::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::psv::ptr pResultEventList, vm::psv::ptr pTimeout) +s32 sceKernelWaitMultipleEventsCB(vm::ptr pWaitEventList, s32 numEvents, u32 waitMode, vm::ptr pResultEventList, vm::ptr pTimeout) { throw __FUNCTION__; } // Event flag functions -s32 sceKernelCreateEventFlag(vm::psv::ptr pName, u32 attr, u32 initPattern, vm::psv::ptr pOptParam) +s32 sceKernelCreateEventFlag(vm::ptr pName, u32 attr, u32 initPattern, vm::ptr pOptParam) { sceLibKernel.Error("sceKernelCreateEventFlag(pName=*0x%x, attr=0x%x, initPattern=0x%x, pOptParam=*0x%x)", pName, attr, initPattern, pOptParam); @@ -410,7 +410,7 @@ s32 sceKernelDeleteEventFlag(s32 evfId) throw __FUNCTION__; } -s32 sceKernelOpenEventFlag(vm::psv::ptr pName) +s32 sceKernelOpenEventFlag(vm::ptr pName) { throw __FUNCTION__; } @@ -420,17 +420,17 @@ s32 sceKernelCloseEventFlag(s32 evfId) throw __FUNCTION__; } -s32 sceKernelWaitEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat, vm::psv::ptr pTimeout) +s32 sceKernelWaitEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelWaitEventFlagCB(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat, vm::psv::ptr pTimeout) +s32 sceKernelWaitEventFlagCB(s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelPollEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::psv::ptr pResultPat) +s32 sceKernelPollEventFlag(s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr pResultPat) { throw __FUNCTION__; } @@ -445,19 +445,19 @@ s32 sceKernelClearEventFlag(s32 evfId, u32 bitPattern) throw __FUNCTION__; } -s32 sceKernelCancelEventFlag(s32 evfId, u32 setPattern, vm::psv::ptr pNumWaitThreads) +s32 sceKernelCancelEventFlag(s32 evfId, u32 setPattern, vm::ptr pNumWaitThreads) { throw __FUNCTION__; } -s32 sceKernelGetEventFlagInfo(s32 evfId, vm::psv::ptr pInfo) +s32 sceKernelGetEventFlagInfo(s32 evfId, vm::ptr pInfo) { throw __FUNCTION__; } // Semaphore functions -s32 sceKernelCreateSema(vm::psv::ptr pName, u32 attr, s32 initCount, s32 maxCount, vm::psv::ptr pOptParam) +s32 sceKernelCreateSema(vm::ptr pName, u32 attr, s32 initCount, s32 maxCount, vm::ptr pOptParam) { sceLibKernel.Error("sceKernelCreateSema(pName=*0x%x, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=*0x%x)", pName, attr, initCount, maxCount, pOptParam); @@ -488,7 +488,7 @@ s32 sceKernelDeleteSema(s32 semaId) return SCE_OK; } -s32 sceKernelOpenSema(vm::psv::ptr pName) +s32 sceKernelOpenSema(vm::ptr pName) { throw __FUNCTION__; } @@ -498,7 +498,7 @@ s32 sceKernelCloseSema(s32 semaId) throw __FUNCTION__; } -s32 sceKernelWaitSema(s32 semaId, s32 needCount, vm::psv::ptr pTimeout) +s32 sceKernelWaitSema(s32 semaId, s32 needCount, vm::ptr pTimeout) { sceLibKernel.Error("sceKernelWaitSema(semaId=0x%x, needCount=%d, pTimeout=*0x%x)", semaId, needCount, pTimeout); @@ -514,7 +514,7 @@ s32 sceKernelWaitSema(s32 semaId, s32 needCount, vm::psv::ptr pTimeout) return SCE_OK; } -s32 sceKernelWaitSemaCB(s32 semaId, s32 needCount, vm::psv::ptr pTimeout) +s32 sceKernelWaitSemaCB(s32 semaId, s32 needCount, vm::ptr pTimeout) { throw __FUNCTION__; } @@ -529,19 +529,19 @@ s32 sceKernelSignalSema(s32 semaId, s32 signalCount) throw __FUNCTION__; } -s32 sceKernelCancelSema(s32 semaId, s32 setCount, vm::psv::ptr pNumWaitThreads) +s32 sceKernelCancelSema(s32 semaId, s32 setCount, vm::ptr pNumWaitThreads) { throw __FUNCTION__; } -s32 sceKernelGetSemaInfo(s32 semaId, vm::psv::ptr pInfo) +s32 sceKernelGetSemaInfo(s32 semaId, vm::ptr pInfo) { throw __FUNCTION__; } // Mutex functions -s32 sceKernelCreateMutex(vm::psv::ptr pName, u32 attr, s32 initCount, vm::psv::ptr pOptParam) +s32 sceKernelCreateMutex(vm::ptr pName, u32 attr, s32 initCount, vm::ptr pOptParam) { sceLibKernel.Error("sceKernelCreateMutex(pName=*0x%x, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam); @@ -558,7 +558,7 @@ s32 sceKernelDeleteMutex(s32 mutexId) throw __FUNCTION__; } -s32 sceKernelOpenMutex(vm::psv::ptr pName) +s32 sceKernelOpenMutex(vm::ptr pName) { throw __FUNCTION__; } @@ -568,12 +568,12 @@ s32 sceKernelCloseMutex(s32 mutexId) throw __FUNCTION__; } -s32 sceKernelLockMutex(s32 mutexId, s32 lockCount, vm::psv::ptr pTimeout) +s32 sceKernelLockMutex(s32 mutexId, s32 lockCount, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelLockMutexCB(s32 mutexId, s32 lockCount, vm::psv::ptr pTimeout) +s32 sceKernelLockMutexCB(s32 mutexId, s32 lockCount, vm::ptr pTimeout) { throw __FUNCTION__; } @@ -588,61 +588,61 @@ s32 sceKernelUnlockMutex(s32 mutexId, s32 unlockCount) throw __FUNCTION__; } -s32 sceKernelCancelMutex(s32 mutexId, s32 newCount, vm::psv::ptr pNumWaitThreads) +s32 sceKernelCancelMutex(s32 mutexId, s32 newCount, vm::ptr pNumWaitThreads) { throw __FUNCTION__; } -s32 sceKernelGetMutexInfo(s32 mutexId, vm::psv::ptr pInfo) +s32 sceKernelGetMutexInfo(s32 mutexId, vm::ptr pInfo) { throw __FUNCTION__; } // Lightweight mutex functions -s32 sceKernelCreateLwMutex(vm::psv::ptr pWork, vm::psv::ptr pName, u32 attr, s32 initCount, vm::psv::ptr pOptParam) +s32 sceKernelCreateLwMutex(vm::ptr pWork, vm::ptr pName, u32 attr, s32 initCount, vm::ptr pOptParam) { throw __FUNCTION__; } -s32 sceKernelDeleteLwMutex(vm::psv::ptr pWork) +s32 sceKernelDeleteLwMutex(vm::ptr pWork) { throw __FUNCTION__; } -s32 sceKernelLockLwMutex(vm::psv::ptr pWork, s32 lockCount, vm::psv::ptr pTimeout) +s32 sceKernelLockLwMutex(vm::ptr pWork, s32 lockCount, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelLockLwMutexCB(vm::psv::ptr pWork, s32 lockCount, vm::psv::ptr pTimeout) +s32 sceKernelLockLwMutexCB(vm::ptr pWork, s32 lockCount, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelTryLockLwMutex(vm::psv::ptr pWork, s32 lockCount) +s32 sceKernelTryLockLwMutex(vm::ptr pWork, s32 lockCount) { throw __FUNCTION__; } -s32 sceKernelUnlockLwMutex(vm::psv::ptr pWork, s32 unlockCount) +s32 sceKernelUnlockLwMutex(vm::ptr pWork, s32 unlockCount) { throw __FUNCTION__; } -s32 sceKernelGetLwMutexInfo(vm::psv::ptr pWork, vm::psv::ptr pInfo) +s32 sceKernelGetLwMutexInfo(vm::ptr pWork, vm::ptr pInfo) { throw __FUNCTION__; } -s32 sceKernelGetLwMutexInfoById(s32 lwMutexId, vm::psv::ptr pInfo) +s32 sceKernelGetLwMutexInfoById(s32 lwMutexId, vm::ptr pInfo) { throw __FUNCTION__; } // Condition variable functions -s32 sceKernelCreateCond(vm::psv::ptr pName, u32 attr, s32 mutexId, vm::psv::ptr pOptParam) +s32 sceKernelCreateCond(vm::ptr pName, u32 attr, s32 mutexId, vm::ptr pOptParam) { sceLibKernel.Error("sceKernelCreateCond(pName=*0x%x, attr=0x%x, mutexId=0x%x, pOptParam=*0x%x)", pName, attr, mutexId, pOptParam); @@ -659,7 +659,7 @@ s32 sceKernelDeleteCond(s32 condId) throw __FUNCTION__; } -s32 sceKernelOpenCond(vm::psv::ptr pName) +s32 sceKernelOpenCond(vm::ptr pName) { throw __FUNCTION__; } @@ -669,12 +669,12 @@ s32 sceKernelCloseCond(s32 condId) throw __FUNCTION__; } -s32 sceKernelWaitCond(s32 condId, vm::psv::ptr pTimeout) +s32 sceKernelWaitCond(s32 condId, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelWaitCondCB(s32 condId, vm::psv::ptr pTimeout) +s32 sceKernelWaitCondCB(s32 condId, vm::ptr pTimeout) { throw __FUNCTION__; } @@ -694,61 +694,61 @@ s32 sceKernelSignalCondTo(s32 condId, s32 threadId) throw __FUNCTION__; } -s32 sceKernelGetCondInfo(s32 condId, vm::psv::ptr pInfo) +s32 sceKernelGetCondInfo(s32 condId, vm::ptr pInfo) { throw __FUNCTION__; } // Lightweight condition variable functions -s32 sceKernelCreateLwCond(vm::psv::ptr pWork, vm::psv::ptr pName, u32 attr, vm::psv::ptr pLwMutex, vm::psv::ptr pOptParam) +s32 sceKernelCreateLwCond(vm::ptr pWork, vm::ptr pName, u32 attr, vm::ptr pLwMutex, vm::ptr pOptParam) { throw __FUNCTION__; } -s32 sceKernelDeleteLwCond(vm::psv::ptr pWork) +s32 sceKernelDeleteLwCond(vm::ptr pWork) { throw __FUNCTION__; } -s32 sceKernelWaitLwCond(vm::psv::ptr pWork, vm::psv::ptr pTimeout) +s32 sceKernelWaitLwCond(vm::ptr pWork, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelWaitLwCondCB(vm::psv::ptr pWork, vm::psv::ptr pTimeout) +s32 sceKernelWaitLwCondCB(vm::ptr pWork, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelSignalLwCond(vm::psv::ptr pWork) +s32 sceKernelSignalLwCond(vm::ptr pWork) { throw __FUNCTION__; } -s32 sceKernelSignalLwCondAll(vm::psv::ptr pWork) +s32 sceKernelSignalLwCondAll(vm::ptr pWork) { throw __FUNCTION__; } -s32 sceKernelSignalLwCondTo(vm::psv::ptr pWork, s32 threadId) +s32 sceKernelSignalLwCondTo(vm::ptr pWork, s32 threadId) { throw __FUNCTION__; } -s32 sceKernelGetLwCondInfo(vm::psv::ptr pWork, vm::psv::ptr pInfo) +s32 sceKernelGetLwCondInfo(vm::ptr pWork, vm::ptr pInfo) { throw __FUNCTION__; } -s32 sceKernelGetLwCondInfoById(s32 lwCondId, vm::psv::ptr pInfo) +s32 sceKernelGetLwCondInfoById(s32 lwCondId, vm::ptr pInfo) { throw __FUNCTION__; } // Time functions -s32 sceKernelGetSystemTime(vm::psv::ptr pClock) +s32 sceKernelGetSystemTime(vm::ptr pClock) { throw __FUNCTION__; } @@ -765,7 +765,7 @@ u32 sceKernelGetSystemTimeLow() // Timer functions -s32 sceKernelCreateTimer(vm::psv::ptr pName, u32 attr, vm::psv::ptr pOptParam) +s32 sceKernelCreateTimer(vm::ptr pName, u32 attr, vm::ptr pOptParam) { throw __FUNCTION__; } @@ -775,7 +775,7 @@ s32 sceKernelDeleteTimer(s32 timerId) throw __FUNCTION__; } -s32 sceKernelOpenTimer(vm::psv::ptr pName) +s32 sceKernelOpenTimer(vm::ptr pName) { throw __FUNCTION__; } @@ -795,7 +795,7 @@ s32 sceKernelStopTimer(s32 timerId) throw __FUNCTION__; } -s32 sceKernelGetTimerBase(s32 timerId, vm::psv::ptr pBase) +s32 sceKernelGetTimerBase(s32 timerId, vm::ptr pBase) { throw __FUNCTION__; } @@ -805,7 +805,7 @@ u64 sceKernelGetTimerBaseWide(s32 timerId) throw __FUNCTION__; } -s32 sceKernelGetTimerTime(s32 timerId, vm::psv::ptr pClock) +s32 sceKernelGetTimerTime(s32 timerId, vm::ptr pClock) { throw __FUNCTION__; } @@ -815,7 +815,7 @@ u64 sceKernelGetTimerTimeWide(s32 timerId) throw __FUNCTION__; } -s32 sceKernelSetTimerTime(s32 timerId, vm::psv::ptr pClock) +s32 sceKernelSetTimerTime(s32 timerId, vm::ptr pClock) { throw __FUNCTION__; } @@ -825,24 +825,24 @@ u64 sceKernelSetTimerTimeWide(s32 timerId, u64 clock) throw __FUNCTION__; } -s32 sceKernelSetTimerEvent(s32 timerId, s32 type, vm::psv::ptr pInterval, s32 fRepeat) +s32 sceKernelSetTimerEvent(s32 timerId, s32 type, vm::ptr pInterval, s32 fRepeat) { throw __FUNCTION__; } -s32 sceKernelCancelTimer(s32 timerId, vm::psv::ptr pNumWaitThreads) +s32 sceKernelCancelTimer(s32 timerId, vm::ptr pNumWaitThreads) { throw __FUNCTION__; } -s32 sceKernelGetTimerInfo(s32 timerId, vm::psv::ptr pInfo) +s32 sceKernelGetTimerInfo(s32 timerId, vm::ptr pInfo) { throw __FUNCTION__; } // Reader/writer lock functions -s32 sceKernelCreateRWLock(vm::psv::ptr pName, u32 attr, vm::psv::ptr pOptParam) +s32 sceKernelCreateRWLock(vm::ptr pName, u32 attr, vm::ptr pOptParam) { throw __FUNCTION__; } @@ -852,7 +852,7 @@ s32 sceKernelDeleteRWLock(s32 rwLockId) throw __FUNCTION__; } -s32 sceKernelOpenRWLock(vm::psv::ptr pName) +s32 sceKernelOpenRWLock(vm::ptr pName) { throw __FUNCTION__; } @@ -862,12 +862,12 @@ s32 sceKernelCloseRWLock(s32 rwLockId) throw __FUNCTION__; } -s32 sceKernelLockReadRWLock(s32 rwLockId, vm::psv::ptr pTimeout) +s32 sceKernelLockReadRWLock(s32 rwLockId, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelLockReadRWLockCB(s32 rwLockId, vm::psv::ptr pTimeout) +s32 sceKernelLockReadRWLockCB(s32 rwLockId, vm::ptr pTimeout) { throw __FUNCTION__; } @@ -882,12 +882,12 @@ s32 sceKernelUnlockReadRWLock(s32 rwLockId) throw __FUNCTION__; } -s32 sceKernelLockWriteRWLock(s32 rwLockId, vm::psv::ptr pTimeout) +s32 sceKernelLockWriteRWLock(s32 rwLockId, vm::ptr pTimeout) { throw __FUNCTION__; } -s32 sceKernelLockWriteRWLockCB(s32 rwLockId, vm::psv::ptr pTimeout) +s32 sceKernelLockWriteRWLockCB(s32 rwLockId, vm::ptr pTimeout) { throw __FUNCTION__; } @@ -902,49 +902,49 @@ s32 sceKernelUnlockWriteRWLock(s32 rwLockId) throw __FUNCTION__; } -s32 sceKernelCancelRWLock(s32 rwLockId, vm::psv::ptr pNumReadWaitThreads, vm::psv::ptr pNumWriteWaitThreads, s32 flag) +s32 sceKernelCancelRWLock(s32 rwLockId, vm::ptr pNumReadWaitThreads, vm::ptr pNumWriteWaitThreads, s32 flag) { throw __FUNCTION__; } -s32 sceKernelGetRWLockInfo(s32 rwLockId, vm::psv::ptr pInfo) +s32 sceKernelGetRWLockInfo(s32 rwLockId, vm::ptr pInfo) { throw __FUNCTION__; } // IO/File functions -s32 sceIoRemove(vm::psv::ptr filename) +s32 sceIoRemove(vm::ptr filename) { throw __FUNCTION__; } -s32 sceIoMkdir(vm::psv::ptr dirname, s32 mode) +s32 sceIoMkdir(vm::ptr dirname, s32 mode) { throw __FUNCTION__; } -s32 sceIoRmdir(vm::psv::ptr dirname) +s32 sceIoRmdir(vm::ptr dirname) { throw __FUNCTION__; } -s32 sceIoRename(vm::psv::ptr oldname, vm::psv::ptr newname) +s32 sceIoRename(vm::ptr oldname, vm::ptr newname) { throw __FUNCTION__; } -s32 sceIoDevctl(vm::psv::ptr devname, s32 cmd, vm::psv::ptr arg, u32 arglen, vm::psv::ptr bufp, u32 buflen) +s32 sceIoDevctl(vm::ptr devname, s32 cmd, vm::ptr arg, u32 arglen, vm::ptr bufp, u32 buflen) { throw __FUNCTION__; } -s32 sceIoSync(vm::psv::ptr devname, s32 flag) +s32 sceIoSync(vm::ptr devname, s32 flag) { throw __FUNCTION__; } -s32 sceIoOpen(vm::psv::ptr filename, s32 flag, s32 mode) +s32 sceIoOpen(vm::ptr filename, s32 flag, s32 mode) { throw __FUNCTION__; } @@ -954,7 +954,7 @@ s32 sceIoClose(s32 fd) throw __FUNCTION__; } -s32 sceIoIoctl(s32 fd, s32 cmd, vm::psv::ptr argp, u32 arglen, vm::psv::ptr bufp, u32 buflen) +s32 sceIoIoctl(s32 fd, s32 cmd, vm::ptr argp, u32 arglen, vm::ptr bufp, u32 buflen) { throw __FUNCTION__; } @@ -969,27 +969,27 @@ s32 sceIoLseek32(s32 fd, s32 offset, s32 whence) throw __FUNCTION__; } -s32 sceIoRead(s32 fd, vm::psv::ptr buf, u32 nbyte) +s32 sceIoRead(s32 fd, vm::ptr buf, u32 nbyte) { throw __FUNCTION__; } -s32 sceIoWrite(s32 fd, vm::psv::ptr buf, u32 nbyte) +s32 sceIoWrite(s32 fd, vm::ptr buf, u32 nbyte) { throw __FUNCTION__; } -s32 sceIoPread(s32 fd, vm::psv::ptr buf, u32 nbyte, s64 offset) +s32 sceIoPread(s32 fd, vm::ptr buf, u32 nbyte, s64 offset) { throw __FUNCTION__; } -s32 sceIoPwrite(s32 fd, vm::psv::ptr buf, u32 nbyte, s64 offset) +s32 sceIoPwrite(s32 fd, vm::ptr buf, u32 nbyte, s64 offset) { throw __FUNCTION__; } -s32 sceIoDopen(vm::psv::ptr dirname) +s32 sceIoDopen(vm::ptr dirname) { throw __FUNCTION__; } @@ -999,17 +999,17 @@ s32 sceIoDclose(s32 fd) throw __FUNCTION__; } -s32 sceIoDread(s32 fd, vm::psv::ptr buf) +s32 sceIoDread(s32 fd, vm::ptr buf) { throw __FUNCTION__; } -s32 sceIoChstat(vm::psv::ptr name, vm::psv::ptr buf, u32 cbit) +s32 sceIoChstat(vm::ptr name, vm::ptr buf, u32 cbit) { throw __FUNCTION__; } -s32 sceIoGetstat(vm::psv::ptr name, vm::psv::ptr buf) +s32 sceIoGetstat(vm::ptr name, vm::ptr buf) { throw __FUNCTION__; } diff --git a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h index df2bbd3d3d..97cd650976 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h +++ b/rpcs3/Emu/ARMv7/Modules/sceLibKernel.h @@ -269,339 +269,337 @@ union SceKernelSysClock { struct { - u32 low; - u32 hi; + le_t low; + le_t hi; }; - u64 quad; + le_t quad; }; struct SceKernelCallFrame { - u32 sp; - u32 pc; + le_t sp; + le_t pc; }; // Memory Manager definitions -typedef s32 SceKernelMemoryType; - struct SceKernelMemBlockInfo { - u32 size; - vm::psv::ptr mappedBase; - u32 mappedSize; - SceKernelMemoryType memoryType; - u32 access; + le_t size; + vm::lptr mappedBase; + le_t mappedSize; + le_t memoryType; // SceKernelMemoryType + le_t access; }; struct SceKernelAllocMemBlockOpt { - u32 size; - u32 attr; - u32 alignment; - s32 uidBaseBlock; - vm::psv::ptr strBaseBlockName; + le_t size; + le_t attr; + le_t alignment; + le_t uidBaseBlock; + vm::lcptr strBaseBlockName; }; // Thread Manager definitions (threads) -typedef s32(SceKernelThreadEntry)(u32 argSize, vm::psv::ptr pArgBlock); +using SceKernelThreadEntry = func_def pArgBlock)>; struct SceKernelThreadOptParam { - u32 size; - u32 attr; + le_t size; + le_t attr; }; struct SceKernelThreadInfo { - u32 size; - s32 processId; + le_t size; + le_t processId; char name[32]; - u32 attr; - u32 status; - vm::psv::ptr entry; - vm::psv::ptr pStack; - u32 stackSize; - s32 initPriority; - s32 currentPriority; - s32 initCpuAffinityMask; - s32 currentCpuAffinityMask; - s32 currentCpuId; - s32 lastExecutedCpuId; - u32 waitType; - s32 waitId; - s32 exitStatus; + le_t attr; + le_t status; + vm::lptr entry; + vm::lptr pStack; + le_t stackSize; + le_t initPriority; + le_t currentPriority; + le_t initCpuAffinityMask; + le_t currentCpuAffinityMask; + le_t currentCpuId; + le_t lastExecutedCpuId; + le_t waitType; + le_t waitId; + le_t exitStatus; SceKernelSysClock runClocks; - u32 intrPreemptCount; - u32 threadPreemptCount; - u32 threadReleaseCount; - s32 changeCpuCount; - s32 fNotifyCallback; - s32 reserved; + le_t intrPreemptCount; + le_t threadPreemptCount; + le_t threadReleaseCount; + le_t changeCpuCount; + le_t fNotifyCallback; + le_t reserved; }; struct SceKernelThreadRunStatus { - u32 size; + le_t size; struct { - s32 processId; - s32 threadId; - s32 priority; + le_t processId; + le_t threadId; + le_t priority; } cpuInfo[4]; }; struct SceKernelSystemInfo { - u32 size; - u32 activeCpuMask; + le_t size; + le_t activeCpuMask; struct { SceKernelSysClock idleClock; - u32 comesOutOfIdleCount; - u32 threadSwitchCount; + le_t comesOutOfIdleCount; + le_t threadSwitchCount; } cpuInfo[4]; }; // Thread Manager definitions (callbacks) -typedef s32(SceKernelCallbackFunction)(s32 notifyId, s32 notifyCount, s32 notifyArg, vm::psv::ptr pCommon); +using SceKernelCallbackFunction = func_def pCommon)>; struct SceKernelCallbackInfo { - u32 size; - s32 callbackId; + le_t size; + le_t callbackId; char name[32]; - u32 attr; - s32 threadId; - vm::psv::ptr callbackFunc; - s32 notifyId; - s32 notifyCount; - s32 notifyArg; - vm::psv::ptr pCommon; + le_t attr; + le_t threadId; + vm::lptr callbackFunc; + le_t notifyId; + le_t notifyCount; + le_t notifyArg; + vm::lptr pCommon; }; // Thread Manager definitions (events) -typedef s32(SceKernelThreadEventHandler)(s32 type, s32 threadId, s32 arg, vm::psv::ptr pCommon); +using SceKernelThreadEventHandler = func_def pCommon)>; struct SceKernelEventInfo { - u32 size; - s32 eventId; + le_t size; + le_t eventId; char name[32]; - u32 attr; - u32 eventPattern; - u64 userData; - u32 numWaitThreads; - s32 reserved[1]; + le_t attr; + le_t eventPattern; + le_t userData; + le_t numWaitThreads; + le_t reserved[1]; }; struct SceKernelWaitEvent { - s32 eventId; - u32 eventPattern; + le_t eventId; + le_t eventPattern; }; struct SceKernelResultEvent { - s32 eventId; - s32 result; - u32 resultPattern; - s32 reserved[1]; - u64 userData; + le_t eventId; + le_t result; + le_t resultPattern; + le_t reserved[1]; + le_t userData; }; // Thread Manager definitions (event flags) struct SceKernelEventFlagOptParam { - u32 size; + le_t size; }; struct SceKernelEventFlagInfo { - u32 size; - s32 evfId; + le_t size; + le_t evfId; char name[32]; - u32 attr; - u32 initPattern; - u32 currentPattern; - s32 numWaitThreads; + le_t attr; + le_t initPattern; + le_t currentPattern; + le_t numWaitThreads; }; // Thread Manager definitions (semaphores) struct SceKernelSemaOptParam { - u32 size; + le_t size; }; struct SceKernelSemaInfo { - u32 size; - s32 semaId; + le_t size; + le_t semaId; char name[32]; - u32 attr; - s32 initCount; - s32 currentCount; - s32 maxCount; - s32 numWaitThreads; + le_t attr; + le_t initCount; + le_t currentCount; + le_t maxCount; + le_t numWaitThreads; }; // Thread Manager definitions (mutexes) struct SceKernelMutexOptParam { - u32 size; - s32 ceilingPriority; + le_t size; + le_t ceilingPriority; }; struct SceKernelMutexInfo { - u32 size; - s32 mutexId; + le_t size; + le_t mutexId; char name[32]; - u32 attr; - s32 initCount; - s32 currentCount; - s32 currentOwnerId; - s32 numWaitThreads; + le_t attr; + le_t initCount; + le_t currentCount; + le_t currentOwnerId; + le_t numWaitThreads; }; // Thread Manager definitions (lightweight mutexes) struct SceKernelLwMutexWork { - s32 data[4]; + le_t data[4]; }; struct SceKernelLwMutexOptParam { - u32 size; + le_t size; }; struct SceKernelLwMutexInfo { - u32 size; - s32 uid; + le_t size; + le_t uid; char name[32]; - u32 attr; - vm::psv::ptr pWork; - s32 initCount; - s32 currentCount; - s32 currentOwnerId; - s32 numWaitThreads; + le_t attr; + vm::lptr pWork; + le_t initCount; + le_t currentCount; + le_t currentOwnerId; + le_t numWaitThreads; }; // Thread Manager definitions (condition variables) struct SceKernelCondOptParam { - u32 size; + le_t size; }; struct SceKernelCondInfo { - u32 size; - s32 condId; + le_t size; + le_t condId; char name[32]; - u32 attr; - s32 mutexId; - u32 numWaitThreads; + le_t attr; + le_t mutexId; + le_t numWaitThreads; }; // Thread Manager definitions (lightweight condition variables) struct SceKernelLwCondWork { - s32 data[4]; + le_t data[4]; }; struct SceKernelLwCondOptParam { - u32 size; + le_t size; }; struct SceKernelLwCondInfo { - u32 size; - s32 uid; + le_t size; + le_t uid; char name[32]; - u32 attr; - vm::psv::ptr pWork; - vm::psv::ptr pLwMutex; - u32 numWaitThreads; + le_t attr; + vm::lptr pWork; + vm::lptr pLwMutex; + le_t numWaitThreads; }; // Thread Manager definitions (timers) struct SceKernelTimerOptParam { - u32 size; + le_t size; }; struct SceKernelTimerInfo { - u32 size; - s32 timerId; + le_t size; + le_t timerId; char name[32]; - u32 attr; - s32 fActive; + le_t attr; + le_t fActive; SceKernelSysClock baseTime; SceKernelSysClock currentTime; SceKernelSysClock schedule; SceKernelSysClock interval; - s32 type; - s32 fRepeat; - s32 numWaitThreads; - s32 reserved[1]; + le_t type; + le_t fRepeat; + le_t numWaitThreads; + le_t reserved[1]; }; // Thread Manager definitions (reader/writer locks) struct SceKernelRWLockOptParam { - u32 size; + le_t size; }; struct SceKernelRWLockInfo { - u32 size; - s32 rwLockId; + le_t size; + le_t rwLockId; char name[32]; - u32 attr; - s32 lockCount; - s32 writeOwnerId; - s32 numReadWaitThreads; - s32 numWriteWaitThreads; + le_t attr; + le_t lockCount; + le_t writeOwnerId; + le_t numReadWaitThreads; + le_t numWriteWaitThreads; }; // IO/File Manager definitions struct SceIoStat { - s32 mode; - u32 attr; - s64 size; + le_t mode; + le_t attr; + le_t size; SceDateTime ctime; SceDateTime atime; SceDateTime mtime; - u64 _private[6]; + le_t _private[6]; }; struct SceIoDirent { SceIoStat d_stat; char d_name[256]; - vm::psv::ptr d_private; - s32 dummy; + vm::lptr d_private; + le_t dummy; }; // Module diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h index 9bd061b512..34d2a82f4d 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.h +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -1,13 +1,18 @@ #pragma once + #include "Emu/Memory/Memory.h" #include "ARMv7Context.h" #include "Emu/SysCalls/LogBase.h" +namespace vm { using namespace psv; } + // PSV module class class psv_log_base : public LogBase { + using init_func_t = void(*)(); + std::string m_name; - void(*m_init_func)(); + init_func_t m_init; public: std::function on_load; @@ -15,15 +20,15 @@ public: std::function on_stop; public: - psv_log_base(const std::string& name, void(*init_func)()) + psv_log_base(const std::string& name, init_func_t init) : m_name(name) - , m_init_func(init_func) + , m_init(init) { } void Init() { - m_init_func(); + m_init(); } virtual const std::string& GetName() const override @@ -140,7 +145,7 @@ namespace psv_func_detail force_inline static T get_arg(ARMv7Context& context) { // TODO: check - return cast_from_armv7_gpr(vm::psv::read32(context.SP + sizeof(u32) * (g_count - 5))); + return cast_from_armv7_gpr(vm::read32(context.SP + sizeof(u32) * (g_count - 5))); } force_inline static void put_arg(ARMv7Context& context, const T& arg) @@ -149,7 +154,7 @@ namespace psv_func_detail const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; static_assert(stack_pos < 0, "TODO: Increase fixed stack frame size (arg count limit broken)"); - vm::psv::write32(context.SP + stack_pos, cast_to_armv7_gpr(arg)); + vm::write32(context.SP + stack_pos, cast_to_armv7_gpr(arg)); } }; @@ -159,7 +164,7 @@ namespace psv_func_detail force_inline static u64 get_arg(ARMv7Context& context) { // TODO: check - return vm::psv::read64(context.SP + sizeof(u32) * (g_count - 5)); + return vm::read64(context.SP + sizeof(u32) * (g_count - 5)); } force_inline static void put_arg(ARMv7Context& context, u64 arg) @@ -168,7 +173,7 @@ namespace psv_func_detail const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; static_assert(stack_pos < -4, "TODO: Increase fixed stack frame size (arg count limit broken)"); - vm::psv::write64(context.SP + stack_pos, arg); + vm::write64(context.SP + stack_pos, arg); } }; @@ -178,7 +183,7 @@ namespace psv_func_detail force_inline static s64 get_arg(ARMv7Context& context) { // TODO: check - return vm::psv::read64(context.SP + sizeof(u32) * (g_count - 5)); + return vm::read64(context.SP + sizeof(u32) * (g_count - 5)); } force_inline static void put_arg(ARMv7Context& context, s64 arg) @@ -187,7 +192,7 @@ namespace psv_func_detail const int stack_pos = (g_count - 5) * 4 - FIXED_STACK_FRAME_SIZE; static_assert(stack_pos < -4, "TODO: Increase fixed stack frame size (arg count limit broken)"); - vm::psv::write64(context.SP + stack_pos, arg); + vm::write64(context.SP + stack_pos, arg); } }; @@ -619,27 +624,34 @@ enum psv_error_codes struct SceDateTime { - u16 year; - u16 month; - u16 day; - u16 hour; - u16 minute; - u16 second; - u32 microsecond; + le_t year; + le_t month; + le_t day; + le_t hour; + le_t minute; + le_t second; + le_t microsecond; }; struct SceFVector3 { - float x, y, z; + le_t x, y, z; }; struct SceFQuaternion { - float x, y, z, w; + le_t x, y, z, w; }; union SceUMatrix4 { - float f[4][4]; - s32 i[4][4]; + struct + { + le_t f[4][4]; + }; + + struct + { + le_t i[4][4]; + }; }; diff --git a/rpcs3/Emu/Audio/AudioManager.cpp b/rpcs3/Emu/Audio/AudioManager.cpp index a48802136d..8d28c476a6 100644 --- a/rpcs3/Emu/Audio/AudioManager.cpp +++ b/rpcs3/Emu/Audio/AudioManager.cpp @@ -36,8 +36,3 @@ void AudioManager::Close() delete m_audio_out; m_audio_out = nullptr; } - -u8 AudioManager::GetState() -{ - return CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED; -} diff --git a/rpcs3/Emu/Audio/AudioManager.h b/rpcs3/Emu/Audio/AudioManager.h index 88eb3db216..a1f50c84da 100644 --- a/rpcs3/Emu/Audio/AudioManager.h +++ b/rpcs3/Emu/Audio/AudioManager.h @@ -1,31 +1,16 @@ #pragma once -#include "sysutil_audio.h" + #include "AudioThread.h" +// it cannot be configured currently, and it must NOT use cellSysutil definitions struct AudioInfo { - struct - { - u8 type; - u8 channel; - u8 encoder; - u8 fs; - u32 layout; - u32 downMixer; - } mode; - AudioInfo() { } void Init() { - mode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM; - mode.channel = CELL_AUDIO_OUT_CHNUM_8; - mode.fs = CELL_AUDIO_OUT_FS_48KHZ; - mode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy; - mode.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; - mode.downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; } }; @@ -42,6 +27,4 @@ public: AudioThread& GetAudioOut() { assert(m_audio_out); return *m_audio_out; } AudioInfo& GetInfo() { return m_audio_info; } - - u8 GetState(); -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/Audio/AudioThread.h b/rpcs3/Emu/Audio/AudioThread.h index fa600ba9cb..6932294bb3 100644 --- a/rpcs3/Emu/Audio/AudioThread.h +++ b/rpcs3/Emu/Audio/AudioThread.h @@ -12,4 +12,4 @@ public: virtual void Close() = 0; virtual void Stop() = 0; virtual void AddData(const void* src, int size) = 0; -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/Cell/PPCDecoder.cpp b/rpcs3/Emu/Cell/PPCDecoder.cpp index 6425cf7c7a..7cbb50565f 100644 --- a/rpcs3/Emu/Cell/PPCDecoder.cpp +++ b/rpcs3/Emu/Cell/PPCDecoder.cpp @@ -4,8 +4,8 @@ u32 PPCDecoder::DecodeMemory(const u32 address) { - u32 instr = vm::read32(address); + u32 instr = vm::ps3::read32(address); Decode(instr); return sizeof(u32); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index d7945fd2f9..080a692beb 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -751,8 +751,8 @@ ppu_thread::ppu_thread(u32 entry, const std::string& name, u32 stack_size, u32 p thread->SetName(name); thread->SetEntry(entry); - thread->SetStackSize(stack_size ? stack_size : Emu.GetInfo().GetProcParam().primary_stacksize); - thread->SetPrio(prio ? prio : Emu.GetInfo().GetProcParam().primary_prio); + thread->SetStackSize(stack_size ? stack_size : Emu.GetPrimaryStackSize()); + thread->SetPrio(prio ? prio : Emu.GetPrimaryPrio()); argc = 0; } @@ -764,14 +764,14 @@ cpu_thread& ppu_thread::args(std::initializer_list values) assert(argc == 0); - envp.set(vm::alloc(align((u32)sizeof(*envp), stack_align), vm::main)); + envp.set(vm::alloc(align(sizeof32(u64), stack_align), vm::main)); *envp = 0; - argv.set(vm::alloc(sizeof(*argv) * values.size(), vm::main)); + argv.set(vm::alloc(sizeof32(u64) * (u32)values.size(), vm::main)); for (auto &arg : values) { - u32 arg_size = align(u32(arg.size() + 1), stack_align); - u32 arg_addr = vm::alloc(arg_size, vm::main); + const u32 arg_size = align(u32(arg.size() + 1), stack_align); + const u32 arg_addr = vm::alloc(arg_size, vm::main); std::strcpy(vm::get_ptr(arg_addr), arg.c_str()); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index 4a5ced3483..d767dfb4b2 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -828,9 +828,9 @@ PPUThread& GetCurrentPPUThread(); class ppu_thread : cpu_thread { static const u32 stack_align = 0x10; - vm::ptr argv; + vm::_ptr_base> argv; u32 argc; - vm::ptr envp; + vm::_ptr_base> envp; public: ppu_thread(u32 entry, const std::string& name = "", u32 stack_size = 0, u32 prio = 0); diff --git a/rpcs3/Emu/Cell/SPURSManager.cpp b/rpcs3/Emu/Cell/SPURSManager.cpp deleted file mode 100644 index 105cb2c79e..0000000000 --- a/rpcs3/Emu/Cell/SPURSManager.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "stdafx.h" -#include "Emu/Memory/Memory.h" - -#include "SPURSManager.h" - -SPURSManagerEventFlag::SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirection) -{ - this->flagClearMode = flagClearMode; - this->flagDirection = flagDirection; -} - -SPURSManagerTasksetAttribute::SPURSManagerTasksetAttribute(u64 args, vm::ptr priority, u32 maxContention) -{ - this->args = args; - this->maxContention = maxContention; -} - -SPURSManager::SPURSManager() -{ -} - -void SPURSManager::Finalize() -{ -} - -void SPURSManager::AttachLv2EventQueue(u32 queue, vm::ptr port, int isDynamic) -{ - //TODO: -} - -void SPURSManager::DetachLv2EventQueue(u8 port) -{ - //TODO: -} - -SPURSManagerTaskset::SPURSManagerTaskset(u32 address, SPURSManagerTasksetAttribute *tattr) -{ - this->tattr = tattr; - this->address = address; -} \ No newline at end of file diff --git a/rpcs3/Emu/Cell/SPURSManager.h b/rpcs3/Emu/Cell/SPURSManager.h deleted file mode 100644 index 55bf5de181..0000000000 --- a/rpcs3/Emu/Cell/SPURSManager.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -class SPURSManagerEventFlag -{ -public: - SPURSManagerEventFlag(u32 flagClearMode, u32 flagDirection); - - u32 _getDirection() const - { - return this->flagDirection; - } - - u32 _getClearMode() const - { - return this->flagClearMode; - } - -protected: - be_t flagClearMode; - be_t flagDirection; -}; - -class SPURSManagerTasksetAttribute -{ -public: - SPURSManagerTasksetAttribute(u64 args, vm::ptr priority, u32 maxContention); - -protected: - be_t args; - be_t maxContention; -}; - -class SPURSManagerTaskset -{ -public: - SPURSManagerTaskset(u32 address, SPURSManagerTasksetAttribute *tattr); - -protected: - u32 address; - SPURSManagerTasksetAttribute *tattr; -}; - -// Main SPURS manager class. -class SPURSManager -{ -public: - SPURSManager(); - - void Finalize(); - void AttachLv2EventQueue(u32 queue, vm::ptr port, int isDynamic); - void DetachLv2EventQueue(u8 port); -}; diff --git a/rpcs3/Emu/Cell/SPURecompilerCore.cpp b/rpcs3/Emu/Cell/SPURecompilerCore.cpp index 6257baaf7e..0caf41d906 100644 --- a/rpcs3/Emu/Cell/SPURecompilerCore.cpp +++ b/rpcs3/Emu/Cell/SPURecompilerCore.cpp @@ -4,8 +4,6 @@ #include "Emu/System.h" #include "Utilities/File.h" -#include "Emu/SysCalls/lv2/sys_time.h" - #include "SPUInstrTable.h" #include "SPUDisAsm.h" @@ -20,6 +18,8 @@ using namespace asmjit; using namespace asmjit::host; +extern u64 get_system_time(); + SPURecompilerCore::SPURecompilerCore(SPUThread& cpu) : m_enc(new SPURecompiler(cpu, *this)) , m_int(new SPUInterpreter(cpu)) @@ -95,7 +95,7 @@ void SPURecompilerCore::Compile(u16 pos) while (true) { - const u32 opcode = vm::read32(CPU.offset + pos * 4); + const u32 opcode = vm::ps3::read32(CPU.offset + pos * 4); m_enc->do_finalize = false; if (opcode) { diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 29f209c3f4..c9345eee51 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1219,8 +1219,6 @@ spu_thread::spu_thread(u32 entry, const std::string& name, u32 stack_size, u32 p thread->SetName(name); thread->SetEntry(entry); - thread->SetStackSize(stack_size ? stack_size : Emu.GetInfo().GetProcParam().primary_stacksize); - thread->SetPrio(prio ? prio : Emu.GetInfo().GetProcParam().primary_prio); - - argc = 0; + thread->SetStackSize(stack_size ? stack_size : Emu.GetPrimaryStackSize()); + thread->SetPrio(prio ? prio : Emu.GetPrimaryPrio()); } diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index b76fda8e1c..00fe179483 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -582,21 +582,21 @@ public: void halt(); u8 read8(u32 lsa) const { return vm::read8(lsa + offset); } - u16 read16(u32 lsa) const { return vm::read16(lsa + offset); } - u32 read32(u32 lsa) const { return vm::read32(lsa + offset); } - u64 read64(u32 lsa) const { return vm::read64(lsa + offset); } - u128 read128(u32 lsa) const { return vm::read128(lsa + offset); } + u16 read16(u32 lsa) const { return vm::ps3::read16(lsa + offset); } + u32 read32(u32 lsa) const { return vm::ps3::read32(lsa + offset); } + u64 read64(u32 lsa) const { return vm::ps3::read64(lsa + offset); } + u128 read128(u32 lsa) const { return vm::ps3::read128(lsa + offset); } void write8(u32 lsa, u8 data) const { vm::write8(lsa + offset, data); } - void write16(u32 lsa, u16 data) const { vm::write16(lsa + offset, data); } - void write32(u32 lsa, u32 data) const { vm::write32(lsa + offset, data); } - void write64(u32 lsa, u64 data) const { vm::write64(lsa + offset, data); } - void write128(u32 lsa, u128 data) const { vm::write128(lsa + offset, data); } + void write16(u32 lsa, u16 data) const { vm::ps3::write16(lsa + offset, data); } + void write32(u32 lsa, u32 data) const { vm::ps3::write32(lsa + offset, data); } + void write64(u32 lsa, u64 data) const { vm::ps3::write64(lsa + offset, data); } + void write128(u32 lsa, u128 data) const { vm::ps3::write128(lsa + offset, data); } - void write16(u32 lsa, be_t data) const { vm::write16(lsa + offset, data); } - void write32(u32 lsa, be_t data) const { vm::write32(lsa + offset, data); } - void write64(u32 lsa, be_t data) const { vm::write64(lsa + offset, data); } - void write128(u32 lsa, be_t data) const { vm::write128(lsa + offset, data); } + void write16(u32 lsa, be_t data) const { vm::ps3::write16(lsa + offset, data); } + void write32(u32 lsa, be_t data) const { vm::ps3::write32(lsa + offset, data); } + void write64(u32 lsa, be_t data) const { vm::ps3::write64(lsa + offset, data); } + void write128(u32 lsa, be_t data) const { vm::ps3::write128(lsa + offset, data); } void RegisterHleFunction(u32 addr, std::function function) { @@ -702,35 +702,11 @@ SPUThread& GetCurrentSPUThread(); class spu_thread : cpu_thread { - static const u32 stack_align = 0x10; - vm::ptr argv; - u32 argc; - vm::ptr envp; - public: spu_thread(u32 entry, const std::string& name = "", u32 stack_size = 0, u32 prio = 0); cpu_thread& args(std::initializer_list values) override { - if (!values.size()) - return *this; - - assert(argc == 0); - - envp.set(Memory.MainMem.AllocAlign((u32)sizeof(envp), stack_align)); - *envp = 0; - argv.set(Memory.MainMem.AllocAlign(u32(sizeof(argv)* values.size()), stack_align)); - - for (auto &arg : values) - { - u32 arg_size = align(u32(arg.size() + 1), stack_align); - u32 arg_addr = (u32)Memory.MainMem.AllocAlign(arg_size, stack_align); - - std::strcpy(vm::get_ptr(arg_addr), arg.c_str()); - - argv[argc++] = arg_addr; - } - return *this; } @@ -740,10 +716,6 @@ public: spu.Run(); - spu.GPR[3].from64(argc); - spu.GPR[4].from64(argv.addr()); - spu.GPR[5].from64(envp.addr()); - return *this; } }; diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 6cee9d4bfc..d2b1187d4f 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -63,7 +63,7 @@ public: } // must be called from the constructor called through make() to get further ID of current object - u32 get_cur_id() + u32 get_current_id() { // if called correctly from make(), the mutex is locked // if called illegally, the mutex is unlocked with high probability (wrong ID is returned otherwise) diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 9c8f038187..94e99f4bc6 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -436,7 +436,7 @@ bool VirtualMemoryBlock::Read32(const u32 addr, u32* value) u32 realAddr; if (!getRealAddr(addr, realAddr)) return false; - *value = vm::read32(realAddr); + *value = vm::ps3::read32(realAddr); return true; } @@ -445,7 +445,7 @@ bool VirtualMemoryBlock::Write32(const u32 addr, const u32 value) u32 realAddr; if (!getRealAddr(addr, realAddr)) return false; - vm::write32(realAddr, value); + vm::ps3::write32(realAddr, value); return true; } diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index 8dea66bff7..e5fb349241 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -142,20 +142,20 @@ namespace vm return cast_ptr::cast(addr, func); } + static u8 read8(u32 addr) + { + return get_ref(addr); + } + + static void write8(u32 addr, u8 value) + { + get_ref(addr) = value; + } + namespace ps3 { void init(); - static u8 read8(u32 addr) - { - return get_ref(addr); - } - - static void write8(u32 addr, u8 value) - { - get_ref(addr) = value; - } - static u16 read16(u32 addr) { return get_ref>(addr); @@ -216,16 +216,6 @@ namespace vm { void init(); - static u8 read8(u32 addr) - { - return get_ref(addr); - } - - static void write8(u32 addr, u8 value) - { - get_ref(addr) = value; - } - static u16 read16(u32 addr) { return get_ref(addr); @@ -298,15 +288,15 @@ namespace vm u32 alloc_offset; template - ptr alloc(u32 count = 1) const + _ptr_base alloc(u32 count = 1) const { - return ptr::make(allocator(count * sizeof(T))); + return{ allocator(count * sizeof32(T)) }; } template - ptr fixed_alloc(u32 addr, u32 count = 1) const + _ptr_base fixed_alloc(u32 addr, u32 count = 1) const { - return ptr::make(fixed_allocator(addr, count * sizeof(T))); + return{ fixed_allocator(addr, count * sizeof32(T)) }; } }; diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 255cfd8735..0eb033c20f 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -184,9 +184,6 @@ namespace vm template using lcptr = lptr; } - // PS3 emulation is main now, so lets it be as default - using namespace ps3; - struct null_t { template operator _ptr_base() const diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index acd62e58f1..f420a68083 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -103,9 +103,6 @@ namespace vm // default reference for PSV HLE structures (LE reference to LE data) template using lref = lrefl; } - - //PS3 emulation is main now, so lets it be as default - using namespace ps3; } // postfix increment operator for vm::_ref_base diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index eeefd1d3b9..61b97a098d 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -1,10 +1,10 @@ #include "stdafx.h" -#include "FragmentProgramDecompiler.h" - #include "Utilities/Log.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" +#include "FragmentProgramDecompiler.h" + FragmentProgramDecompiler::FragmentProgramDecompiler(u32 addr, u32& size, u32 ctrl) : m_addr(addr), m_size(size), @@ -114,7 +114,7 @@ std::string FragmentProgramDecompiler::AddConst() return name; } - auto data = vm::ptr::make(m_addr + m_size + 4 * sizeof(u32)); + auto data = vm::ps3::ptr::make(m_addr + m_size + 4 * sizeof(u32)); m_offset = 2 * 4 * sizeof(u32); u32 x = GetData(data[0]); @@ -335,7 +335,7 @@ std::string FragmentProgramDecompiler::BuildCode() std::string FragmentProgramDecompiler::Decompile() { - auto data = vm::ptr::make(m_addr); + auto data = vm::ps3::ptr::make(m_addr); m_size = 0; m_location = 0; m_loop_count = 0; diff --git a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp index 5505f4cde9..3c8792611c 100644 --- a/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/VertexProgramDecompiler.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" -#include "VertexProgramDecompiler.h" #include "Utilities/Log.h" #include "Emu/System.h" +#include "VertexProgramDecompiler.h" + std::string VertexProgramDecompiler::GetMask(bool is_sca) { std::string ret; diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index 39c15ab2ca..375788fdb7 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum { CELL_GCM_DISPLAY_HSYNC = 1, diff --git a/rpcs3/Emu/RSX/GSManager.h b/rpcs3/Emu/RSX/GSManager.h index 68d9db987a..7d8a185364 100644 --- a/rpcs3/Emu/RSX/GSManager.h +++ b/rpcs3/Emu/RSX/GSManager.h @@ -1,5 +1,6 @@ #pragma once -#include "GSRender.h" + +struct GSRender; struct GSInfo { @@ -13,7 +14,6 @@ struct GSInfo u16 refreshRates; u32 pitch; } mode; - //CellVideoOutDisplayMode mode; GSInfo() { diff --git a/rpcs3/Emu/RSX/RSXDMA.cpp b/rpcs3/Emu/RSX/RSXDMA.cpp deleted file mode 100644 index ad6bc06a74..0000000000 --- a/rpcs3/Emu/RSX/RSXDMA.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2015 AlexAltea (https://github.com/AlexAltea/nucleus) -#include "stdafx.h" -#include "RSXDMA.h" -#include "Emu/Memory/Memory.h" -#include "Utilities/Log.h" - -DMAObject dma_address(u32 dma_object) -{ - // NOTE: RAMIN is not emulated, therefore DMA Objects are hardcoded in this function - switch (dma_object) { - case RSX_CONTEXT_DMA_REPORT_LOCATION_LOCAL: - return DMAObject{ 0x40300000, 0x8000, DMAObject::READWRITE }; // TODO: Inconsistency: Gitbrew says R starting at 0x1400, test says RW starting at 0x0. - case RSX_CONTEXT_DMA_DEVICE_RW: - return DMAObject{ 0x40000000, 0x1000, DMAObject::READWRITE }; - case RSX_CONTEXT_DMA_DEVICE_R: - return DMAObject{ 0x40000000, 0x1000, DMAObject::READWRITE }; // TODO: Inconsistency: Gitbrew says R, test says RW - case RSX_CONTEXT_DMA_SEMAPHORE_RW: - return DMAObject{ 0x40100000, 0x1000, DMAObject::READWRITE }; - case RSX_CONTEXT_DMA_SEMAPHORE_R: - return DMAObject{ 0x40100000, 0x1000, DMAObject::READWRITE }; // TODO: Inconsistency: Gitbrew says R, test says RW - default: - LOG_WARNING(RSX, "Unknown DMA object (0x%08x)", dma_object); - return DMAObject{}; - } -} - -u8 dma_read8(u32 dma_object, u8 offset) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::READ) - { - return vm::read8(dma.addr + offset); - } - - LOG_WARNING(RSX, "Illegal DMA 8-bit read"); - return 0; -} - -u16 dma_read16(u32 dma_object, u16 offset) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::READ) - { - return vm::read16(dma.addr + offset); - } - - LOG_WARNING(RSX, "Illegal DMA 16-bit read"); - return 0; -} - -u32 dma_read32(u32 dma_object, u32 offset) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::READ) - { - return vm::read32(dma.addr + offset); - } - - LOG_WARNING(RSX, "Illegal DMA 32-bit read"); - return 0; -} - -u64 dma_read64(u32 dma_object, u64 offset) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::READ) - { - return vm::read64(dma.addr + offset); - } - - LOG_WARNING(RSX, "Illegal DMA 64-bit read"); - return 0; -} - -void dma_write8(u32 dma_object, u32 offset, u8 value) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::WRITE) - { - return vm::write8(dma.addr + offset, value); - } - - LOG_WARNING(RSX, "Illegal DMA 32-bit write"); -} - -void dma_write16(u32 dma_object, u32 offset, u16 value) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::WRITE) - { - return vm::write16(dma.addr + offset, value); - } - - LOG_WARNING(RSX, "Illegal DMA 32-bit write"); -} - -void dma_write32(u32 dma_object, u32 offset, u32 value) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::WRITE) - { - return vm::write32(dma.addr + offset, value); - } - - LOG_WARNING(RSX, "Illegal DMA 32-bit write"); -} - -void dma_write64(u32 dma_object, u32 offset, u64 value) -{ - const DMAObject& dma = dma_address(dma_object); - - if (dma.addr && dma.flags & DMAObject::WRITE) - { - return vm::write64(dma.addr + offset, value); - } - - LOG_WARNING(RSX, "Illegal DMA 64-bit write"); -} \ No newline at end of file diff --git a/rpcs3/Emu/RSX/RSXDMA.h b/rpcs3/Emu/RSX/RSXDMA.h deleted file mode 100644 index e5da8918eb..0000000000 --- a/rpcs3/Emu/RSX/RSXDMA.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2015 AlexAltea (https://github.com/AlexAltea/nucleus) -#pragma once - -enum { - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY0 = 0x66604200, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY1 = 0x66604201, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY2 = 0x66604202, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY3 = 0x66604203, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY4 = 0x66604204, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY5 = 0x66604205, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY6 = 0x66604206, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY7 = 0x66604207, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_TO_MEMORY_GET_NOTIFY8 = 0x66604208, // Target: lpar_reports[0x1000 : 0x????] - RSX_CONTEXT_DMA_NOTIFY_MAIN_0 = 0x6660420F, - RSX_CONTEXT_DMA_SEMAPHORE_RW = 0x66606660, // Target: lpar_reports[0x0000 : 0x1000] (Read/Write) - RSX_CONTEXT_DMA_SEMAPHORE_R = 0x66616661, // Target: lpar_reports[0x0000 : 0x1000] (Read) - RSX_CONTEXT_DMA_REPORT_LOCATION_LOCAL = 0x66626660, // Target: lpar_reports[0x1400 : 0x9400] - RSX_CONTEXT_DMA_REPORT_LOCATION_MAIN = 0xBAD68000, - RSX_CONTEXT_DMA_DEVICE_RW = 0x56616660, - RSX_CONTEXT_DMA_DEVICE_R = 0x56616661, -}; - -struct DMAObject { - // Flags - enum { - READ = 1 << 0, - WRITE = 1 << 1, - READWRITE = READ | WRITE, - }; - u32 addr; - u32 size; - u32 flags; -}; - -// RSX Direct Memory Access -DMAObject dma_address(u32 dma_object); - -u8 dma_read8(u32 dma_object, u32 offset); -u16 dma_read16(u32 dma_object, u32 offset); -u32 dma_read32(u32 dma_object, u32 offset); -u64 dma_read64(u32 dma_object, u32 offset); - -void dma_write8(u32 dma_object, u32 offset, u8 value); -void dma_write16(u32 dma_object, u32 offset, u16 value); -void dma_write32(u32 dma_object, u32 offset, u32 value); -void dma_write64(u32 dma_object, u32 offset, u64 value); \ No newline at end of file diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 6725a190f1..9f0fbe9f42 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -4,19 +4,20 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/RSX/GSManager.h" -#include "Emu/RSX/RSXDMA.h" +#include "Emu/RSX/GSRender.h" #include "Emu/RSX/sysutil_video.h" #include "RSXThread.h" #include "Emu/SysCalls/Callback.h" #include "Emu/SysCalls/CB_FUNC.h" -#include "Emu/SysCalls/lv2/sys_time.h" extern "C" { #include "libswscale/swscale.h" } +extern u64 get_system_time(); + #define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count, args.addr()) : args[x].value()) #define CMD_DEBUG 0 diff --git a/rpcs3/Emu/SysCalls/Callback.cpp b/rpcs3/Emu/SysCalls/Callback.cpp index b8e319ac73..6d21152f09 100644 --- a/rpcs3/Emu/SysCalls/Callback.cpp +++ b/rpcs3/Emu/SysCalls/Callback.cpp @@ -9,28 +9,24 @@ void CallbackManager::Register(const std::function& func) { - { - std::lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); - m_cb_list.push_back([=](CPUThread& CPU) -> s32 - { - assert(CPU.GetType() == CPU_THREAD_PPU); - return func(static_cast(CPU)); - }); - } + m_cb_list.push_back([=](CPUThread& CPU) -> s32 + { + assert(CPU.GetType() == CPU_THREAD_PPU); + return func(static_cast(CPU)); + }); } void CallbackManager::Async(const std::function& func) { - { - std::lock_guard lock(m_mutex); + std::lock_guard lock(m_mutex); - m_async_list.push_back([=](CPUThread& CPU) - { - assert(CPU.GetType() == CPU_THREAD_PPU); - func(static_cast(CPU)); - }); - } + m_async_list.push_back([=](CPUThread& CPU) + { + assert(CPU.GetType() == CPU_THREAD_PPU); + func(static_cast(CPU)); + }); m_cv.notify_one(); } diff --git a/rpcs3/Emu/SysCalls/ModuleManager.cpp b/rpcs3/Emu/SysCalls/ModuleManager.cpp index e0256fd20e..ef81c7d939 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.cpp +++ b/rpcs3/Emu/SysCalls/ModuleManager.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "Modules.h" #include "ModuleManager.h" extern Module cellAdec; diff --git a/rpcs3/Emu/SysCalls/ModuleManager.h b/rpcs3/Emu/SysCalls/ModuleManager.h index 4da02e2539..68dc46444d 100644 --- a/rpcs3/Emu/SysCalls/ModuleManager.h +++ b/rpcs3/Emu/SysCalls/ModuleManager.h @@ -1,5 +1,6 @@ #pragma once -#include "Modules.h" + +class Module; class ModuleManager { diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index 67f68567b8..909b817cd6 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -1,8 +1,11 @@ #pragma once + #include "Emu/SysCalls/SC_FUNC.h" #include "ErrorCodes.h" #include "LogBase.h" +namespace vm { using namespace ps3; } + class Module; // flags set in ModuleFunc diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h index 00c5a58c3e..c4144879ec 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.h b/rpcs3/Emu/SysCalls/Modules/cellAtrac.h index c6102316b9..0b18040f49 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.h b/rpcs3/Emu/SysCalls/Modules/cellAudio.h index 08356a506a..ed925f71c6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudioIn.h b/rpcs3/Emu/SysCalls/Modules/cellAudioIn.h new file mode 100644 index 0000000000..300869111c --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellAudioIn.h @@ -0,0 +1,90 @@ +#pragma once + +namespace vm { using namespace ps3; } + +// Error codes +enum +{ + CELL_AUDIO_IN_ERROR_NOT_IMPLEMENTED = 0x8002b260, + CELL_AUDIO_IN_ERROR_ILLEGAL_CONFIGURATION = 0x8002b261, + CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER = 0x8002b262, + CELL_AUDIO_IN_ERROR_PARAMETER_OUT_OF_RANGE = 0x8002b263, + CELL_AUDIO_IN_ERROR_DEVICE_NOT_FOUND = 0x8002b264, + CELL_AUDIO_IN_ERROR_UNSUPPORTED_AUDIO_IN = 0x8002b265, + CELL_AUDIO_IN_ERROR_UNSUPPORTED_SOUND_MODE = 0x8002b266, + CELL_AUDIO_IN_ERROR_CONDITION_BUSY = 0x8002b267, +}; + +enum +{ + CELL_AUDIO_IN_SINGLE_DEVICE_MODE = 0, + CELL_AUDIO_IN_MULTI_DEVICE_MODE = 1, + CELL_AUDIO_IN_MULTI_DEVICE_MODE_2 = 2, +}; + +enum CellAudioInPortType +{ + CELL_AUDIO_IN_PORT_USB = 3, + CELL_AUDIO_IN_PORT_BLUETOOTH = 4, +}; + +enum CellAudioInDeviceState +{ + CELL_AUDIO_IN_DEVICE_STATE_UNAVAILABLE = 0, + CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE = 1, +}; + +enum CellAudioInCodingType +{ + CELL_AUDIO_IN_CODING_TYPE_LPCM = 0, +}; + +enum CellAudioInChnum +{ + CELL_AUDIO_IN_CHNUM_NONE = 0, + CELL_AUDIO_IN_CHNUM_1 = 1, + CELL_AUDIO_IN_CHNUM_2 = 2, +}; + +enum CellAudioInFs +{ + CELL_AUDIO_IN_FS_UNDEFINED = 0x00, + CELL_AUDIO_IN_FS_8KHZ = 0x01, + CELL_AUDIO_IN_FS_12KHZ = 0x02, + CELL_AUDIO_IN_FS_16KHZ = 0x04, + CELL_AUDIO_IN_FS_24KHZ = 0x08, + CELL_AUDIO_IN_FS_32KHZ = 0x10, + CELL_AUDIO_IN_FS_48KHZ = 0x20, +}; + +struct CellAudioInSoundMode +{ + u8 type; + u8 channel; + be_t fs; + u8 reserved[4]; +}; + +struct CellAudioInDeviceInfo +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 deviceNumber; + u8 reserved[12]; + be_t deviceId; + be_t type; + char name[64]; + CellAudioInSoundMode availableModes[16]; +}; + +struct CellAudioInRegistrationOption +{ + //(Omitted) +}; + +struct CellAudioInDeviceConfiguration +{ + u8 volume; + u8 reserved[31]; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudioOut.h b/rpcs3/Emu/SysCalls/Modules/cellAudioOut.h new file mode 100644 index 0000000000..92ab800e3d --- /dev/null +++ b/rpcs3/Emu/SysCalls/Modules/cellAudioOut.h @@ -0,0 +1,179 @@ +#pragma once + +namespace vm { using namespace ps3; } + +// Error codes +enum +{ + CELL_AUDIO_OUT_ERROR_NOT_IMPLEMENTED = 0x8002b240, + CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION = 0x8002b241, + CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER = 0x8002b242, + CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE = 0x8002b243, + CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND = 0x8002b244, + CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT = 0x8002b245, + CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE = 0x8002b246, + CELL_AUDIO_OUT_ERROR_CONDITION_BUSY = 0x8002b247, +}; + + +enum CellAudioOut +{ + CELL_AUDIO_OUT_PRIMARY = 0, + CELL_AUDIO_OUT_SECONDARY = 1, +}; + +enum CellAudioOutDownMixer +{ + CELL_AUDIO_OUT_DOWNMIXER_NONE = 0, + CELL_AUDIO_OUT_DOWNMIXER_TYPE_A = 1, + CELL_AUDIO_OUT_DOWNMIXER_TYPE_B = 2, +}; + +enum +{ + CELL_AUDIO_OUT_SINGLE_DEVICE_MODE = 0, + CELL_AUDIO_OUT_MULTI_DEVICE_MODE = 1, + CELL_AUDIO_OUT_MULTI_DEVICE_MODE_2 = 2, +}; + +enum CellAudioOutPortType +{ + CELL_AUDIO_OUT_PORT_HDMI = 0, + CELL_AUDIO_OUT_PORT_SPDIF = 1, + CELL_AUDIO_OUT_PORT_ANALOG = 2, + CELL_AUDIO_OUT_PORT_USB = 3, + CELL_AUDIO_OUT_PORT_BLUETOOTH = 4, + CELL_AUDIO_OUT_PORT_NETWORK = 5, +}; + +enum CellAudioOutDeviceState +{ + CELL_AUDIO_OUT_DEVICE_STATE_UNAVAILABLE = 0, + CELL_AUDIO_OUT_DEVICE_STATE_AVAILABLE = 1, +}; + +enum CellAudioOutOutputState +{ + CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED = 0, + CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED = 1, + CELL_AUDIO_OUT_OUTPUT_STATE_PREPARING = 2, +}; + +enum CellAudioOutCodingType +{ + CELL_AUDIO_OUT_CODING_TYPE_LPCM = 0, + CELL_AUDIO_OUT_CODING_TYPE_AC3 = 1, + CELL_AUDIO_OUT_CODING_TYPE_MPEG1 = 2, + CELL_AUDIO_OUT_CODING_TYPE_MP3 = 3, + CELL_AUDIO_OUT_CODING_TYPE_MPEG2 = 4, + CELL_AUDIO_OUT_CODING_TYPE_AAC = 5, + CELL_AUDIO_OUT_CODING_TYPE_DTS = 6, + CELL_AUDIO_OUT_CODING_TYPE_ATRAC = 7, + CELL_AUDIO_OUT_CODING_TYPE_BITSTREAM = 0xff, +}; + +enum CellAudioOutChnum +{ + CELL_AUDIO_OUT_CHNUM_2 = 2, + CELL_AUDIO_OUT_CHNUM_4 = 4, + CELL_AUDIO_OUT_CHNUM_6 = 6, + CELL_AUDIO_OUT_CHNUM_8 = 8, +}; + +enum CellAudioOutFs +{ + CELL_AUDIO_OUT_FS_32KHZ = 0x01, + CELL_AUDIO_OUT_FS_44KHZ = 0x02, + CELL_AUDIO_OUT_FS_48KHZ = 0x04, + CELL_AUDIO_OUT_FS_88KHZ = 0x08, + CELL_AUDIO_OUT_FS_96KHZ = 0x10, + CELL_AUDIO_OUT_FS_176KHZ = 0x20, + CELL_AUDIO_OUT_FS_192KHZ = 0x40, +}; + +enum +{ + CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH = 0x00000001, + CELL_AUDIO_OUT_SPEAKER_LAYOUT_6CH_LREClr = 0x00010000, + CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy = 0x40000000, +}; + +enum +{ + CELL_AUDIO_OUT_COPY_CONTROL_COPY_FREE = 0, + CELL_AUDIO_OUT_COPY_CONTROL_COPY_ONCE = 1, + CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER = 2, +}; + + +struct CellAudioOutConfiguration +{ + u8 channel; + u8 encoder; + u8 reserved[10]; + be_t downMixer; +}; + +struct CellAudioOutSoundMode +{ + u8 type; + u8 channel; + u8 fs; + u8 reserved; + be_t layout; +}; + +struct CellAudioOutDeviceInfo +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 reserved[3]; + be_t latency; + CellAudioOutSoundMode availableModes[16]; +}; + +struct CellAudioOutState +{ + u8 state; + u8 encoder; + u8 reserved[6]; + be_t downMixer; + CellAudioOutSoundMode soundMode; +}; + +struct CellAudioOutSoundMode2 +{ + u8 type; + u8 channel; + be_t fs; + u8 reserved[4]; +}; + +struct CellAudioOutDeviceInfo2 +{ + u8 portType; + u8 availableModeCount; + u8 state; + u8 deviceNumber; + u8 reserved[12]; + be_t deviceId; + be_t type; + char name[64]; + CellAudioOutSoundMode2 availableModes2[16]; +}; + +struct CellAudioOutOption +{ + //(Omitted) +}; + +struct CellAudioOutRegistrationOption +{ + //(Omitted) +}; + +struct CellAudioOutDeviceConfiguration +{ + //(Omitted) +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp index 4e51060ee0..5499ac05b4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAvconfExt.cpp @@ -4,6 +4,8 @@ #include "Emu/SysCalls/Modules.h" #include "Emu/RSX/sysutil_video.h" +namespace vm { using namespace ps3; } + extern Module cellAvconfExt; s32 cellVideoOutConvertCursorColor() diff --git a/rpcs3/Emu/SysCalls/Modules/cellCamera.h b/rpcs3/Emu/SysCalls/Modules/cellCamera.h index 12ae95270a..e1bc6362ea 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellCamera.h +++ b/rpcs3/Emu/SysCalls/Modules/cellCamera.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 69ca3645d0..011389a65e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellFiber.h b/rpcs3/Emu/SysCalls/Modules/cellFiber.h index cfeaac2323..36c3421c21 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFiber.h +++ b/rpcs3/Emu/SysCalls/Modules/cellFiber.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellFont.h b/rpcs3/Emu/SysCalls/Modules/cellFont.h index 2f4dee8410..9f644ed407 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFont.h +++ b/rpcs3/Emu/SysCalls/Modules/cellFont.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellFontFT.h b/rpcs3/Emu/SysCalls/Modules/cellFontFT.h index fb8a0c109f..541f5f287d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFontFT.h +++ b/rpcs3/Emu/SysCalls/Modules/cellFontFT.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct CellFontLibraryConfigFT { u32 library_addr; //void* diff --git a/rpcs3/Emu/SysCalls/Modules/cellFs.h b/rpcs3/Emu/SysCalls/Modules/cellFs.h index c5cc965795..b74d0df31b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFs.h +++ b/rpcs3/Emu/SysCalls/Modules/cellFs.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct CellFsDirectoryEntry { CellFsStat attribute; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.h b/rpcs3/Emu/SysCalls/Modules/cellGame.h index 284f89a75b..f95f28629a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index bfbfe1eeee..bfad4c783c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -7,6 +7,7 @@ //#include "Emu/RSX/GCM.h" #include "Emu/RSX/GSManager.h" +#include "Emu/RSX/GSRender.h" //#include "Emu/SysCalls/lv2/sys_process.h" #include "cellGcmSys.h" diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.h b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.h index 82c53937f8..58f7a7dc1a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.h @@ -1,4 +1,7 @@ #pragma once + +namespace vm { using namespace ps3; } + #include "Emu/RSX/GCM.h" enum diff --git a/rpcs3/Emu/SysCalls/Modules/cellGem.h b/rpcs3/Emu/SysCalls/Modules/cellGem.h index 712e406998..d86af2edf1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGem.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGem.h @@ -1,7 +1,8 @@ #pragma once -// Had to use define, since enum doesn't allow floats -#define CELL_GEM_SPHERE_RADIUS_MM = 22.5f; +namespace vm { using namespace ps3; } + +static const float CELL_GEM_SPHERE_RADIUS_MM = 22.5f; // Error Codes enum diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.h b/rpcs3/Emu/SysCalls/Modules/cellGifDec.h index ec00dedd82..ebb959dfd0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.h b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.h index 2450eb9977..cbcc60fce9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + //Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellKb.h b/rpcs3/Emu/SysCalls/Modules/cellKb.h index af23ce6226..d1564b6c3d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellKb.h +++ b/rpcs3/Emu/SysCalls/Modules/cellKb.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum CELL_KB_ERROR_CODE { CELL_KB_ERROR_FATAL = 0x80121001, diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index 3bb1b38525..22e62a3fbd 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -33,7 +33,7 @@ s32 UTF16stoUTF8s(vm::ptr utf16, vm::ref utf16_len, vm::ptr // return SRCIllegal; //} - if (utf8) + if (utf8 != vm::null) { if (len > max_len) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.h b/rpcs3/Emu/SysCalls/Modules/cellL10n.h index 74a8b6cec9..0c8057744f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.h +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // L10nResult enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellMic.h b/rpcs3/Emu/SysCalls/Modules/cellMic.h index 4fbc695af2..2050f5aa79 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMic.h +++ b/rpcs3/Emu/SysCalls/Modules/cellMic.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { @@ -20,4 +22,4 @@ enum CELL_MICIN_ERROR_SYSTEM_NOT_FOUND = 0x8014010e, CELL_MICIN_ERROR_FATAL = 0x8014010f, CELL_MICIN_ERROR_DEVICE_NOT_SUPPORT = 0x80140110, -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellMouse.h b/rpcs3/Emu/SysCalls/Modules/cellMouse.h index 123de6076e..02c276fc87 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMouse.h +++ b/rpcs3/Emu/SysCalls/Modules/cellMouse.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum CELL_MOUSE_ERROR_CODE { CELL_MOUSE_ERROR_FATAL = 0x80121201, diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h index 25c1434fcc..f861c054af 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum { CELL_MSGDIALOG_ERROR_PARAM = 0x8002b301, diff --git a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h index 3b3b0db019..adf5f172d5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h +++ b/rpcs3/Emu/SysCalls/Modules/cellNetCtl.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp index 0c9c779f6a..eccb31c7ef 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellOvis.cpp @@ -2,6 +2,8 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" +namespace vm { using namespace ps3; } + extern Module cellOvis; // Return Codes diff --git a/rpcs3/Emu/SysCalls/Modules/cellPad.h b/rpcs3/Emu/SysCalls/Modules/cellPad.h index c87a6c8dc5..bbd12d2b2b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPad.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPad.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum CELL_PAD_ERROR_CODE { CELL_PAD_ERROR_FATAL = 0x80121101, diff --git a/rpcs3/Emu/SysCalls/Modules/cellPamf.h b/rpcs3/Emu/SysCalls/Modules/cellPamf.h index 33904beb97..87eae0c9f6 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPamf.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPamf.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellPng.h b/rpcs3/Emu/SysCalls/Modules/cellPng.h index 3237fcd869..2ea038a9b9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPng.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPng.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum CellPngTxtType { CELL_PNG_TEXT = 0, diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h index 037019fe65..74eced5635 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.h @@ -1,4 +1,7 @@ #pragma once + +namespace vm { using namespace ps3; } + #include "cellPng.h" enum : u32 diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 3cda3208f7..842f5da0a4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -6,6 +6,7 @@ #include "cellSysutil.h" #include "Emu/RSX/sysutil_video.h" #include "Emu/RSX/GSManager.h" +#include "Emu/RSX/GSRender.h" #include "cellResc.h" extern Module cellResc; diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.h b/rpcs3/Emu/SysCalls/Modules/cellResc.h index a2d577a061..6fcb438ec8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.h +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.h @@ -3,6 +3,8 @@ #define roundup(x,a) (((x)+(a)-1)&(~((a)-1))) #define SEVIRITY 80.f +namespace vm { using namespace ps3; } + #include "Emu/RSX/GCM.h" enum diff --git a/rpcs3/Emu/SysCalls/Modules/cellRtc.h b/rpcs3/Emu/SysCalls/Modules/cellRtc.h index 3863de0b01..2c51bac05e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRtc.h +++ b/rpcs3/Emu/SysCalls/Modules/cellRtc.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellRudp.h b/rpcs3/Emu/SysCalls/Modules/cellRudp.h index 0a33a58998..9f3e17c70d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellRudp.h +++ b/rpcs3/Emu/SysCalls/Modules/cellRudp.h @@ -1,3 +1,7 @@ +#pragma once + +namespace vm { using namespace ps3; } + // Return Codes enum { @@ -42,11 +46,11 @@ enum CELL_RUDP_ERROR_KEEP_ALIVE_FAILURE = 0x80770026, }; -typedef vm::ptr(CellRudpAllocatorFuncAlloc)(u32 size); -typedef u32(CellRudpAllocatorFuncFree)(vm::ptr ptr); +using CellRudpAllocatorFuncAlloc = func_def(u32 size)>; +using CellRudpAllocatorFuncFree = func_def ptr)>; struct CellRudpAllocator { - vm::ptr app_malloc; - vm::ptr app_free; -}; \ No newline at end of file + vm::bptr app_malloc; + vm::bptr app_free; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSail.h b/rpcs3/Emu/SysCalls/Modules/cellSail.h index 3f77c94d98..a8fab2b6e9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSail.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSail.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h index 1c9351ca3a..5e7e4e71b5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.h b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.h index 75045278d7..766fd73783 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellScreenshot.h +++ b/rpcs3/Emu/SysCalls/Modules/cellScreenshot.h @@ -1,3 +1,7 @@ +#pragma once + +namespace vm { using namespace ps3; } + // Return Codes enum { @@ -11,7 +15,7 @@ enum struct CellScreenShotSetParam { - const char *photo_title; - const char *game_title; - const char *game_comment; -}; \ No newline at end of file + vm::bcptr photo_title; + vm::bcptr game_title; + vm::bcptr game_comment; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSearch.h b/rpcs3/Emu/SysCalls/Modules/cellSearch.h index 8c61d51018..af72515101 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSearch.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSearch.h @@ -1,3 +1,7 @@ +#pragma once + +namespace vm { using namespace ps3; } + // Error Codes enum { @@ -162,7 +166,7 @@ enum CellSearchEvent CELL_SEARCH_EVENT_SCENESEARCH_RESULT, }; -typedef void(CellSearchSystemCallback)(CellSearchEvent event, s32 result, vm::ptr param, vm::ptr userData); +using CellSearchSystemCallback = func_def param, vm::ptr userData)>; struct CellSearchContentId { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp index 9f96909219..9af59c5bb8 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.cpp @@ -17,7 +17,6 @@ #include "Emu/SysCalls/lv2/sys_process.h" #include "Emu/SysCalls/lv2/sys_semaphore.h" #include "Emu/SysCalls/lv2/sys_event.h" -#include "Emu/Cell/SPURSManager.h" #include "sysPrxForUser.h" #include "cellSpurs.h" @@ -111,7 +110,7 @@ s32 spursInit( u32 sem; for (u32 i = 0; i < 0x10; i++) { - sem = Emu.GetIdManager().make(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl"); + sem = Emu.GetIdManager().make(SYS_SYNC_PRIORITY, 1, *(u64*)"_spuWkl", 0); assert(sem && ~sem); // should rollback if semaphore creation failed and return the error spurs->m.wklF1[i].sem = sem; } @@ -119,12 +118,12 @@ s32 spursInit( { for (u32 i = 0; i < 0x10; i++) { - sem = Emu.GetIdManager().make(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuWkl"); + sem = Emu.GetIdManager().make(SYS_SYNC_PRIORITY, 1, *(u64*)"_spuWkl", 0); assert(sem && ~sem); spurs->m.wklF2[i].sem = sem; } } - sem = Emu.GetIdManager().make(0, 1, SYS_SYNC_PRIORITY, *(u64*)"_spuPrv"); + sem = Emu.GetIdManager().make(SYS_SYNC_PRIORITY, 1, *(u64*)"_spuPrv", 0); assert(sem && ~sem); spurs->m.semPrv = sem; spurs->m.unk11 = -1; @@ -1556,7 +1555,7 @@ s32 cellSpursEventFlagAttachLv2EventQueue(vm::ptr eventFlag) if (eventFlag->m.direction == CELL_SPURS_EVENT_FLAG_ANY2ANY) { vm::var> eventPortId; - rc = sys_event_port_create(vm::ptr::make(eventPortId.addr()), SYS_EVENT_PORT_LOCAL, 0); + rc = sys_event_port_create(vm::ref::make(eventPortId.addr()), SYS_EVENT_PORT_LOCAL, 0); if (rc == CELL_OK) { rc = sys_event_port_connect_local(eventPortId.value(), eventQueueId); diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h index 8a049fc7cf..986f45f1ed 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpurs.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSpurs.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Core return codes. enum { @@ -292,11 +294,6 @@ struct CellSpursAttribute be_t swlMaxSpu; // 0x40 be_t swlIsPreem; // 0x44 } m; - - // alternative implementation - struct - { - } c; }; }; @@ -520,12 +517,6 @@ struct CellSpurs _sub_str1 wklF2[0x10]; // 0x1200 _sub_str4 wklH2[0x10]; // 0x1A00 } m; - - // alternative implementation - struct - { - SPURSManager *spurs; - } c; }; force_inline atomic_be_t& wklState(const u32 wid) @@ -614,8 +605,6 @@ struct CellSpursEventFlag be_t eventPortId; // 0x78 be_t eventQueueId; // 0x7C } m; - - SPURSManagerEventFlag *eventFlag; }; }; @@ -679,8 +668,6 @@ struct CellSpursTaskset u32 event_flag_id2; // 0x189C u8 unk3[0x60]; // 0x18A0 } m; - - SPURSManagerTaskset *taskset; }; }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.h b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.h index 3f59c932d3..8744312ca5 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSpursJq.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSpursJq.h @@ -1,2 +1,3 @@ #pragma once +namespace vm { using namespace ps3; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.h b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.h index 8321a606c0..590a6aa41b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSubdisplay.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { @@ -58,8 +60,8 @@ struct CellSubDisplayParam be_t mode; be_t nGroup; be_t nPeer; - vm::ptr videoParam; - vm::ptr audioParam; + vm::bptr videoParam; + vm::bptr audioParam; }; struct CellSubDisplayPSPId @@ -80,4 +82,4 @@ struct CellSubDisplayPeerInfo CellSubDisplayNickname pspNickname; }; -typedef void(*CellSubDisplayHandler)(s32 cbMsg, u64 cbParam, u32 *userdata); \ No newline at end of file +using CellSubDisplayHandler = func_def userdata)>; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.h b/rpcs3/Emu/SysCalls/Modules/cellSync.h index d5c9430752..b2f1323012 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync2.h b/rpcs3/Emu/SysCalls/Modules/cellSync2.h index b18c3d69a2..d50fade99d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync2.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSync2.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp index 2324e48ffc..3a51927a28 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysmodule.cpp @@ -4,6 +4,8 @@ #include "Emu/SysCalls/ModuleManager.h" #include "Emu/SysCalls/Modules.h" +namespace vm { using namespace ps3; } + extern Module cellSysmodule; enum diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 74c23480c6..3bf5579681 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -10,12 +10,13 @@ #include "rpcs3/Ini.h" #include "Emu/FS/vfsFile.h" #include "Loader/PSF.h" -#include "Emu/Audio/sysutil_audio.h" #include "Emu/RSX/sysutil_video.h" #include "Emu/RSX/GSManager.h" #include "Emu/Audio/AudioManager.h" #include "Emu/FS/VFS.h" #include "cellMsgDialog.h" +#include "cellAudioIn.h" +#include "cellAudioOut.h" #include "cellSysutil.h" extern Module cellSysutil; @@ -479,21 +480,21 @@ int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptrstate = Emu.GetAudioManager().GetState(); - state->encoder = Emu.GetAudioManager().GetInfo().mode.encoder; - state->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer; - state->soundMode.type = Emu.GetAudioManager().GetInfo().mode.type; - state->soundMode.channel = Emu.GetAudioManager().GetInfo().mode.channel; - state->soundMode.fs = Emu.GetAudioManager().GetInfo().mode.fs; + state->state = CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED; + state->encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; + state->downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; + state->soundMode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM; + state->soundMode.channel = CELL_AUDIO_OUT_CHNUM_8; + state->soundMode.fs = CELL_AUDIO_OUT_FS_48KHZ; state->soundMode.reserved = 0; - state->soundMode.layout = Emu.GetAudioManager().GetInfo().mode.layout; + state->soundMode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy; - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; case CELL_AUDIO_OUT_SECONDARY: state->state = CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED; - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; } return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; @@ -509,20 +510,20 @@ int cellAudioOutConfigure(u32 audioOut, vm::ptr confi case CELL_AUDIO_OUT_PRIMARY: if (config->channel) { - Emu.GetAudioManager().GetInfo().mode.channel = config->channel; + //Emu.GetAudioManager().GetInfo().mode.channel = config->channel; } - Emu.GetAudioManager().GetInfo().mode.encoder = config->encoder; + //Emu.GetAudioManager().GetInfo().mode.encoder = config->encoder; if(config->downMixer) { - Emu.GetAudioManager().GetInfo().mode.downMixer = config->downMixer; + //Emu.GetAudioManager().GetInfo().mode.downMixer = config->downMixer; } - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; case CELL_AUDIO_OUT_SECONDARY: - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; } return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; @@ -538,15 +539,15 @@ int cellAudioOutGetConfiguration(u32 audioOut, vm::ptrchannel = Emu.GetAudioManager().GetInfo().mode.channel; - config->encoder = Emu.GetAudioManager().GetInfo().mode.encoder; - config->downMixer = Emu.GetAudioManager().GetInfo().mode.downMixer; + config->channel = CELL_AUDIO_OUT_CHNUM_8; + config->encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; + config->downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; case CELL_AUDIO_OUT_SECONDARY: - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; } return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; @@ -580,7 +581,7 @@ int cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptravailableModes[0].fs = CELL_AUDIO_OUT_FS_48KHZ; info->availableModes[0].layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy; - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; } int cellAudioOutSetCopyControl(u32 audioOut, u32 control) @@ -606,7 +607,7 @@ int cellAudioOutSetCopyControl(u32 audioOut, u32 control) default: return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER; } - return CELL_AUDIO_OUT_SUCCEEDED; + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h index 2c8fd2245c..3eb6435e93 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum { CELL_SYSUTIL_ERROR_TYPE = 0x8002b101, @@ -218,3 +220,39 @@ struct CellWebBrowserConfig2 be_t resolution_factor; be_t magic_number_; }; + +enum CellSysutilBgmPlaybackStatusState +{ + CELL_SYSUTIL_BGMPLAYBACK_STATUS_PLAY = 0, + CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP = 1 +}; + +enum CellSysutilBgmPlaybackStatusEnabled +{ + CELL_SYSUTIL_BGMPLAYBACK_STATUS_ENABLE = 0, + CELL_SYSUTIL_BGMPLAYBACK_STATUS_DISABLE = 1 +}; + +struct CellSysutilBgmPlaybackStatus +{ + u8 playerState; + u8 enableState; + char contentId[16]; + u8 currentFadeRatio; + char reserved[13]; +}; + +struct CellSysutilBgmPlaybackStatus2 +{ + u8 playerState; + char reserved[7]; +}; + +struct CellSysutilBgmPlaybackExtraParam +{ + be_t systemBgmFadeInTime; + be_t systemBgmFadeOutTime; + be_t gameBgmFadeInTime; + be_t gameBgmFadeOutTime; + char reserved[8]; +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp index 915a469dbd..1ccd6ba5cf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp @@ -2,6 +2,8 @@ #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/Modules.h" +namespace vm { using namespace ps3; } + extern Module cellSysutilAp; // Return Codes diff --git a/rpcs3/Emu/SysCalls/Modules/cellUsbd.h b/rpcs3/Emu/SysCalls/Modules/cellUsbd.h index 6259bd9978..56f08c0210 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUsbd.h +++ b/rpcs3/Emu/SysCalls/Modules/cellUsbd.h @@ -1,3 +1,7 @@ +#pragma once + +namespace vm { using namespace ps3; } + // Return Codes enum { @@ -36,4 +40,4 @@ enum USBD_HC_CC_XACT = 0x2, USBD_HC_CC_BABBLE = 0x4, USBD_HC_CC_DATABUF = 0x8, -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h index 5edd525cb6..33192f4f2b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.h b/rpcs3/Emu/SysCalls/Modules/cellVdec.h index 66de0968fe..d48ced76fa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp index e9ed1f9da1..3ffa9c52ad 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVoice.cpp @@ -3,6 +3,8 @@ #include "Emu/System.h" #include "Emu/SysCalls/Modules.h" +namespace vm { using namespace ps3; } + extern Module cellVoice; // Error Codes diff --git a/rpcs3/Emu/SysCalls/Modules/cellVpost.h b/rpcs3/Emu/SysCalls/Modules/cellVpost.h index e69cf9e09a..0cf9577075 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVpost.h +++ b/rpcs3/Emu/SysCalls/Modules/cellVpost.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { @@ -325,4 +327,4 @@ public: : to_rgba(rgba) { } -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/Modules/libmixer.h b/rpcs3/Emu/SysCalls/Modules/libmixer.h index b2f0a19dcd..0ad5f6832e 100644 --- a/rpcs3/Emu/SysCalls/Modules/libmixer.h +++ b/rpcs3/Emu/SysCalls/Modules/libmixer.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error Codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.h b/rpcs3/Emu/SysCalls/Modules/sceNp.h index 35be94177a..bbd1f6d323 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.h @@ -1,4 +1,7 @@ #pragma once + +namespace vm { using namespace ps3; } + #include "cellRtc.h" // Error Codes diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpClans.h b/rpcs3/Emu/SysCalls/Modules/sceNpClans.h index 838458c071..90728adce4 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpClans.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNpClans.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.h b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.h index 90e30569d7..804e7d84a7 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNpCommerce2.h @@ -1,4 +1,7 @@ #pragma once + +namespace vm { using namespace ps3; } + #include "cellRtc.h" // Return codes diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpSns.h b/rpcs3/Emu/SysCalls/Modules/sceNpSns.h index 874ea96be1..274c982291 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpSns.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNpSns.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.h b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.h index bcb857cc04..5d5a0a5da8 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Error codes enum { diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTus.h b/rpcs3/Emu/SysCalls/Modules/sceNpTus.h index 865a725e78..a03e985379 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTus.h +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTus.h @@ -1,4 +1,7 @@ #pragma once + +namespace vm { using namespace ps3; } + #include "cellRtc.h" // Constants for TUS functions and structures diff --git a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h index 41aa474d9f..bb9c3c23cf 100644 --- a/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h +++ b/rpcs3/Emu/SysCalls/Modules/sysPrxForUser.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct HeapInfo { const std::string name; diff --git a/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp b/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp index 858263109e..2b181989c2 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_libc.cpp @@ -4,6 +4,8 @@ #include "Emu/SysCalls/Modules.h" #include "Emu/Cell/PPUInstrTable.h" +namespace vm { using namespace ps3; } + extern Module sys_libc; namespace sys_libc_func diff --git a/rpcs3/Emu/SysCalls/Modules/sys_net.h b/rpcs3/Emu/SysCalls/Modules/sys_net.h index 37b04d05eb..939ec86227 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_net.h +++ b/rpcs3/Emu/SysCalls/Modules/sys_net.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_net_initialize_parameter { be_t memory_addr; diff --git a/rpcs3/Emu/Audio/sysutil_audio.h b/rpcs3/Emu/SysCalls/Modules/sysutil_audio.h similarity index 99% rename from rpcs3/Emu/Audio/sysutil_audio.h rename to rpcs3/Emu/SysCalls/Modules/sysutil_audio.h index 2fd567461f..ca09ee29d1 100644 --- a/rpcs3/Emu/Audio/sysutil_audio.h +++ b/rpcs3/Emu/SysCalls/Modules/sysutil_audio.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + //error codes enum AudioErrorCode { diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index fc3652a1f8..58ebf522c4 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -4,7 +4,7 @@ #include "Utilities/AutoPause.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" -#include "ModuleManager.h" +#include "Modules.h" #include "lv2/sleep_queue.h" #include "lv2/sys_lwmutex.h" diff --git a/rpcs3/Emu/SysCalls/lv2/sleep_queue.h b/rpcs3/Emu/SysCalls/lv2/sleep_queue.h index 4b3a157888..c1c8167f08 100644 --- a/rpcs3/Emu/SysCalls/lv2/sleep_queue.h +++ b/rpcs3/Emu/SysCalls/lv2/sleep_queue.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // attr_protocol (waiting scheduling policy) enum { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index 2d22b1cb6e..b72ebbebc6 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -13,7 +13,7 @@ SysCallBase sys_cond("sys_cond"); -s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptr attr) +s32 sys_cond_create(vm::ref cond_id, u32 mutex_id, vm::ptr attr) { sys_cond.Warning("sys_cond_create(cond_id=*0x%x, mutex_id=0x%x, attr=*0x%x)", cond_id, mutex_id, attr); @@ -37,7 +37,7 @@ s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptr(mutex, attr->name_u64); + cond_id = Emu.GetIdManager().make(mutex, attr->name_u64); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.h b/rpcs3/Emu/SysCalls/lv2/sys_cond.h index ee61ee9912..c12c5485bb 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct lv2_mutex_t; struct sys_cond_attribute_t @@ -40,7 +42,7 @@ REG_ID_TYPE(lv2_cond_t, 0x86); // SYS_COND_OBJECT class PPUThread; // SysCalls -s32 sys_cond_create(vm::ptr cond_id, u32 mutex_id, vm::ptr attr); +s32 sys_cond_create(vm::ref cond_id, u32 mutex_id, vm::ptr attr); s32 sys_cond_destroy(u32 cond_id); s32 sys_cond_wait(PPUThread& CPU, u32 cond_id, u64 timeout); s32 sys_cond_signal(u32 cond_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp index ab64c03805..7a6ab22d41 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp @@ -13,7 +13,7 @@ SysCallBase sys_event("sys_event"); -s32 sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) +s32 sys_event_queue_create(vm::ref equeue_id, vm::ptr attr, u64 event_queue_key, s32 size) { sys_event.Warning("sys_event_queue_create(equeue_id=*0x%x, attr=*0x%x, event_queue_key=0x%llx, size=%d)", equeue_id, attr, event_queue_key, size); @@ -47,7 +47,7 @@ s32 sys_event_queue_create(vm::ptr equeue_id, vm::ptr return CELL_EEXIST; } - *equeue_id = Emu.GetIdManager().add(std::move(queue)); + equeue_id = Emu.GetIdManager().add(std::move(queue)); return CELL_OK; } @@ -91,7 +91,7 @@ s32 sys_event_queue_destroy(u32 equeue_id, s32 mode) return CELL_OK; } -s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr number) +s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ref number) { sys_event.Log("sys_event_queue_tryreceive(equeue_id=0x%x, event_array=*0x%x, size=%d, number=*0x%x)", equeue_id, event_array, size, number); @@ -124,7 +124,7 @@ s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, queue->events.pop_front(); } - *number = count; + number = count; return CELL_OK; } @@ -206,7 +206,7 @@ s32 sys_event_queue_drain(u32 equeue_id) return CELL_OK; } -s32 sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name) +s32 sys_event_port_create(vm::ref eport_id, s32 port_type, u64 name) { sys_event.Warning("sys_event_port_create(eport_id=*0x%x, port_type=%d, name=0x%llx)", eport_id, port_type, name); @@ -216,7 +216,7 @@ s32 sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name) return CELL_EINVAL; } - *eport_id = Emu.GetIdManager().make(port_type, name); + eport_id = Emu.GetIdManager().make(port_type, name); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.h b/rpcs3/Emu/SysCalls/lv2/sys_event.h index 8d10f379b3..23ad59f319 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Event Queue Type enum : u32 { @@ -128,13 +130,13 @@ REG_ID_TYPE(lv2_event_port_t, 0x0E); // SYS_EVENT_PORT_OBJECT class PPUThread; // SysCalls -s32 sys_event_queue_create(vm::ptr equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); +s32 sys_event_queue_create(vm::ref equeue_id, vm::ptr attr, u64 event_queue_key, s32 size); s32 sys_event_queue_destroy(u32 equeue_id, s32 mode); s32 sys_event_queue_receive(PPUThread& CPU, u32 equeue_id, vm::ptr dummy_event, u64 timeout); -s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ptr number); +s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, s32 size, vm::ref number); s32 sys_event_queue_drain(u32 event_queue_id); -s32 sys_event_port_create(vm::ptr eport_id, s32 port_type, u64 name); +s32 sys_event_port_create(vm::ref eport_id, s32 port_type, u64 name); s32 sys_event_port_destroy(u32 eport_id); s32 sys_event_port_connect_local(u32 event_port_id, u32 event_queue_id); s32 sys_event_port_disconnect(u32 eport_id); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h index 348d5c736c..066b0d14ea 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum { SYS_SYNC_WAITER_SINGLE = 0x10000, diff --git a/rpcs3/Emu/SysCalls/lv2/sys_fs.h b/rpcs3/Emu/SysCalls/lv2/sys_fs.h index bc53cbd904..7597b0a845 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_fs.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_fs.h @@ -1,6 +1,9 @@ #pragma once + #include "Utilities/Thread.h" +namespace vm { using namespace ps3; } + #pragma pack(push, 4) // Error Codes diff --git a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h index 4420ee78f5..db4d6fde6f 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_interrupt.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + class PPUThread; struct lv2_int_handler_t diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.h b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.h index 52a822adc7..a01467259a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_lwmutex_t; struct sys_lwcond_attribute_t diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.h b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.h index 0543b24cb6..1870abc948 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwmutex.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_lwmutex_attribute_t { be_t protocol; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.h b/rpcs3/Emu/SysCalls/lv2/sys_memory.h index f0cf7e7ac4..998c39e095 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum : u32 { SYS_MEMORY_CONTAINER_ID_INVALID = 0xFFFFFFFF, diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h index a32000d347..cb1ed3aff2 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_mmapper.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + #define SYS_MMAPPER_FIXED_ADDR 0xB0000000 #define SYS_MMAPPER_FIXED_SIZE 0x10000000 diff --git a/rpcs3/Emu/SysCalls/lv2/sys_mutex.h b/rpcs3/Emu/SysCalls/lv2/sys_mutex.h index b111aa4f31..ccc8312abb 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_mutex.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_mutex.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_mutex_attribute_t { be_t protocol; // SYS_SYNC_FIFO, SYS_SYNC_PRIORITY or SYS_SYNC_PRIORITY_INHERIT diff --git a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h index 8aeb276359..e827040afd 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_ppu_thread.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + class PPUThread; enum : u32 diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.h b/rpcs3/Emu/SysCalls/lv2/sys_process.h index b055e452a0..cb43cd5cb1 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Process Local Object Type enum : u32 { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_prx.h b/rpcs3/Emu/SysCalls/lv2/sys_prx.h index d0b329cfe6..61cfd740b8 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_prx.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_prx.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // Return codes enum { @@ -28,6 +30,39 @@ enum CELL_PRX_ERROR_ELF_IS_REGISTERED = 0x80011910, // Fixed ELF is already registered }; +struct sys_stub +{ + u8 s_size; // = 0x2c + u8 s_unk0; + be_t s_version; // = 0x1 + be_t s_unk1; // = 0x9 // flags? + be_t s_imports; + be_t s_unk2; // = 0x0 + be_t s_unk3; // = 0x0 + vm::bptr s_modulename; + vm::bptr s_nid; + vm::bptr s_text; + be_t s_unk4; // = 0x0 + be_t s_unk5; // = 0x0 + be_t s_unk6; // = 0x0 + be_t s_unk7; // = 0x0 +}; + +struct sys_proc_prx_param +{ + be_t size; + be_t magic; + be_t version; + be_t pad0; + be_t libentstart; + be_t libentend; + vm::bptr libstubstart; + vm::bptr libstubend; + be_t ver; + be_t pad1; + be_t pad2; +}; + // Information about imported or exported libraries in PRX modules struct sys_prx_library_info_t { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rsx.h b/rpcs3/Emu/SysCalls/lv2/sys_rsx.h index f44254cef5..3eb214a83c 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rsx.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_rsx.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // SysCalls s32 sys_rsx_device_open(); s32 sys_rsx_device_close(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h index cb3d73a575..1c0ff707c6 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_rwlock.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_rwlock_attribute_t { be_t protocol; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h index a0e98a97ba..25a0071cc0 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + struct sys_semaphore_attribute_t { be_t protocol; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_spu.h b/rpcs3/Emu/SysCalls/lv2/sys_spu.h index 590d93dead..ca2f3d5180 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_spu.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_spu.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + #include "sys_event.h" enum : s32 diff --git a/rpcs3/Emu/SysCalls/lv2/sys_time.h b/rpcs3/Emu/SysCalls/lv2/sys_time.h index dacff931e0..1ead891134 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_time.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_time.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum : u32 { MHZ = 1000000, diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp index 3bc6592e11..6b214719a8 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp @@ -12,46 +12,58 @@ SysCallBase sys_timer("sys_timer"); -s32 sys_timer_create(vm::ptr timer_id) +lv2_timer_t::lv2_timer_t() + : start(0) + , period(0) + , state(SYS_TIMER_STATE_STOP) + , thread(fmt::format("Timer[0x%x] Thread", Emu.GetIdManager().get_current_id())) { - sys_timer.Warning("sys_timer_create(timer_id=*0x%x)", timer_id); - - std::shared_ptr timer(new lv2_timer_t); - - thread_t(fmt::format("Timer[0x%x] Thread", (*timer_id = Emu.GetIdManager().add(timer))), [timer]() // TODO: call from the constructor + thread.start([this]() { LV2_LOCK; - while (!timer.unique() && !Emu.IsStopped()) + while (thread.joinable() && !Emu.IsStopped()) { - if (timer->state == SYS_TIMER_STATE_RUN) + if (state == SYS_TIMER_STATE_RUN) { - if (get_system_time() >= timer->start) + if (get_system_time() >= start) { - const auto queue = timer->port.lock(); + const auto queue = port.lock(); if (queue) { - queue->push(lv2_lock, timer->source, timer->data1, timer->data2, timer->start); + queue->push(lv2_lock, source, data1, data2, start); } - if (timer->period && queue) + if (period && queue) { - timer->start += timer->period; // set next expiration time + start += period; // set next expiration time continue; // hack: check again } else { - timer->state = SYS_TIMER_STATE_STOP; // stop if oneshot or the event port was disconnected (TODO: is it correct?) + state = SYS_TIMER_STATE_STOP; // stop if oneshot or the event port was disconnected (TODO: is it correct?) } } } - timer->cv.wait_for(lv2_lock, std::chrono::milliseconds(1)); + cv.wait_for(lv2_lock, std::chrono::milliseconds(1)); } + }); +} - }).detach(); +lv2_timer_t::~lv2_timer_t() +{ + cv.notify_all(); + thread.join(); +} + +s32 sys_timer_create(vm::ref timer_id) +{ + sys_timer.Warning("sys_timer_create(timer_id=*0x%x)", timer_id); + + timer_id = Emu.GetIdManager().make(); return CELL_OK; } @@ -60,8 +72,6 @@ s32 sys_timer_destroy(u32 timer_id) { sys_timer.Warning("sys_timer_destroy(timer_id=0x%x)", timer_id); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -69,6 +79,8 @@ s32 sys_timer_destroy(u32 timer_id) return CELL_ESRCH; } + LV2_LOCK; + if (!timer->port.expired()) { return CELL_EISCONN; @@ -83,8 +95,6 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr inf { sys_timer.Warning("sys_timer_get_information(timer_id=0x%x, info=*0x%x)", timer_id, info); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -92,6 +102,8 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr inf return CELL_ESRCH; } + LV2_LOCK; + info->next_expiration_time = timer->start; info->period = timer->period; @@ -106,8 +118,6 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period) const u64 start_time = get_system_time(); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -115,6 +125,8 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period) return CELL_ESRCH; } + LV2_LOCK; + if (timer->state != SYS_TIMER_STATE_STOP) { return CELL_EBUSY; @@ -158,8 +170,6 @@ s32 sys_timer_stop(u32 timer_id) { sys_timer.Warning("sys_timer_stop()"); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -167,6 +177,8 @@ s32 sys_timer_stop(u32 timer_id) return CELL_ESRCH; } + LV2_LOCK; + timer->state = SYS_TIMER_STATE_STOP; // stop timer return CELL_OK; @@ -176,8 +188,6 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data { sys_timer.Warning("sys_timer_connect_event_queue(timer_id=0x%x, queue_id=0x%x, name=0x%llx, data1=0x%llx, data2=0x%llx)", timer_id, queue_id, name, data1, data2); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); const auto queue = Emu.GetIdManager().get(queue_id); @@ -186,6 +196,8 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data return CELL_ESRCH; } + LV2_LOCK; + if (!timer->port.expired()) { return CELL_EISCONN; @@ -203,8 +215,6 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id) { sys_timer.Warning("sys_timer_disconnect_event_queue(timer_id=0x%x)", timer_id); - LV2_LOCK; - const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -212,6 +222,8 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id) return CELL_ESRCH; } + LV2_LOCK; + if (timer->port.expired()) { return CELL_ENOTCONN; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.h b/rpcs3/Emu/SysCalls/lv2/sys_timer.h index 257d779b3d..5e69d20c88 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.h @@ -1,5 +1,9 @@ #pragma once +#include "Utilities/Thread.h" + +namespace vm { using namespace ps3; } + // Timer State enum : u32 { @@ -29,17 +33,15 @@ struct lv2_timer_t std::atomic state; // timer state std::condition_variable cv; - lv2_timer_t() - : start(0) - , period(0) - , state(SYS_TIMER_STATE_STOP) - { - } + thread_t thread; // timer thread + + lv2_timer_t(); + ~lv2_timer_t(); }; REG_ID_TYPE(lv2_timer_t, 0x11); // SYS_TIMER_OBJECT -s32 sys_timer_create(vm::ptr timer_id); +s32 sys_timer_create(vm::ref timer_id); s32 sys_timer_destroy(u32 timer_id); s32 sys_timer_get_information(u32 timer_id, vm::ptr info); s32 _sys_timer_start(u32 timer_id, u64 basetime, u64 period); // basetime type changed from s64 diff --git a/rpcs3/Emu/SysCalls/lv2/sys_trace.h b/rpcs3/Emu/SysCalls/lv2/sys_trace.h index 5b253893c3..43be75ff47 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_trace.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_trace.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // SysCalls s32 sys_trace_create(); s32 sys_trace_start(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_tty.h b/rpcs3/Emu/SysCalls/lv2/sys_tty.h index 602acda625..6207a51b4f 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_tty.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_tty.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + // TTY channels enum { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_vm.h b/rpcs3/Emu/SysCalls/lv2/sys_vm.h index d803063eab..fced0279d6 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_vm.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_vm.h @@ -1,5 +1,7 @@ #pragma once +namespace vm { using namespace ps3; } + enum : u64 { SYS_VM_TEST_INVALID = 0, diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 11ef295559..9d6dda7650 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -5,8 +5,6 @@ #include "Emu/System.h" #include "Emu/GameInfo.h" -#include "Emu/ARMv7/PSVFuncList.h" -#include "Emu/ARMv7/PSVObjectList.h" #include "Emu/SysCalls/ModuleManager.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/SPUThread.h" @@ -41,6 +39,9 @@ extern std::atomic g_thread_count; extern void finalize_ppu_exec_map(); +extern void finalize_psv_modules(); +extern void clear_all_psv_objects(); + Emulator::Emulator() : m_status(Stopped) , m_mode(DisAsm) @@ -219,7 +220,7 @@ void Emulator::Load() } LOG_NOTICE(LOADER, "Loading '%s'...", m_path.c_str()); - GetInfo().Reset(); + ResetInfo(); GetVFS().Init(elf_dir); // /dev_bdvd/ mounting diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 3617b42b61..96d60ff3ee 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -26,38 +26,20 @@ struct VFS; struct EmuInfo { private: - u32 tls_addr; - u32 tls_filesz; - u32 tls_memsz; + friend class Emulator; - sys_process_param_info proc_param; + u32 m_tls_addr = 0; + u32 m_tls_filesz = 0; + u32 m_tls_memsz = 0; + u32 m_sdk_version = 0x360001; + u32 m_malloc_pagesize = 0x100000; + u32 m_primary_stacksize = 0x100000; + u32 m_primary_prio = 0x50; public: - EmuInfo() { Reset(); } - - sys_process_param_info& GetProcParam() { return proc_param; } - - void Reset() + EmuInfo() { - SetTLSData(0, 0, 0); - memset(&proc_param, 0, sizeof(sys_process_param_info)); - - proc_param.malloc_pagesize = be_t::make(0x100000); - proc_param.sdk_version = be_t::make(0x360001); - proc_param.primary_stacksize = be_t::make(0x100000); - proc_param.primary_prio = be_t::make(0x50); } - - void SetTLSData(u32 addr, u32 filesz, u32 memsz) - { - tls_addr = addr; - tls_filesz = filesz; - tls_memsz = memsz; - } - - u32 GetTLSAddr() const { return tls_addr; } - u32 GetTLSFilesz() const { return tls_filesz; } - u32 GetTLSMemsz() const { return tls_memsz; } }; class Emulator @@ -151,9 +133,25 @@ public: EventManager& GetEventManager() { return *m_event_manager; } ModuleManager& GetModuleManager() { return *m_module_manager; } + void ResetInfo() + { + m_info.~EmuInfo(); + new (&m_info) EmuInfo(); + } + void SetTLSData(u32 addr, u32 filesz, u32 memsz) { - m_info.SetTLSData(addr, filesz, memsz); + m_info.m_tls_addr = addr; + m_info.m_tls_filesz = filesz; + m_info.m_tls_memsz = memsz; + } + + void SetParams(u32 sdk_ver, u32 malloc_pagesz, u32 stacksz, u32 prio) + { + m_info.m_sdk_version = sdk_ver; + m_info.m_malloc_pagesize = malloc_pagesz; + m_info.m_primary_stacksize = stacksz; + m_info.m_primary_prio = prio; } void SetRSXCallback(u32 addr) @@ -166,14 +164,14 @@ public: m_cpu_thr_stop = addr; } - EmuInfo& GetInfo() { return m_info; } + u32 GetTLSAddr() const { return m_info.m_tls_addr; } + u32 GetTLSFilesz() const { return m_info.m_tls_filesz; } + u32 GetTLSMemsz() const { return m_info.m_tls_memsz; } - u32 GetTLSAddr() const { return m_info.GetTLSAddr(); } - u32 GetTLSFilesz() const { return m_info.GetTLSFilesz(); } - u32 GetTLSMemsz() const { return m_info.GetTLSMemsz(); } - - u32 GetMallocPageSize() { return m_info.GetProcParam().malloc_pagesize; } - u32 GetSDKVersion() { return m_info.GetProcParam().sdk_version; } + u32 GetMallocPageSize() { return m_info.m_malloc_pagesize; } + u32 GetSDKVersion() { return m_info.m_sdk_version; } + u32 GetPrimaryStackSize() { return m_info.m_primary_stacksize; } + u32 GetPrimaryPrio() { return m_info.m_primary_prio; } u32 GetRSXCallback() const { return m_rsx_callback; } u32 GetCPUThreadStop() const { return m_cpu_thr_stop; } diff --git a/rpcs3/Gui/InstructionEditor.h b/rpcs3/Gui/InstructionEditor.h index 75ee526645..5fdf69e76f 100644 --- a/rpcs3/Gui/InstructionEditor.h +++ b/rpcs3/Gui/InstructionEditor.h @@ -73,7 +73,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh s_panel_margin_x->AddSpacer(12); this->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(InstructionEditorDialog::updatePreview)); - t2_instr->SetValue(wxString::Format("%08x", vm::read32(CPU->offset + pc))); + t2_instr->SetValue(wxString::Format("%08x", vm::ps3::read32(CPU->offset + pc))); this->SetSizerAndFit(s_panel_margin_x); @@ -83,7 +83,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh if (!t2_instr->GetValue().ToULong(&opcode, 16)) wxMessageBox("This instruction could not be parsed.\nNo changes were made.","Error"); else - vm::write32(CPU->offset + pc, (u32)opcode); + vm::ps3::write32(CPU->offset + pc, (u32)opcode); } } diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index aa1487a187..3102cbf738 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -8,6 +8,7 @@ #include "RSXDebugger.h" #include "Emu/RSX/sysutil_video.h" #include "Emu/RSX/GSManager.h" +#include "Emu/RSX/GSRender.h" //#include "Emu/RSX/GCM.h" #include "MemoryViewer.h" diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 0a25330f96..e0d1f65af5 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -6,6 +6,7 @@ #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" +#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/ModuleManager.h" #include "Emu/SysCalls/lv2/sys_prx.h" #include "Emu/Cell/PPUInstrTable.h" @@ -622,29 +623,39 @@ namespace loader { if (phdr.p_filesz) { - const sys_process_param& proc_param = *(sys_process_param*)phdr.p_vaddr.get_ptr(); + struct process_param_t + { + be_t size; + be_t magic; + be_t version; + be_t sdk_version; + be_t primary_prio; + be_t primary_stacksize; + be_t malloc_pagesize; + be_t ppc_seg; + //be_t crash_dump_param_addr; + }; - if (proc_param.size < sizeof(sys_process_param)) + const auto& info = *(process_param_t*)phdr.p_vaddr.get_ptr(); + + if (info.size < sizeof(process_param_t)) { - LOG_WARNING(LOADER, "Bad process_param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param)); + LOG_WARNING(LOADER, "Bad process_param size! [0x%x : 0x%x]", info.size, sizeof32(process_param_t)); } - if (proc_param.magic != 0x13bcc5f6) + if (info.magic != 0x13bcc5f6) { - LOG_ERROR(LOADER, "Bad process_param magic! [0x%x]", proc_param.magic); + LOG_ERROR(LOADER, "Bad process_param magic! [0x%x]", info.magic); } else { - sys_process_param_info& info = Emu.GetInfo().GetProcParam(); - /* LOG_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version); LOG_NOTICE(LOADER, "*** primary prio: %d", info.primary_prio); LOG_NOTICE(LOADER, "*** primary stacksize: 0x%x", info.primary_stacksize); LOG_NOTICE(LOADER, "*** malloc pagesize: 0x%x", info.malloc_pagesize); LOG_NOTICE(LOADER, "*** ppc seg: 0x%x", info.ppc_seg); //LOG_NOTICE(LOADER, "*** crash dump param addr: 0x%x", info.crash_dump_param_addr); - */ - info = proc_param.info; + Emu.SetParams(info.sdk_version, info.malloc_pagesize, info.primary_stacksize, info.primary_prio); } } break; @@ -704,6 +715,10 @@ namespace loader } break; } + default: + { + LOG_ERROR(LOADER, "Unknown phdr type (0x%08x)", phdr.p_type); + } } } diff --git a/rpcs3/Loader/ELF64.h b/rpcs3/Loader/ELF64.h index 8580c5be69..ab2c455b98 100644 --- a/rpcs3/Loader/ELF64.h +++ b/rpcs3/Loader/ELF64.h @@ -40,8 +40,8 @@ namespace loader be_t p_type; be_t p_flags; be_t p_offset; - bptr p_vaddr; - bptr p_paddr; + _ptr_base> p_vaddr; + _ptr_base> p_paddr; be_t p_filesz; be_t p_memsz; be_t p_align; @@ -52,7 +52,7 @@ namespace loader be_t sh_name; be_t sh_type; be_t sh_flags; - bptr sh_addr; + _ptr_base> sh_addr; be_t sh_offset; be_t sh_size; be_t sh_link; @@ -120,10 +120,10 @@ namespace loader struct sprx_segment_info { - vm::ptr begin; + _ptr_base begin; u32 size; u32 size_file; - vm::ptr initial_addr; + _ptr_base initial_addr; std::vector modules; }; @@ -161,4 +161,4 @@ namespace loader std::string sprx_get_module_name() const { return m_sprx_module_info.name; } }; } -} \ No newline at end of file +} diff --git a/rpcs3/Loader/Loader.h b/rpcs3/Loader/Loader.h index 0cafa3554a..0b6834ccbd 100644 --- a/rpcs3/Loader/Loader.h +++ b/rpcs3/Loader/Loader.h @@ -48,57 +48,6 @@ const std::string Ehdr_MachineToString(const u16 machine); const std::string Phdr_FlagsToString(u32 flags); const std::string Phdr_TypeToString(const u32 type); -struct sys_process_param_info -{ - be_t sdk_version; - be_t primary_prio; - be_t primary_stacksize; - be_t malloc_pagesize; - be_t ppc_seg; - //be_t crash_dump_param_addr; -}; - -struct sys_process_param -{ - be_t size; - be_t magic; - be_t version; - sys_process_param_info info; -}; - -struct sys_stub -{ - u8 s_size; // = 0x2c - u8 s_unk0; - be_t s_version; // = 0x1 - be_t s_unk1; // = 0x9 // flags? - be_t s_imports; - be_t s_unk2; // = 0x0 - be_t s_unk3; // = 0x0 - vm::bptr s_modulename; - vm::bptr s_nid; - vm::bptr s_text; - be_t s_unk4; // = 0x0 - be_t s_unk5; // = 0x0 - be_t s_unk6; // = 0x0 - be_t s_unk7; // = 0x0 -}; - -struct sys_proc_prx_param -{ - be_t size; - be_t magic; - be_t version; - be_t pad0; - be_t libentstart; - be_t libentend; - vm::bptr libstubstart; - vm::bptr libstubend; - be_t ver; - be_t pad1; - be_t pad2; -}; - namespace loader { class handler diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 970570fae7..1826d79f2a 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -143,7 +143,6 @@ - @@ -174,7 +173,6 @@ - @@ -379,7 +377,6 @@ - @@ -432,7 +429,6 @@ - @@ -474,6 +470,8 @@ + + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index aa8ddbdc0e..b6a768876b 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -353,9 +353,6 @@ Emu\CPU\Cell - - Emu\CPU\Cell - Emu\CPU\Cell @@ -575,9 +572,6 @@ Emu\GPU\RSX - - Emu\GPU\RSX - Emu\GPU\RSX @@ -1162,9 +1156,6 @@ Emu\CPU\Cell - - Emu\CPU\Cell - Emu\CPU\Cell @@ -1366,9 +1357,6 @@ Emu\GPU\RSX - - Emu\GPU\RSX - Emu\GPU\RSX @@ -1573,5 +1561,11 @@ Emu\GPU\RSX\GL + + Emu\SysCalls\Modules + + + Emu\SysCalls\Modules + \ No newline at end of file