Add PowerOff IOP module stub

Makes ScummVM boot, if LIBSD is provided in rom0
This commit is contained in:
Björn Gerdau 2022-03-16 14:12:20 +01:00
parent 729050e139
commit dd538f9561
No known key found for this signature in database
GPG key ID: 950E6970BF893644
5 changed files with 83 additions and 0 deletions

View file

@ -319,6 +319,8 @@ set(COMMON_SRC_FILES
iop/Iop_PadMan.h
iop/Iop_PathUtils.cpp
iop/Iop_PathUtils.h
iop/Iop_PowerOff.cpp
iop/Iop_PowerOff.h
iop/Iop_RootCounters.cpp
iop/Iop_RootCounters.h
iop/Iop_Secrman.cpp

View file

@ -254,6 +254,10 @@ void CIopBios::Reset(const Iop::SifManPtr& sifMan)
m_mcserv = std::make_shared<Iop::CMcServ>(*this, *m_sifMan, *m_sifCmd, *m_sysmem, m_ram);
RegisterModule(m_mcserv);
}
{
m_powerOff = std::make_shared<Iop::CPowerOff>(*m_sifMan);
RegisterModule(m_powerOff);
}
RegisterModule(std::make_shared<Iop::CIomanX>(*m_ioman));
//RegisterModule(std::make_shared<Iop::CNaplink>(*m_sifMan, *m_ioman));
{

View file

@ -26,6 +26,7 @@
#include "Iop_MtapMan.h"
#include "Iop_Cdvdfsv.h"
#include "Iop_McServ.h"
#include "Iop_PowerOff.h"
#endif
class CIopBios : public Iop::CBiosBase
@ -680,6 +681,7 @@ private:
Iop::MtapManPtr m_mtapman;
Iop::McServPtr m_mcserv;
Iop::CdvdfsvPtr m_cdvdfsv;
Iop::PowerOffPtr m_powerOff;
std::map<std::string, Iop::ModulePtr> m_hleModules;
#endif

View file

@ -0,0 +1,41 @@
#include "Iop_PowerOff.h"
#include "Log.h"
#include "Iop_SifMan.h"
#define LOG_NAME ("iop_poweroff")
using namespace Iop;
CPowerOff::CPowerOff(CSifMan& sifMan)
{
sifMan.RegisterModule(MODULE_ID, this);
}
std::string CPowerOff::GetId() const
{
return "poweroff";
}
std::string CPowerOff::GetFunctionName(unsigned int functionId) const
{
return "unknown";
}
void CPowerOff::Invoke(CMIPS& context, unsigned int functionId)
{
switch(functionId)
{
default:
CLog::GetInstance().Warn(LOG_NAME, "%08X: Unknown function (%d) called.\r\n", context.m_State.nPC, functionId);
break;
}
}
bool CPowerOff::Invoke(uint32 method, uint32* args, uint32 argsSize, uint32* ret, uint32 retSize, uint8* ram)
{
switch(method)
{
default:
CLog::GetInstance().Warn(LOG_NAME, "Unknown RPC method invoked (0x%08X).\r\n", method);
return true;
}
}

34
Source/iop/Iop_PowerOff.h Normal file
View file

@ -0,0 +1,34 @@
#pragma once
#include "Iop_Module.h"
#include "Iop_SifMan.h"
// Not an actual implementation of the PowerOff module.
// For insights what this emulates see here:
// https://github.com/ps2dev/ps2sdk/blob/c80310b3967a0ef3f8cb3cf20e469d7763fe0e9a/iop/dev9/poweroff/src/poweroff.c
// Some homebrew (e.g. ScummVM) expect the module to be loaded beforehand on the IOP
// via the ELF loader (e.g. ps2link), and thus don't load it themselves.
// In the future, this module should only be loaded on ELF files, and not on discs.
namespace Iop
{
class CPowerOff : public CModule, public CSifModule
{
public:
CPowerOff(Iop::CSifMan& sifMan);
virtual ~CPowerOff() = default;
std::string GetId() const override;
std::string GetFunctionName(unsigned int) const override;
void Invoke(CMIPS&, unsigned int) override;
bool Invoke(uint32, uint32*, uint32, uint32*, uint32, uint8*) override;
private:
enum MODULE_ID
{
MODULE_ID = 0x09090900,
};
};
typedef std::shared_ptr<CPowerOff> PowerOffPtr;
}