SPUThread& GetCurrentSPUThread() { PPCThread* thread = GetCurrentPPCThread(); if(!thread || (thread->GetType() != CPU_THREAD_SPU && thread->GetType() != CPU_THREAD_RAW_SPU)) { throw wxString("GetCurrentSPUThread: bad thread"); } return *(SPUThread*)thread; }
PPUThread& GetCurrentPPUThread() { PPCThread* thread = GetCurrentPPCThread(); if(!thread || thread->GetType() != CPU_THREAD_PPU) throw std::string("GetCurrentPPUThread: bad thread"); return *(PPUThread*)thread; }
//181 int sys_spu_thread_write_ls(u32 id, u32 address, u64 value, u32 type) { sc_spu.Warning("sys_spu_thread_write_ls(id=0x%x, address=0x%x, value=0x%llx, type=0x%x)", id, address, value, type); PPCThread* thr = Emu.GetCPU().GetThread(id); if(!thr || thr->GetType() == PPC_THREAD_PPU) { return CELL_ESRCH; } (*(SPUThread*)thr).WriteLS64(address, value); return CELL_OK; }
//190 int sys_spu_thread_write_spu_mb(u32 id, u32 value) { sc_spu.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x)", id, value); PPCThread* thr = Emu.GetCPU().GetThread(id); if(!thr || !thr->GetType() == PPC_THREAD_PPU) { return CELL_ESRCH; } if(!(*(SPUThread*)thr).mfc.SPU_In_MBox.Push(value)) { ConLog.Warning("sys_spu_thread_write_spu_mb(id=0x%x, value=0x%x): used all mbox items."); return CELL_EBUSY; //? } return CELL_OK; }
//182 int sys_spu_thread_read_ls(u32 id, u32 address, u32 value_addr, u32 type) { sc_spu.Warning("sys_spu_thread_read_ls(id=0x%x, address=0x%x, value_addr=0x%x, type=0x%x)", id, address, value_addr, type); PPCThread* thr = Emu.GetCPU().GetThread(id); if(!thr || thr->GetType() == PPC_THREAD_PPU) { return CELL_ESRCH; } if(!(*(SPUThread*)thr).IsGoodLSA(address)) { return CELL_EFAULT; } Memory.Write64(value_addr, (*(SPUThread*)thr).ReadLS64(address)); return CELL_OK; }
//166 int sys_spu_thread_set_argument(u32 id, u32 arg_addr) { sc_spu.Warning("sys_spu_thread_set_argument(id=0x%x, arg_addr=0x%x)", id, arg_addr); PPCThread* thr = Emu.GetCPU().GetThread(id); if(!thr || thr->GetType() == PPC_THREAD_PPU) { return CELL_ESRCH; } if(!Memory.IsGoodAddr(arg_addr, sizeof(sys_spu_thread_argument))) { return CELL_EFAULT; } auto& arg = (sys_spu_thread_argument&)Memory[arg_addr]; thr->SetArg(0, re(arg.arg1)); thr->SetArg(1, re(arg.arg2)); thr->SetArg(2, re(arg.arg3)); thr->SetArg(3, re(arg.arg4)); return CELL_OK; }