Example #1
0
//181
s32 sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type)
{
	sc_spu.Log("sys_spu_thread_write_ls(id=%d, address=0x%x, value=0x%llx, type=0x%x)",
		id, address, value, type);

	CPUThread* thr = Emu.GetCPU().GetThread(id);

	if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU))
	{
		return CELL_ESRCH;
	}

	if (!thr->IsRunning())
	{
		return CELL_ESTAT;
	}

	if (!(*(SPUThread*)thr).IsGoodLSA(address) || (address % type)) // +check alignment
	{
		return CELL_EINVAL;
	}

	switch (type)
	{
	case 1: (*(SPUThread*)thr).WriteLS8(address, value); return CELL_OK;
	case 2: (*(SPUThread*)thr).WriteLS16(address, value); return CELL_OK;
	case 4: (*(SPUThread*)thr).WriteLS32(address, value); return CELL_OK;
	case 8: (*(SPUThread*)thr).WriteLS64(address, value); return CELL_OK;
	default: return CELL_EINVAL;
	}
}
Example #2
0
//182
int sys_spu_thread_read_ls(u32 id, u32 address, mem64_t value, u32 type)
{
    sc_spu.Log("sys_spu_thread_read_ls(id=%d, address=0x%x, value_addr=0x%x, type=0x%x)",
               id, address, value.GetAddr(), type);

    CPUThread* thr = Emu.GetCPU().GetThread(id);

    if(!thr || (thr->GetType() != CPU_THREAD_SPU && thr->GetType() != CPU_THREAD_RAW_SPU))
    {
        return CELL_ESRCH;
    }

    if (!thr->IsRunning())
    {
        return CELL_ESTAT;
    }

    if(!value.IsGood())
    {
        return CELL_EFAULT;
    }

    if (!(*(SPUThread*)thr).IsGoodLSA(address) || (address % type)) // +check alignment
    {
        return CELL_EINVAL;
    }

    switch (type)
    {
    case 1:
        value = (*(SPUThread*)thr).ReadLS8(address);
        return CELL_OK;
    case 2:
        value = (*(SPUThread*)thr).ReadLS16(address);
        return CELL_OK;
    case 4:
        value = (*(SPUThread*)thr).ReadLS32(address);
        return CELL_OK;
    case 8:
        value = (*(SPUThread*)thr).ReadLS64(address);
        return CELL_OK;
    default:
        return CELL_EINVAL;
    }
}