2019-08-17 13:51:31 -04:00
|
|
|
#include <cstring>
|
2008-10-20 04:14:13 +00:00
|
|
|
#include "Iop_SifManPs2.h"
|
2015-03-22 23:35:06 -04:00
|
|
|
#include "../Ps2Const.h"
|
2008-11-10 01:46:02 +00:00
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CSifManPs2::CSifManPs2(CSIF& sif, uint8* eeRam, uint8* iopRam)
|
|
|
|
: m_sif(sif)
|
|
|
|
, m_eeRam(eeRam)
|
|
|
|
, m_iopRam(iopRam)
|
2008-11-10 01:46:02 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSifManPs2::RegisterModule(uint32 id, CSifModule* module)
|
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
m_sif.RegisterModule(id, module);
|
2008-11-10 01:46:02 +00:00
|
|
|
}
|
|
|
|
|
2012-12-30 22:25:21 +00:00
|
|
|
bool CSifManPs2::IsModuleRegistered(uint32 id)
|
|
|
|
{
|
|
|
|
return m_sif.IsModuleRegistered(id);
|
|
|
|
}
|
|
|
|
|
2009-02-04 02:15:56 +00:00
|
|
|
void CSifManPs2::UnregisterModule(uint32 id)
|
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
m_sif.UnregisterModule(id);
|
2009-02-04 02:15:56 +00:00
|
|
|
}
|
|
|
|
|
2008-11-10 01:46:02 +00:00
|
|
|
void CSifManPs2::SendPacket(void* packet, uint32 size)
|
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
m_sif.SendPacket(packet, size);
|
2008-11-10 01:46:02 +00:00
|
|
|
}
|
|
|
|
|
2009-01-26 02:53:10 +00:00
|
|
|
void CSifManPs2::SetDmaBuffer(uint32 bufferAddress, uint32 size)
|
2008-11-10 01:46:02 +00:00
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
m_sif.SetDmaBuffer(bufferAddress, size);
|
2008-11-10 01:46:02 +00:00
|
|
|
}
|
2008-12-15 02:57:21 +00:00
|
|
|
|
2014-12-12 20:20:51 +00:00
|
|
|
void CSifManPs2::SetCmdBuffer(uint32 bufferAddress, uint32 size)
|
|
|
|
{
|
|
|
|
m_sif.SetCmdBuffer(bufferAddress, size);
|
|
|
|
}
|
|
|
|
|
2014-07-10 23:32:17 -04:00
|
|
|
void CSifManPs2::SendCallReply(uint32 serverId, const void* returnData)
|
2008-12-15 02:57:21 +00:00
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
m_sif.SendCallReply(serverId, returnData);
|
2008-12-15 02:57:21 +00:00
|
|
|
}
|
2009-04-28 01:20:03 +00:00
|
|
|
|
2014-10-16 03:33:59 -04:00
|
|
|
void CSifManPs2::GetOtherData(uint32 dst, uint32 src, uint32 size)
|
|
|
|
{
|
2015-03-22 23:35:06 -04:00
|
|
|
uint8* srcPtr = m_eeRam + (src & (PS2::EE_RAM_SIZE - 1));
|
2014-10-16 03:33:59 -04:00
|
|
|
uint8* dstPtr = m_iopRam + dst;
|
|
|
|
memcpy(dstPtr, srcPtr, size);
|
|
|
|
}
|
|
|
|
|
2015-01-26 03:39:44 -05:00
|
|
|
void CSifManPs2::SetModuleResetHandler(const ModuleResetHandler& moduleResetHandler)
|
|
|
|
{
|
|
|
|
m_sif.SetModuleResetHandler(moduleResetHandler);
|
|
|
|
}
|
|
|
|
|
2014-11-08 01:14:48 -05:00
|
|
|
void CSifManPs2::SetCustomCommandHandler(const CustomCommandHandler& customCommandHandler)
|
|
|
|
{
|
|
|
|
m_sif.SetCustomCommandHandler(customCommandHandler);
|
|
|
|
}
|
|
|
|
|
2009-04-28 01:20:03 +00:00
|
|
|
uint32 CSifManPs2::SifSetDma(uint32 structAddr, uint32 count)
|
|
|
|
{
|
2012-04-07 23:44:10 +00:00
|
|
|
CSifMan::SifSetDma(structAddr, count);
|
2009-04-28 01:20:03 +00:00
|
|
|
|
2012-04-07 23:44:10 +00:00
|
|
|
if(structAddr == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-04-28 01:20:03 +00:00
|
|
|
|
2021-02-18 20:03:17 -05:00
|
|
|
auto dmaRegs = reinterpret_cast<const SIFDMAREG*>(m_iopRam + structAddr);
|
2009-04-28 01:20:03 +00:00
|
|
|
for(unsigned int i = 0; i < count; i++)
|
|
|
|
{
|
2021-02-18 20:03:17 -05:00
|
|
|
const auto& dmaReg = dmaRegs[i];
|
|
|
|
uint8* src = m_iopRam + dmaReg.srcAddr;
|
|
|
|
uint8* dst = m_eeRam + (dmaReg.dstAddr & (PS2::EE_RAM_SIZE - 1));
|
|
|
|
memcpy(dst, src, dmaReg.size);
|
2009-04-28 01:20:03 +00:00
|
|
|
}
|
|
|
|
|
2012-04-07 23:44:10 +00:00
|
|
|
return count;
|
2009-04-28 01:20:03 +00:00
|
|
|
}
|
2012-06-29 04:39:59 +00:00
|
|
|
|
2014-10-16 03:33:59 -04:00
|
|
|
uint8* CSifManPs2::GetEeRam() const
|
2012-06-29 04:39:59 +00:00
|
|
|
{
|
2014-10-16 03:33:59 -04:00
|
|
|
return m_eeRam;
|
2012-06-29 04:39:59 +00:00
|
|
|
}
|