SPURS: Implement some taskset functions

This commit is contained in:
S Gopal Rajagopal 2014-12-14 00:22:31 +05:30
parent 5dd15b3c47
commit 40f5f73658
4 changed files with 156 additions and 25 deletions

View File

@ -253,7 +253,7 @@ namespace vm
void* get_ptr() const
{
return vm::get_ptr<void>(m_addr);
return vm::get_ptr<void>((u32)m_addr);
}
explicit operator void*() const
@ -313,7 +313,7 @@ namespace vm
const void* get_ptr() const
{
return vm::get_ptr<const void>(m_addr);
return vm::get_ptr<const void>((u32)m_addr);
}
explicit operator const void*() const

View File

@ -2309,7 +2309,7 @@ s64 spursCreateTaskset(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset> tasks
return CELL_SPURS_TASK_ERROR_ALIGN;
}
memset((void *)taskset.addr(), 0, size);
memset(taskset.get_ptr(), 0, size);
taskset->m.spurs = spurs;
taskset->m.args = args;
@ -2406,13 +2406,28 @@ s64 cellSpursJoinTaskset(vm::ptr<CellSpursTaskset> taskset)
#endif
}
s64 cellSpursGetTasksetId(vm::ptr<CellSpursTaskset> taskset, vm::ptr<u32> workloadId)
s64 cellSpursGetTasksetId(vm::ptr<CellSpursTaskset> taskset, vm::ptr<u32> wid)
{
#ifdef PRX_DEBUG
cellSpurs->Warning("cellSpursGetTasksetId(taskset_addr=0x%x, workloadId_addr=0x%x)", taskset.addr(), workloadId.addr());
return GetCurrentPPUThread().FastCall2(libsre + 0x14EA0, libsre_rtoc);
#else
UNIMPLEMENTED_FUNC(cellSpurs);
if (!taskset || !wid)
{
return CELL_SPURS_TASK_ERROR_NULL_POINTER;
}
if (taskset.addr() % CellSpursTaskset::align)
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
if (taskset->m.wid >= CELL_SPURS_MAX_WORKLOAD)
{
return CELL_SPURS_TASK_ERROR_INVAL;
}
*wid = taskset->m.wid.ToBE();
return CELL_OK;
#endif
}
@ -2777,29 +2792,66 @@ s64 cellSpursCreateTask2WithBinInfo()
#endif
}
s64 cellSpursTasksetSetExceptionEventHandler()
s64 cellSpursTasksetSetExceptionEventHandler(vm::ptr<CellSpursTaskset> taskset, vm::ptr<u64> handler, vm::ptr<u64> arg)
{
#ifdef PRX_DEBUG
cellSpurs->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsre + 0x13124, libsre_rtoc);
#else
UNIMPLEMENTED_FUNC(cellSpurs);
if (!taskset || !handler)
{
return CELL_SPURS_TASK_ERROR_NULL_POINTER;
}
if (taskset.addr() % CellSpursTaskset::align)
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
if (taskset->m.wid >= CELL_SPURS_MAX_WORKLOAD)
{
return CELL_SPURS_TASK_ERROR_INVAL;
}
if (taskset->m.exception_handler != 0)
{
return CELL_SPURS_TASK_ERROR_BUSY;
}
taskset->m.exception_handler = handler;
taskset->m.exception_handler_arg = arg;
return CELL_OK;
#endif
}
s64 cellSpursTasksetUnsetExceptionEventHandler()
s64 cellSpursTasksetUnsetExceptionEventHandler(vm::ptr<CellSpursTaskset> taskset)
{
#ifdef PRX_DEBUG
cellSpurs->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsre + 0x13194, libsre_rtoc);
#else
UNIMPLEMENTED_FUNC(cellSpurs);
if (!taskset)
{
return CELL_SPURS_TASK_ERROR_NULL_POINTER;
}
if (taskset.addr() % CellSpursTaskset::align)
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
if (taskset->m.wid >= CELL_SPURS_MAX_WORKLOAD)
{
return CELL_SPURS_TASK_ERROR_INVAL;
}
taskset->m.exception_handler.set(0);
taskset->m.exception_handler_arg.set(0);
return CELL_OK;
#endif
}
s64 cellSpursLookUpTasksetAddress(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset *> taskset, u32 id)
s64 cellSpursLookUpTasksetAddress(vm::ptr<CellSpurs> spurs, vm::ptr<u32> taskset, u32 id)
{
#ifdef PRX_DEBUG
cellSpurs->Warning("%s()", __FUNCTION__);
@ -2810,13 +2862,28 @@ s64 cellSpursLookUpTasksetAddress(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTas
#endif
}
s64 cellSpursTasksetGetSpursAddress(vm::ptr<const CellSpursTaskset> taskset, vm::ptr<CellSpurs *> spurs)
s64 cellSpursTasksetGetSpursAddress(vm::ptr<const CellSpursTaskset> taskset, vm::ptr<u32> spurs)
{
#ifdef PRX_DEBUG
cellSpurs->Warning("%s()", __FUNCTION__);
return GetCurrentPPUThread().FastCall2(libsre + 0x14408, libsre_rtoc);
#else
UNIMPLEMENTED_FUNC(cellSpurs);
if (!taskset || !spurs)
{
return CELL_SPURS_TASK_ERROR_NULL_POINTER;
}
if (taskset.addr() % CellSpursTaskset::align)
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
if (taskset->m.wid >= CELL_SPURS_MAX_WORKLOAD)
{
return CELL_SPURS_TASK_ERROR_INVAL;
}
*spurs = (u32)taskset->m.spurs.addr().ToBE();
return CELL_OK;
#endif
}
@ -3092,6 +3159,8 @@ void cellSpurs_init(Module *pxThis)
REG_FUNC(cellSpurs, cellSpursEnableExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursSetGlobalExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursUnsetGlobalExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursSetExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursUnsetExceptionEventHandler);
// Event flag
REG_FUNC(cellSpurs, _cellSpursEventFlagInitialize);
@ -3137,8 +3206,6 @@ void cellSpurs_init(Module *pxThis)
REG_FUNC(cellSpurs, cellSpursCreateTask2WithBinInfo);
REG_FUNC(cellSpurs, cellSpursLookUpTasksetAddress);
REG_FUNC(cellSpurs, cellSpursTasksetGetSpursAddress);
REG_FUNC(cellSpurs, cellSpursSetExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursUnsetExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursGetTasksetInfo);
REG_FUNC(cellSpurs, cellSpursTasksetSetExceptionEventHandler);
REG_FUNC(cellSpurs, cellSpursTasksetUnsetExceptionEventHandler);

View File

@ -427,19 +427,38 @@ struct CellSpursTaskset
// Raw data
u8 _u8[size];
struct TaskInfo
{
be_t<u32> args[4];
vm::bptr<u64, 1, u64> elf;
vm::bptr<u64, 1, u64> context_save_storage;
be_t<u32> ls_pattern[4];
};
// Real data
struct
{
u8 unk1[0x64]; // 0x00
vm::bptr<CellSpurs> spurs; // 0x64
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
u8 x72; // 0x72
u8 x73; // 0x73
be_t<u32> wid; // 0x74
u8 unk3[0x1818]; // 0x78
be_t<u32> size; // 0x1890
be_t<u32> running_set[4]; // 0x00
be_t<u32> ready_set[4]; // 0x10
be_t<u32> unk_set[4]; // 0x20 - TODO: Find out what this is
be_t<u32> enabled_set[4]; // 0x30
be_t<u32> signal_received_set[4]; // 0x40
be_t<u32> waiting_set[4]; // 0x50
vm::bptr<CellSpurs, 1, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
u8 x72; // 0x72
u8 last_scheduled_task; // 0x73
be_t<u32> wid; // 0x74
u8 unk1[8]; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<u64, 1, u64> exception_handler; // 0x1880
vm::bptr<u64, 1, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
u32 event_flag_id2; // 0x189C
} m;
SPURSManagerTaskset *taskset;
@ -564,7 +583,47 @@ struct CellSpursTaskset2
static const u32 align = 128;
static const u32 size = 10496;
be_t<u8> skip[10496];
union
{
// Raw data
u8 _u8[size];
struct TaskInfo
{
be_t<u32> args[4];
vm::bptr<u64, 1, u64> elf_address;
vm::bptr<u64, 1, u64> context_save_storage;
be_t<u32> ls_pattern[4];
};
// Real data
struct
{
be_t<u32> running_set[4]; // 0x00
be_t<u32> ready_set[4]; // 0x10
be_t<u32> unk_set[4]; // 0x20 - TODO: Find out what this is
be_t<u32> enabled_set[4]; // 0x30
be_t<u32> signal_received_set[4]; // 0x40
be_t<u32> waiting_set[4]; // 0x50
vm::bptr<CellSpurs, 1, u64> spurs; // 0x60
be_t<u64> args; // 0x68
u8 enable_clear_ls; // 0x70
u8 x71; // 0x71
u8 x72; // 0x72
u8 last_scheduled_task; // 0x73
be_t<u32> wid; // 0x74
u8 unk1[8]; // 0x78
TaskInfo task_info[128]; // 0x80
vm::bptr<u64, 1, u64> exception_handler; // 0x1880
vm::bptr<u64, 1, u64> exception_handler_arg; // 0x1888
be_t<u32> size; // 0x1890
u32 unk2; // 0x1894
u32 event_flag_id1; // 0x1898
u32 event_flag_id2; // 0x189C
u8 unk3[0x88]; // 0x1900
u128 task_exit_code[128]; // 0x1988
} m;
};
};
struct CellSpursTasksetAttribute

View File

@ -662,6 +662,7 @@
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ExceptionHandling>Async</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -676,6 +677,7 @@
<PreprocessorDefinitions>_UNICODE;UNICODE;LLVM_AVAILABLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ExceptionHandling>Async</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -694,6 +696,7 @@
<PreprocessorDefinitions>_UNICODE;UNICODE;MSVC_CRT_MEMLEAK_DETECTION;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ExceptionHandling>Async</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -741,6 +744,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ExceptionHandling>Async</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -759,6 +763,7 @@
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>LLVM_AVAILABLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>