Code cleanup

This commit is contained in:
Exzap 2023-10-01 11:43:24 +02:00
parent 9523993a24
commit ff9d180154
26 changed files with 105 additions and 131 deletions

View file

@ -446,19 +446,20 @@ namespace save
SAVEStatus SAVEOpenFileOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParamsNew_t asyncParams;
asyncParams.ioMsgQueue = nullptr;
asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback);
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetPointer();
SAVEStatus status = SAVEOpenFileOtherApplicationAsync(client, block, titleId, accountSlot, path, mode, hFile, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -680,19 +681,20 @@ namespace save
SAVEStatus SAVEGetFreeSpaceSize(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FSLargeSize* freeSize, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetFreeSpaceSizeAsync(client, block, accountSlot, freeSize, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -749,19 +751,20 @@ namespace save
SAVEStatus SAVERemove(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVERemoveAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -862,19 +865,20 @@ namespace save
SAVEStatus SAVEOpenDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEOpenDirAsync(client, block, accountSlot, path, hDir, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -935,19 +939,20 @@ namespace save
SAVEStatus SAVEOpenDirOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSDirHandlePtr hDir, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEOpenDirOtherApplicationAsync(client, block, titleId, accountSlot, path, hDir, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1071,19 +1076,20 @@ namespace save
SAVEStatus SAVEMakeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEMakeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1122,19 +1128,20 @@ namespace save
SAVEStatus SAVEOpenFile(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, const char* mode, FSFileHandleDepr_t* hFile, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParamsNew_t asyncParams;
asyncParams.ioMsgQueue = nullptr;
asyncParams.userCallback = PPCInterpreter_makeCallableExportDepr(AsyncCallback);
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetPointer();
SAVEStatus status = SAVEOpenFileAsync(client, block, accountSlot, path, mode, hFile, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1182,19 +1189,20 @@ namespace save
SAVEStatus SAVEGetStat(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetStatAsync(client, block, accountSlot, path, stat, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1233,19 +1241,20 @@ namespace save
SAVEStatus SAVEGetStatOtherApplication(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint64 titleId, uint8 accountSlot, const char* path, FSStat_t* stat, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEGetStatOtherApplicationAsync(client, block, titleId, accountSlot, path, stat, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1422,19 +1431,20 @@ namespace save
SAVEStatus SAVEChangeDir(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, const char* path, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEChangeDirAsync(client, block, accountSlot, path, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}
@ -1491,19 +1501,20 @@ namespace save
SAVEStatus SAVEFlushQuota(coreinit::FSClient_t* client, coreinit::FSCmdBlock_t* block, uint8 accountSlot, FS_ERROR_MASK errHandling)
{
MEMPTR<OSThread_t> currentThread{coreinit::OSGetCurrentThread()};
FSAsyncParams_t asyncParams;
asyncParams.ioMsgQueue = MPTR_NULL;
asyncParams.userCallback = _swapEndianU32(PPCInterpreter_makeCallableExportDepr(AsyncCallback));
StackAllocator<AsyncCallbackParam_t> param;
param->thread = coreinitThread_getCurrentThreadMPTRDepr(PPCInterpreter_getCurrentInstance());
param->thread = currentThread;
param->returnStatus = (FSStatus)FS_RESULT::SUCCESS;
asyncParams.userContext = param.GetMPTRBE();
SAVEStatus status = SAVEFlushQuotaAsync(client, block, accountSlot, errHandling, &asyncParams);
if (status == (FSStatus)FS_RESULT::SUCCESS)
{
coreinit_suspendThread(coreinitThread_getCurrentThreadDepr(PPCInterpreter_getCurrentInstance()), 1000);
coreinit_suspendThread(currentThread, 1000);
PPCCore_switchToScheduler();
return param->returnStatus;
}