Skip to content

Commit

Permalink
nn_fp: Full rework of friend service
Browse files Browse the repository at this point in the history
  • Loading branch information
Exzap committed Oct 17, 2023
1 parent 13a50a9 commit 0d71885
Show file tree
Hide file tree
Showing 37 changed files with 2,755 additions and 1,884 deletions.
24 changes: 19 additions & 5 deletions src/Cafe/CafeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,13 @@ namespace CafeSystem
cemuLog_log(LogType::Force, "Platform: {}", platform);
}

static std::vector<IOSUModule*> s_iosuModules =
{
// entries in this list are ordered by initialization order. Shutdown in reverse order
iosu::kernel::GetModule(),
iosu::fpd::GetModule()
};

// initialize all subsystems which are persistent and don't depend on a game running
void Initialize()
{
Expand All @@ -550,14 +557,15 @@ namespace CafeSystem
// allocate memory for all SysAllocators
// must happen before COS module init, but also before iosu::kernel::Initialize()
SysAllocatorContainer::GetInstance().Initialize();
// init IOSU
// init IOSU modules
for(auto& module : s_iosuModules)
module->SystemLaunch();
// init IOSU (deprecated manual init)
iosuCrypto_init();
iosu::kernel::Initialize();
iosu::fsa::Initialize();
iosuIoctl_init();
iosuAct_init_depr();
iosu::act::Initialize();
iosu::fpd::Initialize();
iosu::iosuMcp_init();
iosu::mcp::Init();
iosu::iosuAcp_init();
Expand Down Expand Up @@ -593,11 +601,14 @@ namespace CafeSystem
// if a title is running, shut it down
if (sSystemRunning)
ShutdownTitle();
// shutdown persistent subsystems
// shutdown persistent subsystems (deprecated manual shutdown)
iosu::odm::Shutdown();
iosu::act::Stop();
iosu::mcp::Shutdown();
iosu::fsa::Shutdown();
// shutdown IOSU modules
for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it)
(*it)->SystemExit();
s_initialized = false;
}

Expand Down Expand Up @@ -821,7 +832,8 @@ namespace CafeSystem

void _LaunchTitleThread()
{
// init
for(auto& module : s_iosuModules)
module->TitleStart();
cemu_initForGame();
// enter scheduler
if (ActiveSettings::GetCPUMode() == CPUMode::MulticoreRecompiler)
Expand Down Expand Up @@ -956,6 +968,8 @@ namespace CafeSystem
nn::save::ResetToDefaultState();
coreinit::__OSDeleteAllActivePPCThreads();
RPLLoader_ResetState();
for(auto it = s_iosuModules.rbegin(); it != s_iosuModules.rend(); ++it)
(*it)->TitleStop();
// stop time tracking
iosu::pdm::Stop();
// reset Cemu subsystems
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Espresso/Interpreter/PPCInterpreterHLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void PPCInterpreter_handleUnsupportedHLECall(PPCInterpreter_t* hCPU)

std::vector<void(*)(PPCInterpreter_t* hCPU)>* sPPCHLETable{};

HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall)
HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall, std::string hleName)
{
if (!sPPCHLETable)
sPPCHLETable = new std::vector<void(*)(PPCInterpreter_t* hCPU)>();
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/HW/Espresso/PPCState.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static inline float flushDenormalToZero(float f)
typedef void(*HLECALL)(PPCInterpreter_t* hCPU);

typedef sint32 HLEIDX;
HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall);
HLEIDX PPCInterpreter_registerHLECall(HLECALL hleCall, std::string hleName);
HLECALL PPCInterpreter_getHLECall(HLEIDX funcIndex);

// HLE scheduler
Expand Down
14 changes: 13 additions & 1 deletion src/Cafe/IOSU/iosu_types_common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once

using IOSMsgQueueId = uint32;
using IOSTimerId = uint32;

static constexpr IOSTimerId IOSInvalidTimerId = 0xFFFFFFFF;

// returned for syscalls
// maybe also shared with IPC?
Expand All @@ -19,4 +22,13 @@ enum IOS_ERROR : sint32
inline bool IOS_ResultIsError(const IOS_ERROR err)
{
return (err & 0x80000000) != 0;
}
}

class IOSUModule
{
public:
virtual void SystemLaunch() {}; // CafeSystem is initialized
virtual void SystemExit() {}; // CafeSystem is shutdown
virtual void TitleStart() {}; // foreground title is launched
virtual void TitleStop() {}; // foreground title is closed
};
Loading

0 comments on commit 0d71885

Please sign in to comment.