2016-02-28 15:55:45 -05:00
|
|
|
#include "Iop_Thvpool.h"
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "Log.h"
|
2016-02-28 15:55:45 -05:00
|
|
|
|
|
|
|
#define LOG_NAME ("iop_thvpool")
|
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
#define FUNCTION_CREATEVPL "CreateVpl"
|
|
|
|
#define FUNCTION_DELETEVPL "DeleteVpl"
|
2024-11-11 12:17:33 -05:00
|
|
|
#define FUNCTION_ALLOCATEVPL "AllocateVpl"
|
2018-04-30 21:01:23 +01:00
|
|
|
#define FUNCTION_PALLOCATEVPL "pAllocateVpl"
|
|
|
|
#define FUNCTION_FREEVPL "FreeVpl"
|
|
|
|
#define FUNCTION_REFERVPLSTATUS "ReferVplStatus"
|
2016-02-28 15:55:45 -05:00
|
|
|
|
|
|
|
CThvpool::CThvpool(CIopBios& bios)
|
2018-04-30 21:01:23 +01:00
|
|
|
: m_bios(bios)
|
2016-02-28 15:55:45 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CThvpool::GetId() const
|
|
|
|
{
|
|
|
|
return "thvpool";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CThvpool::GetFunctionName(unsigned int functionId) const
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
return FUNCTION_CREATEVPL;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return FUNCTION_DELETEVPL;
|
|
|
|
break;
|
2024-11-11 12:17:33 -05:00
|
|
|
case 6:
|
|
|
|
return FUNCTION_ALLOCATEVPL;
|
|
|
|
break;
|
2016-02-28 15:55:45 -05:00
|
|
|
case 7:
|
|
|
|
return FUNCTION_PALLOCATEVPL;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
return FUNCTION_FREEVPL;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
return FUNCTION_REFERVPLSTATUS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CThvpool::Invoke(CMIPS& context, unsigned int functionId)
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(CreateVpl(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0));
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(DeleteVpl(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0));
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
2024-11-11 12:17:33 -05:00
|
|
|
case 6:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(AllocateVpl(
|
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0));
|
|
|
|
break;
|
2016-02-28 15:55:45 -05:00
|
|
|
case 7:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(pAllocateVpl(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0));
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(FreeVpl(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0));
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nD0 = static_cast<int32>(ReferVplStatus(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0));
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
|
|
|
default:
|
2018-05-24 12:59:15 -04:00
|
|
|
CLog::GetInstance().Warn(LOG_NAME, "Unknown function (%d) called at (%08X).\r\n", functionId, context.m_State.nPC);
|
2016-02-28 15:55:45 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThvpool::CreateVpl(uint32 paramPtr)
|
|
|
|
{
|
2017-05-29 06:01:32 +01:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_CREATEVPL "(paramPtr = 0x%08X);\r\n",
|
2018-04-30 21:01:23 +01:00
|
|
|
paramPtr);
|
2016-02-28 15:55:45 -05:00
|
|
|
return m_bios.CreateVpl(paramPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThvpool::DeleteVpl(uint32 vplId)
|
|
|
|
{
|
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_DELETEVPL "(vplId = %d);\r\n",
|
2018-04-30 21:01:23 +01:00
|
|
|
vplId);
|
2016-02-28 15:55:45 -05:00
|
|
|
return m_bios.DeleteVpl(vplId);
|
|
|
|
}
|
|
|
|
|
2024-11-11 12:17:33 -05:00
|
|
|
uint32 CThvpool::AllocateVpl(uint32 vplId, uint32 size)
|
|
|
|
{
|
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_ALLOCATEVPL "(vplId = %d, size = 0x%08X);\r\n",
|
|
|
|
vplId, size);
|
|
|
|
return m_bios.AllocateVpl(vplId, size);
|
|
|
|
}
|
|
|
|
|
2016-02-28 15:55:45 -05:00
|
|
|
uint32 CThvpool::pAllocateVpl(uint32 vplId, uint32 size)
|
|
|
|
{
|
2017-05-29 06:01:32 +01:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_PALLOCATEVPL "(vplId = %d, size = 0x%08X);\r\n",
|
2018-04-30 21:01:23 +01:00
|
|
|
vplId, size);
|
2016-02-28 15:55:45 -05:00
|
|
|
return m_bios.pAllocateVpl(vplId, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThvpool::FreeVpl(uint32 vplId, uint32 ptr)
|
|
|
|
{
|
2017-05-29 06:01:32 +01:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_FREEVPL "(vplId = %d, ptr = 0x%08X);\r\n",
|
2018-04-30 21:01:23 +01:00
|
|
|
vplId, ptr);
|
2016-02-28 15:55:45 -05:00
|
|
|
return m_bios.FreeVpl(vplId, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThvpool::ReferVplStatus(uint32 vplId, uint32 statPtr)
|
|
|
|
{
|
2017-05-29 06:01:32 +01:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_REFERVPLSTATUS "(vplId = %d, statPtr = 0x%08X);\r\n",
|
2018-04-30 21:01:23 +01:00
|
|
|
vplId, statPtr);
|
2016-02-28 15:55:45 -05:00
|
|
|
return m_bios.ReferVplStatus(vplId, statPtr);
|
|
|
|
}
|