mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-14 15:40:17 +00:00
sys_spu_image: minor update
Cleanup Templates extended
This commit is contained in:
parent
14a6269243
commit
b533d57717
@ -99,7 +99,7 @@ struct spu_elf_info
|
||||
{
|
||||
u8 e_class;
|
||||
vm::bptr<spu_elf_ldr> ldr;
|
||||
|
||||
|
||||
struct sce_hdr
|
||||
{
|
||||
be_t<u32> se_magic;
|
||||
@ -170,7 +170,7 @@ struct spu_elf_info
|
||||
{
|
||||
return CELL_ENOEXEC;
|
||||
}
|
||||
|
||||
|
||||
e_class = ehdr->e_class;
|
||||
ldr = vm::get_addr(&_overlay);
|
||||
ldr->_vtable = vm::cast(u32{e_class}); // TODO
|
||||
@ -212,6 +212,7 @@ error_code sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 type)
|
||||
return res;
|
||||
}
|
||||
|
||||
// Reject SCE header
|
||||
if (info->sce0.se_magic == 0x53434500)
|
||||
{
|
||||
return CELL_ENOEXEC;
|
||||
@ -249,7 +250,7 @@ error_code sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 type)
|
||||
|
||||
return _sys_spu_image_import(img, src, img_size, 0);
|
||||
}
|
||||
else if (type == SYS_SPU_IMAGE_DIRECT)
|
||||
else
|
||||
{
|
||||
s32 num_segs = sys_spu_image::get_nsegs(phdr);
|
||||
|
||||
@ -268,22 +269,16 @@ error_code sys_spu_image_import(vm::ptr<sys_spu_image> img, u32 src, u32 type)
|
||||
return CELL_ENOMEM;
|
||||
}
|
||||
|
||||
if (sys_spu_image::fill(segs, phdr, src) != num_segs)
|
||||
if (sys_spu_image::fill(segs, num_segs, phdr, src) != num_segs)
|
||||
{
|
||||
vm::dealloc(segs.addr());
|
||||
return CELL_ENOEXEC;
|
||||
}
|
||||
|
||||
img->type = SYS_SPU_IMAGE_TYPE_USER;
|
||||
img->type = SYS_SPU_IMAGE_TYPE_USER;
|
||||
img->segs = segs;
|
||||
return CELL_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
error_code sys_spu_image_close(vm::ptr<sys_spu_image> img)
|
||||
|
@ -52,7 +52,7 @@ void sys_spu_image::load(const fs::file& stream)
|
||||
stream.seek(0);
|
||||
stream.read(vm::base(src), stream.size());
|
||||
|
||||
if (nsegs < 0 || sys_spu_image::fill(segs, obj.progs, src) != nsegs)
|
||||
if (nsegs < 0 || sys_spu_image::fill(segs, nsegs, obj.progs, src) != nsegs)
|
||||
{
|
||||
fmt::throw_exception("Failed to load SPU segments (%d)" HERE, nsegs);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ struct sys_spu_image
|
||||
vm::ps3::bptr<sys_spu_segment> segs;
|
||||
be_t<s32> nsegs;
|
||||
|
||||
template <typename Phdrs>
|
||||
template <bool CountInfo = true, typename Phdrs>
|
||||
static s32 get_nsegs(const Phdrs& phdrs)
|
||||
{
|
||||
s32 num_segs = 0;
|
||||
@ -128,7 +128,7 @@ struct sys_spu_image
|
||||
{
|
||||
num_segs += 2;
|
||||
}
|
||||
else
|
||||
else if (phdr.p_type == 1 || CountInfo)
|
||||
{
|
||||
num_segs += 1;
|
||||
}
|
||||
@ -137,8 +137,8 @@ struct sys_spu_image
|
||||
return num_segs;
|
||||
}
|
||||
|
||||
template <typename Phdrs>
|
||||
static s32 fill(vm::ps3::ptr<sys_spu_segment> segs, const Phdrs& phdrs, u32 src)
|
||||
template <bool WriteInfo = true, typename Phdrs>
|
||||
static s32 fill(vm::ps3::ptr<sys_spu_segment> segs, s32 nsegs, const Phdrs& phdrs, u32 src)
|
||||
{
|
||||
s32 num_segs = 0;
|
||||
|
||||
@ -148,6 +148,11 @@ struct sys_spu_image
|
||||
{
|
||||
if (phdr.p_filesz)
|
||||
{
|
||||
if (num_segs >= nsegs)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
auto* seg = &segs[num_segs++];
|
||||
seg->type = SYS_SPU_SEGMENT_TYPE_COPY;
|
||||
seg->ls = static_cast<u32>(phdr.p_vaddr);
|
||||
@ -157,6 +162,11 @@ struct sys_spu_image
|
||||
|
||||
if (phdr.p_memsz > phdr.p_filesz)
|
||||
{
|
||||
if (num_segs >= nsegs)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
auto* seg = &segs[num_segs++];
|
||||
seg->type = SYS_SPU_SEGMENT_TYPE_FILL;
|
||||
seg->ls = static_cast<u32>(phdr.p_vaddr + phdr.p_filesz);
|
||||
@ -164,14 +174,19 @@ struct sys_spu_image
|
||||
seg->addr = 0;
|
||||
}
|
||||
}
|
||||
else if (phdr.p_type == 4)
|
||||
else if (WriteInfo && phdr.p_type == 4)
|
||||
{
|
||||
if (num_segs >= nsegs)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
auto* seg = &segs[num_segs++];
|
||||
seg->type = SYS_SPU_SEGMENT_TYPE_INFO;
|
||||
seg->size = 0x20;
|
||||
seg->addr = static_cast<u32>(phdr.p_offset + 0x14 + src);
|
||||
}
|
||||
else
|
||||
else if (phdr.p_type != 4)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@ -283,7 +298,7 @@ error_code sys_spu_thread_group_destroy(u32 id);
|
||||
error_code sys_spu_thread_group_start(ppu_thread&, u32 id);
|
||||
error_code sys_spu_thread_group_suspend(u32 id);
|
||||
error_code sys_spu_thread_group_resume(u32 id);
|
||||
error_code sys_spu_thread_group_yield(u32 id);
|
||||
error_code sys_spu_thread_group_yield(u32 id);
|
||||
error_code sys_spu_thread_group_terminate(u32 id, s32 value);
|
||||
error_code sys_spu_thread_group_join(ppu_thread&, u32 id, vm::ps3::ptr<u32> cause, vm::ps3::ptr<u32> status);
|
||||
error_code sys_spu_thread_group_set_priority(u32 id, s32 priority);
|
||||
|
Loading…
x
Reference in New Issue
Block a user