Skip to content

Commit f3c95f7

Browse files
committed
nn_fp: Multiple fixes
1 parent b0a7fd4 commit f3c95f7

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/Cafe/IOSU/legacy/iosu_fpd.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ namespace iosu
328328
static const auto FPResult_Ok = 0;
329329
static const auto FPResult_InvalidIPCParam = BUILD_NN_RESULT(NN_RESULT_LEVEL_LVL6, NN_RESULT_MODULE_NN_FP, 0x680);
330330
static const auto FPResult_RequestFailed = BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // figure out proper error code
331+
static const auto FPResult_Aborted = BUILD_NN_RESULT(NN_RESULT_LEVEL_STATUS, NN_RESULT_MODULE_NN_FP, 0x3480);
331332

332333
class FPDService : public iosu::nn::IPCSimpleService
333334
{
@@ -586,7 +587,7 @@ namespace iosu
586587
if (!ActiveSettings::IsOnlineEnabled())
587588
{
588589
// not online, fail immediately
589-
return BUILD_NN_RESULT(NN_RESULT_LEVEL_FATAL, NN_RESULT_MODULE_NN_FP, 0); // todo
590+
return FPResult_Ok; // Splatoon expects this to always return success otherwise it will softlock. This should be FPResult_Aborted?
590591
}
591592
StartFriendSession();
592593
fpdClient->hasLoggedIn = true;

src/Cafe/OS/libs/nn_fp/nn_fp.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ namespace nn
5555
{
5656
std::unique_lock _l(m_mtx);
5757
void* p = g_fp.fpBufferHeap->alloc(size, 32);
58-
uint32 heapSize, allocationSize, allocNum;
59-
g_fp.fpBufferHeap->getStats(heapSize, allocationSize, allocNum);
58+
if (!p)
59+
cemuLog_log(LogType::Force, "nn_fp: Internal heap is full");
6060
return p;
6161
}
6262

@@ -153,8 +153,11 @@ namespace nn
153153
totalBufferSize += m_vec[i].size;
154154
totalBufferSize = (totalBufferSize+31)&~31;
155155
}
156-
m_dataBuffer = FPIpcBufferAllocator.Allocate(totalBufferSize, 32);
157-
cemu_assert_debug(m_dataBuffer);
156+
if(totalBufferSize > 0)
157+
{
158+
m_dataBuffer = FPIpcBufferAllocator.Allocate(totalBufferSize, 32);
159+
cemu_assert_debug(m_dataBuffer);
160+
}
158161
// update Ioctl vector addresses
159162
for(uint8 i=0; i<m_numVecIn + m_numVecOut; i++)
160163
{
@@ -176,9 +179,7 @@ namespace nn
176179
ppcDefineParamPtr(ipcCtx, FPIpcContext, 1);
177180
ipcCtx->m_asyncResult = result; // store result in variable since FP callbacks pass a pointer to nnResult and not the value directly
178181
ipcCtx->CopyBackOutputs();
179-
cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler BeforeCallback");
180182
PPCCoreCallback(ipcCtx->m_callbackFunc, &ipcCtx->m_asyncResult, ipcCtx->m_callbackParam);
181-
cemuLog_logDebug(LogType::Force, "[DBG] AsyncHandler AfterCallback");
182183
delete ipcCtx;
183184
osLib_returnFromFunction(hCPU, 0);
184185
}

src/util/ChunkedHeap/ChunkedHeap.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,11 @@ class VHeap : public VGenericHeap
489489

490490
bool _alloc(uint32 size, uint32 alignment, uint32& allocOffsetOut)
491491
{
492+
if(size == 0)
493+
{
494+
size = 1; // zero-sized allocations are not supported
495+
cemu_assert_suspicious();
496+
}
492497
// find smallest bucket to scan
493498
uint32 alignmentM1 = alignment - 1;
494499
uint32 bucketIndex = ulog2(size);
@@ -521,7 +526,10 @@ class VHeap : public VGenericHeap
521526
{
522527
auto it = map_allocatedRange.find(addrOffset);
523528
if (it == map_allocatedRange.end())
524-
assert_dbg();
529+
{
530+
cemuLog_log(LogType::Force, "VHeap internal error");
531+
cemu_assert(false);
532+
}
525533
allocRange_t* range = it->second;
526534
map_allocatedRange.erase(it);
527535
m_statsMemAllocated -= range->size;

0 commit comments

Comments
 (0)