Play-/Source/iop/Iop_Thfpool.cpp

119 lines
2.8 KiB
C++
Raw Normal View History

2019-04-22 21:30:16 -04:00
#include "Iop_Thfpool.h"
2025-03-11 12:48:26 -04:00
#include "Log.h"
2019-04-22 21:30:16 -04:00
#define LOG_NAME ("iop_thfpool")
using namespace Iop;
#define FUNCTION_CREATEFPL "CreateFpl"
2022-08-22 20:00:33 -04:00
#define FUNCTION_DELETEFPL "DeleteFpl"
2019-04-22 21:30:16 -04:00
#define FUNCTION_ALLOCATEFPL "AllocateFpl"
2019-04-28 18:07:48 -04:00
#define FUNCTION_PALLOCATEFPL "pAllocateFpl"
2022-02-07 09:52:38 -05:00
#define FUNCTION_IPALLOCATEFPL "ipAllocateFpl"
2019-04-28 18:07:48 -04:00
#define FUNCTION_FREEFPL "FreeFpl"
2019-04-22 21:30:16 -04:00
CThfpool::CThfpool(CIopBios& bios)
: m_bios(bios)
{
}
std::string CThfpool::GetId() const
{
return "thfpool";
}
std::string CThfpool::GetFunctionName(unsigned int functionId) const
{
switch(functionId)
{
case 4:
return FUNCTION_CREATEFPL;
break;
2022-08-22 20:00:33 -04:00
case 5:
return FUNCTION_DELETEFPL;
break;
2019-04-22 21:30:16 -04:00
case 6:
return FUNCTION_ALLOCATEFPL;
break;
2019-04-28 18:07:48 -04:00
case 7:
return FUNCTION_PALLOCATEFPL;
break;
2022-02-07 09:52:38 -05:00
case 8:
return FUNCTION_IPALLOCATEFPL;
break;
2019-04-28 18:07:48 -04:00
case 9:
return FUNCTION_FREEFPL;
break;
2019-04-22 21:30:16 -04:00
default:
return "unknown";
break;
}
}
void CThfpool::Invoke(CMIPS& context, unsigned int functionId)
{
switch(functionId)
{
case 4:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(CreateFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
2022-08-22 20:00:33 -04:00
case 5:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(DeleteFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
2019-04-22 21:30:16 -04:00
case 6:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(AllocateFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
2019-04-28 18:07:48 -04:00
case 7:
2022-02-07 09:52:38 -05:00
case 8:
2019-04-28 18:07:48 -04:00
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(pAllocateFpl(
2019-04-30 17:21:59 -04:00
context.m_State.nGPR[CMIPS::A0].nV0));
2019-04-28 18:07:48 -04:00
break;
case 9:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(FreeFpl(
2019-04-30 17:21:59 -04:00
context.m_State.nGPR[CMIPS::A0].nV0,
context.m_State.nGPR[CMIPS::A1].nV0));
2019-04-28 18:07:48 -04:00
break;
2019-04-22 21:30:16 -04:00
default:
CLog::GetInstance().Warn(LOG_NAME, "Unknown function (%d) called at (%08X).\r\n", functionId, context.m_State.nPC);
break;
}
}
uint32 CThfpool::CreateFpl(uint32 paramPtr)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_CREATEFPL "(paramPtr = 0x%08X);\r\n",
paramPtr);
2019-04-28 18:07:48 -04:00
return m_bios.CreateFpl(paramPtr);
2019-04-22 21:30:16 -04:00
}
2022-08-22 20:00:33 -04:00
uint32 CThfpool::DeleteFpl(uint32 fplId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_DELETEFPL "(fplId = %d);\r\n",
fplId);
return m_bios.DeleteFpl(fplId);
}
2019-04-22 21:30:16 -04:00
uint32 CThfpool::AllocateFpl(uint32 fplId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_ALLOCATEFPL "(fplId = %d);\r\n",
fplId);
2019-04-28 18:07:48 -04:00
return m_bios.AllocateFpl(fplId);
}
uint32 CThfpool::pAllocateFpl(uint32 fplId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_PALLOCATEFPL "(fplId = %d);\r\n",
fplId);
return m_bios.pAllocateFpl(fplId);
}
uint32 CThfpool::FreeFpl(uint32 fplId, uint32 blockPtr)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_FREEFPL "(fplId = %d, blockPtr = 0x%08X);\r\n",
fplId, blockPtr);
return m_bios.FreeFpl(fplId, blockPtr);
2019-04-22 21:30:16 -04:00
}