some more constants

This commit is contained in:
Megamouse 2021-04-23 20:25:55 +02:00
parent 72c85744b9
commit 41b68ef353
3 changed files with 61 additions and 16 deletions

View File

@ -3790,7 +3790,7 @@ s32 _spurs::create_taskset(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, vm::ptr<Ce
taskset->size = size;
vm::var<CellSpursWorkloadAttribute> wkl_attr;
_cellSpursWorkloadAttributeInitialize(ppu, wkl_attr, 1, 0x330000, vm::cptr<void>::make(SPURS_IMG_ADDR_TASKSET_PM), 0x1E40 /*pm_size*/,
_cellSpursWorkloadAttributeInitialize(ppu, wkl_attr, 1, SYS_PROCESS_PARAM_VERSION_330_0, vm::cptr<void>::make(SPURS_IMG_ADDR_TASKSET_PM), 0x1E40 /*pm_size*/,
taskset.addr(), priority, 8, max_contention);
// TODO: Check return code
@ -4533,7 +4533,7 @@ s32 _spurs::create_job_chain(ppu_thread& ppu, vm::ptr<CellSpurs> spurs, vm::ptr<
vm::var<u32> wid;
// TODO
if (auto err = _cellSpursWorkloadAttributeInitialize(ppu, +attr_wkl, 1, 0x330000, vm::null, 0, jobChain.addr(), prio, 1, maxContention))
if (auto err = _cellSpursWorkloadAttributeInitialize(ppu, +attr_wkl, 1, SYS_PROCESS_PARAM_VERSION_330_0, vm::null, 0, jobChain.addr(), prio, 1, maxContention))
{
return as_job_error(err);
}

View File

@ -817,8 +817,8 @@ void try_spawn_ppu_if_exclusive_program(const ppu_module& m)
{
ppu_thread_params p
{
.stack_addr = vm::cast(vm::alloc(0x100000, vm::stack, 4096)),
.stack_size = 0x100000,
.stack_addr = vm::cast(vm::alloc(SYS_PROCESS_PARAM_STACK_SIZE_MAX, vm::stack, 4096)),
.stack_size = SYS_PROCESS_PARAM_STACK_SIZE_MAX,
};
auto ppu = idm::make_ptr<named_thread<ppu_thread>>("PPU[0x1000000] Thread (test_thread)", p, "test_thread", 0);
@ -1232,10 +1232,10 @@ bool ppu_load_exec(const ppu_exec_object& elf)
u32 tls_vsize = 0;
// Process information
u32 sdk_version = 0xffffffff;
u32 sdk_version = SYS_PROCESS_PARAM_SDK_VERSION_UNKNOWN;
s32 primary_prio = 1001;
u32 primary_stacksize = 0x100000;
u32 malloc_pagesize = 0x100000;
u32 primary_stacksize = SYS_PROCESS_PARAM_STACK_SIZE_MAX;
u32 malloc_pagesize = SYS_PROCESS_PARAM_MALLOC_PAGE_SIZE_1M;
u32 ppc_seg = 0;
// Limit for analysis
@ -1466,7 +1466,7 @@ bool ppu_load_exec(const ppu_exec_object& elf)
ppu_loader.warning("Bad process_param size! [0x%x : 0x%x]", info.size, sizeof(process_param_t));
}
if (info.magic != 0x13bcc5f6u)
if (info.magic != SYS_PROCESS_PARAM_MAGIC)
{
ppu_loader.error("Bad process_param magic! [0x%x]", info.magic);
}
@ -1674,16 +1674,17 @@ bool ppu_load_exec(const ppu_exec_object& elf)
// Fix primary stack size
switch (u32 sz = primary_stacksize)
{
case 0x10: primary_stacksize = 32 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_32K
case 0x20: primary_stacksize = 64 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_64K
case 0x30: primary_stacksize = 96 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_96K
case 0x40: primary_stacksize = 128 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_128K
case 0x50: primary_stacksize = 256 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_256K
case 0x60: primary_stacksize = 512 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_512K
case 0x70: primary_stacksize = 1024 * 1024; break; // SYS_PROCESS_PRIMARY_STACK_SIZE_1M
case SYS_PROCESS_PRIMARY_STACK_SIZE_32K: primary_stacksize = 32 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_64K: primary_stacksize = 64 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_96K: primary_stacksize = 96 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_128K: primary_stacksize = 128 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_256K: primary_stacksize = 256 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_512K: primary_stacksize = 512 * 1024; break;
case SYS_PROCESS_PRIMARY_STACK_SIZE_1M: primary_stacksize = 1024 * 1024; break;
default:
{
primary_stacksize = utils::align<u32>(std::clamp<u32>(sz, 0x10000, 0x100000), 4096);
// According to elad335, the min value seems to be 64KB instead of the expected 4KB (SYS_PROCESS_PARAM_STACK_SIZE_MIN)
primary_stacksize = utils::align<u32>(std::clamp<u32>(sz, 0x10000, SYS_PROCESS_PARAM_STACK_SIZE_MAX), 4096);
break;
}
}

View File

@ -28,6 +28,50 @@ enum : u32
SYS_EVENT_FLAG_OBJECT = 0x98,
};
enum : u64
{
SYS_PROCESS_PRIMARY_STACK_SIZE_32K = 0x0000000000000010,
SYS_PROCESS_PRIMARY_STACK_SIZE_64K = 0x0000000000000020,
SYS_PROCESS_PRIMARY_STACK_SIZE_96K = 0x0000000000000030,
SYS_PROCESS_PRIMARY_STACK_SIZE_128K = 0x0000000000000040,
SYS_PROCESS_PRIMARY_STACK_SIZE_256K = 0x0000000000000050,
SYS_PROCESS_PRIMARY_STACK_SIZE_512K = 0x0000000000000060,
SYS_PROCESS_PRIMARY_STACK_SIZE_1M = 0x0000000000000070,
};
constexpr auto SYS_PROCESS_PARAM_SECTION_NAME = ".sys_proc_param";
enum
{
SYS_PROCESS_PARAM_INVALID_PRIO = -32768,
};
enum : u32
{
SYS_PROCESS_PARAM_INVALID_STACK_SIZE = 0xffffffff,
SYS_PROCESS_PARAM_STACK_SIZE_MIN = 0x1000, // 4KB
SYS_PROCESS_PARAM_STACK_SIZE_MAX = 0x100000, // 1MB
SYS_PROCESS_PARAM_VERSION_INVALID = 0xffffffff,
SYS_PROCESS_PARAM_VERSION_1 = 0x00000001, // for SDK 08X
SYS_PROCESS_PARAM_VERSION_084_0 = 0x00008400,
SYS_PROCESS_PARAM_VERSION_090_0 = 0x00009000,
SYS_PROCESS_PARAM_VERSION_330_0 = 0x00330000,
SYS_PROCESS_PARAM_MAGIC = 0x13bcc5f6,
SYS_PROCESS_PARAM_MALLOC_PAGE_SIZE_NONE = 0x00000000,
SYS_PROCESS_PARAM_MALLOC_PAGE_SIZE_64K = 0x00010000,
SYS_PROCESS_PARAM_MALLOC_PAGE_SIZE_1M = 0x00100000,
SYS_PROCESS_PARAM_PPC_SEG_DEFAULT = 0x00000000,
SYS_PROCESS_PARAM_PPC_SEG_OVLM = 0x00000001,
SYS_PROCESS_PARAM_PPC_SEG_FIXEDADDR_PRX = 0x00000002,
SYS_PROCESS_PARAM_SDK_VERSION_UNKNOWN = 0xffffffff,
};
struct sys_exit2_param
{
be_t<u64> x0; // 0x85