2008-01-15 20:27:44 +00:00
|
|
|
#include "Iop_Intc.h"
|
2019-02-06 13:34:51 -05:00
|
|
|
#include "../states/RegisterStateFile.h"
|
2013-03-05 05:42:20 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
#define STATE_REGS_XML ("iop_intc/regs.xml")
|
|
|
|
#define STATE_REGS_STATUS ("STATUS")
|
|
|
|
#define STATE_REGS_MASK ("MASK")
|
2008-01-15 20:27:44 +00:00
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
|
2008-10-27 22:27:25 +00:00
|
|
|
void CIntc::Reset()
|
|
|
|
{
|
|
|
|
m_status.f = 0;
|
|
|
|
m_mask.f = 0;
|
|
|
|
}
|
|
|
|
|
2013-03-05 05:42:20 +00:00
|
|
|
void CIntc::LoadState(Framework::CZipArchiveReader& archive)
|
|
|
|
{
|
|
|
|
CRegisterStateFile registerFile(*archive.BeginReadFile(STATE_REGS_XML));
|
2018-04-30 21:01:23 +01:00
|
|
|
m_status.f = registerFile.GetRegister64(STATE_REGS_STATUS);
|
|
|
|
m_mask.f = registerFile.GetRegister64(STATE_REGS_MASK);
|
2013-03-05 05:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CIntc::SaveState(Framework::CZipArchiveWriter& archive)
|
|
|
|
{
|
2023-07-23 17:22:18 -04:00
|
|
|
auto registerFile = std::make_unique<CRegisterStateFile>(STATE_REGS_XML);
|
2013-03-05 05:42:20 +00:00
|
|
|
registerFile->SetRegister64(STATE_REGS_STATUS, m_status.f);
|
|
|
|
registerFile->SetRegister64(STATE_REGS_MASK, m_mask.f);
|
2023-07-23 17:22:18 -04:00
|
|
|
archive.InsertFile(std::move(registerFile));
|
2013-03-05 05:42:20 +00:00
|
|
|
}
|
|
|
|
|
2008-10-27 22:27:25 +00:00
|
|
|
uint32 CIntc::ReadRegister(uint32 address)
|
|
|
|
{
|
|
|
|
switch(address)
|
|
|
|
{
|
|
|
|
case MASK0:
|
|
|
|
return m_mask.h0;
|
|
|
|
break;
|
|
|
|
case MASK1:
|
|
|
|
return m_mask.h1;
|
|
|
|
break;
|
|
|
|
case STATUS0:
|
|
|
|
return m_status.h0;
|
|
|
|
break;
|
|
|
|
case STATUS1:
|
|
|
|
return m_status.h1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CIntc::WriteRegister(uint32 address, uint32 value)
|
|
|
|
{
|
|
|
|
switch(address)
|
|
|
|
{
|
|
|
|
case MASK0:
|
|
|
|
m_mask.h0 = value;
|
|
|
|
break;
|
|
|
|
case MASK1:
|
|
|
|
m_mask.h1 = value;
|
|
|
|
break;
|
|
|
|
case STATUS0:
|
|
|
|
m_status.h0 &= value;
|
|
|
|
break;
|
|
|
|
case STATUS1:
|
|
|
|
m_status.h1 &= value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-15 20:27:44 +00:00
|
|
|
void CIntc::AssertLine(unsigned int line)
|
|
|
|
{
|
2012-04-07 20:04:47 +00:00
|
|
|
m_status.f |= 1LL << line;
|
2008-01-15 20:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CIntc::ClearLine(unsigned int line)
|
|
|
|
{
|
2012-04-07 20:04:47 +00:00
|
|
|
m_status.f &= ~(1LL << line);
|
2008-01-15 20:27:44 +00:00
|
|
|
}
|
|
|
|
|
2008-10-27 22:27:25 +00:00
|
|
|
void CIntc::SetMask(uint64 mask)
|
2008-01-15 20:27:44 +00:00
|
|
|
{
|
2012-04-07 20:04:47 +00:00
|
|
|
m_mask.f = mask;
|
2008-01-15 20:27:44 +00:00
|
|
|
}
|
|
|
|
|
2008-10-27 22:27:25 +00:00
|
|
|
void CIntc::SetStatus(uint64 status)
|
2008-01-15 20:27:44 +00:00
|
|
|
{
|
2012-04-07 20:04:47 +00:00
|
|
|
m_status.f = status;
|
2008-01-15 20:27:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CIntc::HasPendingInterrupt()
|
|
|
|
{
|
2012-04-07 20:04:47 +00:00
|
|
|
return (m_mask.f & m_status.f) != 0;
|
2008-01-15 20:27:44 +00:00
|
|
|
}
|