mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-02-16 18:19:17 +01:00
coreinit: Use native COS locks instead of STL
This commit is contained in:
parent
14dd7a72a7
commit
2a735f1fb7
@ -42,17 +42,16 @@ bool strcpy_whole(char* dst, size_t dstLength, const char* src)
|
|||||||
|
|
||||||
namespace coreinit
|
namespace coreinit
|
||||||
{
|
{
|
||||||
std::mutex sFSClientLock;
|
SysAllocator<OSMutex> s_fsGlobalMutex;
|
||||||
std::recursive_mutex sFSGlobalMutex;
|
|
||||||
|
|
||||||
inline void FSLockMutex()
|
inline void FSLockMutex()
|
||||||
{
|
{
|
||||||
sFSGlobalMutex.lock();
|
OSLockMutex(&s_fsGlobalMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FSUnlockMutex()
|
inline void FSUnlockMutex()
|
||||||
{
|
{
|
||||||
sFSGlobalMutex.unlock();
|
OSUnlockMutex(&s_fsGlobalMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _debugVerifyCommand(const char* stage, FSCmdBlockBody_t* fsCmdBlockBody);
|
void _debugVerifyCommand(const char* stage, FSCmdBlockBody_t* fsCmdBlockBody);
|
||||||
@ -251,7 +250,7 @@ namespace coreinit
|
|||||||
fsCmdQueueBE->dequeueHandlerFuncMPTR = _swapEndianU32(dequeueHandlerFuncMPTR);
|
fsCmdQueueBE->dequeueHandlerFuncMPTR = _swapEndianU32(dequeueHandlerFuncMPTR);
|
||||||
fsCmdQueueBE->numCommandsInFlight = 0;
|
fsCmdQueueBE->numCommandsInFlight = 0;
|
||||||
fsCmdQueueBE->numMaxCommandsInFlight = numMaxCommandsInFlight;
|
fsCmdQueueBE->numMaxCommandsInFlight = numMaxCommandsInFlight;
|
||||||
coreinit::OSInitMutexEx(&fsCmdQueueBE->mutex, nullptr);
|
coreinit::OSFastMutex_Init(&fsCmdQueueBE->fastMutex, nullptr);
|
||||||
fsCmdQueueBE->firstMPTR = _swapEndianU32(0);
|
fsCmdQueueBE->firstMPTR = _swapEndianU32(0);
|
||||||
fsCmdQueueBE->lastMPTR = _swapEndianU32(0);
|
fsCmdQueueBE->lastMPTR = _swapEndianU32(0);
|
||||||
}
|
}
|
||||||
@ -672,12 +671,12 @@ namespace coreinit
|
|||||||
_debugVerifyCommand("FSCmdSubmitResult", fsCmdBlockBody);
|
_debugVerifyCommand("FSCmdSubmitResult", fsCmdBlockBody);
|
||||||
|
|
||||||
FSClientBody_t* fsClientBody = fsCmdBlockBody->fsClientBody.GetPtr();
|
FSClientBody_t* fsClientBody = fsCmdBlockBody->fsClientBody.GetPtr();
|
||||||
sFSClientLock.lock(); // OSFastMutex_Lock(&fsClientBody->fsCmdQueue.mutex)
|
OSFastMutex_Lock(&fsClientBody->fsCmdQueue.fastMutex);
|
||||||
fsCmdBlockBody->cancelState &= ~(1 << 0); // clear cancel bit
|
fsCmdBlockBody->cancelState &= ~(1 << 0); // clear cancel bit
|
||||||
if (fsClientBody->currentCmdBlockBody.GetPtr() == fsCmdBlockBody)
|
if (fsClientBody->currentCmdBlockBody.GetPtr() == fsCmdBlockBody)
|
||||||
fsClientBody->currentCmdBlockBody = nullptr;
|
fsClientBody->currentCmdBlockBody = nullptr;
|
||||||
fsCmdBlockBody->statusCode = _swapEndianU32(FSA_CMD_STATUS_CODE_D900A24);
|
fsCmdBlockBody->statusCode = _swapEndianU32(FSA_CMD_STATUS_CODE_D900A24);
|
||||||
sFSClientLock.unlock();
|
OSFastMutex_Unlock(&fsClientBody->fsCmdQueue.fastMutex);
|
||||||
// send result via msg queue or callback
|
// send result via msg queue or callback
|
||||||
cemu_assert_debug(!fsCmdBlockBody->asyncResult.fsAsyncParamsNew.ioMsgQueue != !fsCmdBlockBody->asyncResult.fsAsyncParamsNew.userCallback); // either must be set
|
cemu_assert_debug(!fsCmdBlockBody->asyncResult.fsAsyncParamsNew.ioMsgQueue != !fsCmdBlockBody->asyncResult.fsAsyncParamsNew.userCallback); // either must be set
|
||||||
fsCmdBlockBody->ukn09EA = 0;
|
fsCmdBlockBody->ukn09EA = 0;
|
||||||
@ -1433,7 +1432,7 @@ namespace coreinit
|
|||||||
return (FSStatus)FS_RESULT::SUCCESS;
|
return (FSStatus)FS_RESULT::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask)
|
sint32 FSAppendFile(FSClient_t* fsClient, FSCmdBlock_t* fsCmdBlock, uint32 size, uint32 count, uint32 fileHandle, uint32 errorMask)
|
||||||
{
|
{
|
||||||
StackAllocator<FSAsyncParamsNew_t> asyncParams;
|
StackAllocator<FSAsyncParamsNew_t> asyncParams;
|
||||||
__FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams);
|
__FSAsyncToSyncInit(fsClient, fsCmdBlock, asyncParams);
|
||||||
@ -2640,6 +2639,8 @@ namespace coreinit
|
|||||||
|
|
||||||
void InitializeFS()
|
void InitializeFS()
|
||||||
{
|
{
|
||||||
|
OSInitMutex(&s_fsGlobalMutex);
|
||||||
|
|
||||||
cafeExportRegister("coreinit", FSInit, LogType::CoreinitFile);
|
cafeExportRegister("coreinit", FSInit, LogType::CoreinitFile);
|
||||||
cafeExportRegister("coreinit", FSShutdown, LogType::CoreinitFile);
|
cafeExportRegister("coreinit", FSShutdown, LogType::CoreinitFile);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ namespace coreinit
|
|||||||
|
|
||||||
/* +0x00 */ MPTR firstMPTR;
|
/* +0x00 */ MPTR firstMPTR;
|
||||||
/* +0x04 */ MPTR lastMPTR;
|
/* +0x04 */ MPTR lastMPTR;
|
||||||
/* +0x08 */ OSMutex mutex;
|
/* +0x08 */ OSFastMutex fastMutex;
|
||||||
/* +0x34 */ MPTR dequeueHandlerFuncMPTR;
|
/* +0x34 */ MPTR dequeueHandlerFuncMPTR;
|
||||||
/* +0x38 */ uint32be numCommandsInFlight;
|
/* +0x38 */ uint32be numCommandsInFlight;
|
||||||
/* +0x3C */ uint32 numMaxCommandsInFlight;
|
/* +0x3C */ uint32 numMaxCommandsInFlight;
|
||||||
@ -50,6 +50,8 @@ namespace coreinit
|
|||||||
};
|
};
|
||||||
DEFINE_ENUM_FLAG_OPERATORS(FSCmdQueue::QUEUE_FLAG);
|
DEFINE_ENUM_FLAG_OPERATORS(FSCmdQueue::QUEUE_FLAG);
|
||||||
|
|
||||||
|
static_assert(sizeof(FSCmdQueue) == 0x44);
|
||||||
|
|
||||||
#define FS_CLIENT_BUFFER_SIZE (5888)
|
#define FS_CLIENT_BUFFER_SIZE (5888)
|
||||||
#define FS_CMD_BLOCK_SIZE (2688)
|
#define FS_CMD_BLOCK_SIZE (2688)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user