mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
Changed 64-bits and 128-bits memory access instructions to use new 64-bits and 128-bits params/return values now supported in Jitter.
git-svn-id: http://svn.purei.org/purei/trunk@843 b36208d7-6611-0410-8bec-b1987f11c4a2
This commit is contained in:
parent
5920974c77
commit
42c704aca2
8 changed files with 257 additions and 294 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "MemoryUtils.h"
|
||||
#include "Integer64.h"
|
||||
|
||||
uint32 CMemoryUtils::GetByteProxy(CMIPS* pCtx, uint32 nAddress)
|
||||
{
|
||||
|
@ -15,6 +16,64 @@ uint32 CMemoryUtils::GetWordProxy(CMIPS* pCtx, uint32 nAddress)
|
|||
return pCtx->m_pMemoryMap->GetWord(nAddress);
|
||||
}
|
||||
|
||||
uint64 CMemoryUtils::GetDoubleProxy(CMIPS* context, uint32 address)
|
||||
{
|
||||
assert((address & 0x07) == 0);
|
||||
const CMemoryMap::MEMORYMAPELEMENT* e = context->m_pMemoryMap->GetReadMap(address);
|
||||
INTEGER64 result;
|
||||
#ifdef _DEBUG
|
||||
result.q = 0xCCCCCCCCCCCCCCCCull;
|
||||
#endif
|
||||
if(e != NULL)
|
||||
{
|
||||
switch(e->nType)
|
||||
{
|
||||
case CMemoryMap::MEMORYMAP_TYPE_MEMORY:
|
||||
result.q = *reinterpret_cast<uint64*>(reinterpret_cast<uint8*>(e->pPointer) + (address - e->nStart));
|
||||
break;
|
||||
case CMemoryMap::MEMORYMAP_TYPE_FUNCTION:
|
||||
for(unsigned int i = 0; i < 2; i++)
|
||||
{
|
||||
result.d[i] = e->handler(address + (i * 4), 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result.q;
|
||||
}
|
||||
|
||||
uint128 CMemoryUtils::GetQuadProxy(CMIPS* context, uint32 address)
|
||||
{
|
||||
assert((address & 0x0F) == 0);
|
||||
const CMemoryMap::MEMORYMAPELEMENT* e = context->m_pMemoryMap->GetReadMap(address);
|
||||
uint128 result;
|
||||
#ifdef _DEBUG
|
||||
memset(&result, 0xCC, sizeof(result));
|
||||
#endif
|
||||
if(e != NULL)
|
||||
{
|
||||
switch(e->nType)
|
||||
{
|
||||
case CMemoryMap::MEMORYMAP_TYPE_MEMORY:
|
||||
result = *reinterpret_cast<uint128*>(reinterpret_cast<uint8*>(e->pPointer) + (address - e->nStart));
|
||||
break;
|
||||
case CMemoryMap::MEMORYMAP_TYPE_FUNCTION:
|
||||
for(unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
result.nV[i] = e->handler(address + (i * 4), 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CMemoryUtils::SetByteProxy(CMIPS* pCtx, uint32 nValue, uint32 nAddress)
|
||||
{
|
||||
pCtx->m_pMemoryMap->SetByte(nAddress, (uint8)(nValue & 0xFF));
|
||||
|
@ -29,3 +88,59 @@ void CMemoryUtils::SetWordProxy(CMIPS* pCtx, uint32 nValue, uint32 nAddress)
|
|||
{
|
||||
pCtx->m_pMemoryMap->SetWord(nAddress, nValue);
|
||||
}
|
||||
|
||||
void CMemoryUtils::SetDoubleProxy(CMIPS* context, uint64 value64, uint32 address)
|
||||
{
|
||||
assert((address & 0x07) == 0);
|
||||
INTEGER64 value;
|
||||
value.q = value64;
|
||||
const CMemoryMap::MEMORYMAPELEMENT* e = context->m_pMemoryMap->GetWriteMap(address);
|
||||
if(e == NULL)
|
||||
{
|
||||
printf("MemoryMap: Wrote to unmapped memory (0x%0.8X, [0x%0.8X, 0x%0.8X]).\r\n",
|
||||
address, value.d0, value.d1);
|
||||
return;
|
||||
}
|
||||
switch(e->nType)
|
||||
{
|
||||
case CMemoryMap::MEMORYMAP_TYPE_MEMORY:
|
||||
*reinterpret_cast<uint64*>(reinterpret_cast<uint8*>(e->pPointer) + (address - e->nStart)) = value.q;
|
||||
break;
|
||||
case CMemoryMap::MEMORYMAP_TYPE_FUNCTION:
|
||||
for(unsigned int i = 0; i < 2; i++)
|
||||
{
|
||||
e->handler(address + (i * 4), value.d[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryUtils::SetQuadProxy(CMIPS* context, const uint128& value, uint32 address)
|
||||
{
|
||||
assert((address & 0x0F) == 0);
|
||||
const CMemoryMap::MEMORYMAPELEMENT* e = context->m_pMemoryMap->GetWriteMap(address);
|
||||
if(e == NULL)
|
||||
{
|
||||
printf("MemoryMap: Wrote to unmapped memory (0x%0.8X, [0x%0.8X, 0x%0.8X, 0x%0.8X, 0x%0.8X]).\r\n",
|
||||
address, value.nV0, value.nV1, value.nV2, value.nV3);
|
||||
return;
|
||||
}
|
||||
switch(e->nType)
|
||||
{
|
||||
case CMemoryMap::MEMORYMAP_TYPE_MEMORY:
|
||||
*reinterpret_cast<uint128*>(reinterpret_cast<uint8*>(e->pPointer) + (address - e->nStart)) = value;
|
||||
break;
|
||||
case CMemoryMap::MEMORYMAP_TYPE_FUNCTION:
|
||||
for(unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
e->handler(address + (i * 4), value.nV[i]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue