Play-/Source/iop/Iop_Thfpool.cpp
Jean-Philip Desjardins 30568a057d
Some checks failed
Build macOS / build_macos (push) Has been cancelled
Build Android / build_android (apk) (push) Has been cancelled
Build Android / build_android (libretro) (push) Has been cancelled
Build Linux ARM32 / build_linux_arm32 (push) Has been cancelled
Build Linux ARM64 / build_linux_arm64 (push) Has been cancelled
Build Windows Psf / build_windows_psf (off, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows Psf / build_windows_psf (on, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows / build_windows (x86_32, Visual Studio 16 2019, installer32.nsi, win32_msvc2019, Win32) (push) Has been cancelled
Build Windows / build_windows (x86_64, Visual Studio 16 2019, installer64.nsi, win64_msvc2019_64, x64) (push) Has been cancelled
Check Format / run_clangformat (push) Has been cancelled
Build iOS / build_ios (push) Has been cancelled
Build JavaScript / build_js (push) Has been cancelled
Build Linux / build_linux (push) Has been cancelled
Use app_config module.
2025-03-11 16:18:58 -04:00

118 lines
2.8 KiB
C++

#include "Iop_Thfpool.h"
#include "Log.h"
#define LOG_NAME ("iop_thfpool")
using namespace Iop;
#define FUNCTION_CREATEFPL "CreateFpl"
#define FUNCTION_DELETEFPL "DeleteFpl"
#define FUNCTION_ALLOCATEFPL "AllocateFpl"
#define FUNCTION_PALLOCATEFPL "pAllocateFpl"
#define FUNCTION_IPALLOCATEFPL "ipAllocateFpl"
#define FUNCTION_FREEFPL "FreeFpl"
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;
case 5:
return FUNCTION_DELETEFPL;
break;
case 6:
return FUNCTION_ALLOCATEFPL;
break;
case 7:
return FUNCTION_PALLOCATEFPL;
break;
case 8:
return FUNCTION_IPALLOCATEFPL;
break;
case 9:
return FUNCTION_FREEFPL;
break;
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;
case 5:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(DeleteFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
case 6:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(AllocateFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
case 7:
case 8:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(pAllocateFpl(
context.m_State.nGPR[CMIPS::A0].nV0));
break;
case 9:
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(FreeFpl(
context.m_State.nGPR[CMIPS::A0].nV0,
context.m_State.nGPR[CMIPS::A1].nV0));
break;
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);
return m_bios.CreateFpl(paramPtr);
}
uint32 CThfpool::DeleteFpl(uint32 fplId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_DELETEFPL "(fplId = %d);\r\n",
fplId);
return m_bios.DeleteFpl(fplId);
}
uint32 CThfpool::AllocateFpl(uint32 fplId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_ALLOCATEFPL "(fplId = %d);\r\n",
fplId);
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);
}