From f59a448f3f46f39e3dd2faa4552b4336c402f439 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 27 Aug 2017 02:57:41 +0300 Subject: [PATCH] Copy sys_spu_segment info in SPU TG No idea whether it fixes something or not --- rpcs3/Emu/Cell/Modules/sys_spu_.cpp | 4 ++-- rpcs3/Emu/Cell/lv2/sys_spu.cpp | 11 ++++++----- rpcs3/Emu/Cell/lv2/sys_spu.h | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp index fa53704c3c..091eeb6069 100644 --- a/rpcs3/Emu/Cell/Modules/sys_spu_.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_spu_.cpp @@ -322,7 +322,7 @@ s32 sys_raw_spu_load(s32 id, vm::cptr path, vm::ptr entry) sys_spu_image img; img.load(elf_file); - img.deploy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id); + img.deploy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, img.segs.get_ptr(), img.nsegs); img.free(); *entry = img.entry_point | 1; @@ -335,7 +335,7 @@ s32 sys_raw_spu_image_load(ppu_thread& ppu, s32 id, vm::ptr img) sysPrxForUser.warning("sys_raw_spu_image_load(id=%d, img=*0x%x)", id, img); // Load SPU segments - img->deploy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id); + img->deploy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, img->segs.get_ptr(), img->nsegs); // Use MMIO vm::write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, img->entry_point | 1); diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 71868422a4..b2c1b2e80a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -66,7 +66,7 @@ void sys_spu_image::free() } } -void sys_spu_image::deploy(u32 loc) +void sys_spu_image::deploy(u32 loc, sys_spu_segment* segs, u32 nsegs) { // Segment info dump std::string dump; @@ -76,7 +76,7 @@ void sys_spu_image::deploy(u32 loc) sha1_starts(&sha); u8 sha1_hash[20]; - for (int i = 0; i < nsegs; i++) + for (u32 i = 0; i < nsegs; i++) { auto& seg = segs[i]; @@ -232,7 +232,8 @@ error_code sys_spu_thread_initialize(vm::ptr thread, u32 group_id, u32 spu_ group->threads[spu_num] = std::move(spu); group->args[spu_num] = {arg->arg1, arg->arg2, arg->arg3, arg->arg4}; - group->imgs[spu_num] = *img; + group->imgs[spu_num] = std::make_pair(*img, std::vector()); + group->imgs[spu_num].second.assign(img->segs.get_ptr(), img->segs.get_ptr() + img->nsegs); if (++group->init == group->num) { @@ -374,9 +375,9 @@ error_code sys_spu_thread_group_start(ppu_thread& ppu, u32 id) auto& args = group->args[thread->index]; auto& img = group->imgs[thread->index]; - img.deploy(thread->offset); + sys_spu_image::deploy(thread->offset, img.second.data(), img.first.nsegs); - thread->pc = img.entry_point; + thread->pc = img.first.entry_point; thread->cpu_init(); thread->gpr[3] = v128::from64(0, args[0]); thread->gpr[4] = v128::from64(0, args[1]); diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.h b/rpcs3/Emu/Cell/lv2/sys_spu.h index 46348af11f..da3692e7b2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.h +++ b/rpcs3/Emu/Cell/lv2/sys_spu.h @@ -182,7 +182,7 @@ struct sys_spu_image void load(const fs::file& stream); void free(); - void deploy(u32 loc); + static void deploy(u32 loc, sys_spu_segment* segs, u32 nsegs); }; enum : u32 @@ -221,7 +221,7 @@ struct lv2_spu_group cond_variable cv; // used to signal waiting PPU thread std::array, 256> threads; // SPU Threads - std::array imgs; // SPU Images + std::array>, 256> imgs; // SPU Images std::array, 256> args; // SPU Thread Arguments std::weak_ptr ep_run; // port for SYS_SPU_THREAD_GROUP_EVENT_RUN events