s64 cellSpursJobGuardInitialize() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x1807C, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursGetWorkloadData() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0xA78C, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursRequestIdleSpu() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0xAD88, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 _cellSpursWorkloadAttributeInitialize() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x9F08, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursAddWorkloadWithAttribute() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x9E14, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 _cellSpursWorkloadFlagReceiver() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0xF158, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursJobChainGetError() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x190AC, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursWorkloadAttributeSetShutdownCompletionEventHook() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x96A4, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursAttributeEnableSpuPrintfIfAvailable(vm::ptr<CellSpursAttribute> attr) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursAttributeEnableSpuPrintfIfAvailable(attr_addr=0x%x)", attr.addr()); return GetCurrentPPUThread().FastCall2(libsre + 0x7150, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursJobChainAttributeSetJobTypeMemoryCheck() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x186A4, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursUnsetExceptionEventHandler() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0xD77C, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursReadyCountCompareAndSwap() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0xA9CC, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursTasksetGetSpursAddress() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x14408, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursCreateTask2WithBinInfo() { #ifdef PRX_DEBUG cellSpurs->Warning("%s()", __FUNCTION__); return GetCurrentPPUThread().FastCall2(libsre + 0x120E0, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
void sys_ppu_thread_once(vm::ptr<std::atomic<be_t<u32>>> once_ctrl, u32 entry) { sys_ppu_thread.Warning("sys_ppu_thread_once(once_ctrl_addr=0x%x, entry=0x%x)", once_ctrl.addr(), entry); be_t<u32> old = be_t<u32>::MakeFromBE(se32(SYS_PPU_THREAD_ONCE_INIT)); if (once_ctrl->compare_exchange_weak(old, be_t<u32>::MakeFromBE(se32(SYS_PPU_THREAD_DONE_INIT)))) { GetCurrentPPUThread().FastCall2(Memory.Read32(entry), Memory.Read32(entry + 4)); } }
int sys_rwlock_wunlock(u32 rw_lock_id) { sys_rwlock.Log("sys_rwlock_wunlock(rw_lock_id=%d)", rw_lock_id); RWLock* rw; if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH; if (!rw->wlock_unlock(GetCurrentPPUThread().GetId())) return CELL_EPERM; return CELL_OK; }
int cellFontSetEffectSlant(mem_ptr_t<CellFont> font, float slantParam) { slantParam = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments cellFont->Log("cellFontSetEffectSlant(font_addr=0x%x, slantParam=%f)", font.GetAddr(), slantParam); if (!font.IsGood() || slantParam < -1.0 || slantParam > 1.0) return CELL_FONT_ERROR_INVALID_PARAMETER; font->slant = slantParam; return CELL_FONT_OK; }
s32 sys_rwlock_tryrlock(u32 rw_lock_id) { sys_rwlock.Log("sys_rwlock_tryrlock(rw_lock_id=%d)", rw_lock_id); RWLock* rw; if (!sys_rwlock.CheckId(rw_lock_id, rw)) return CELL_ESRCH; if (!rw->rlock_trylock(GetCurrentPPUThread().GetId())) return CELL_EBUSY; return CELL_OK; }
s64 _sys_spu_printf_detach_thread(u32 arg) { sysPrxForUser->Warning("_sys_spu_printf_detach_thread(arg=0x%x)", arg); if (!spu_printf_dtcb) { return CELL_ESTAT; } return GetCurrentPPUThread().FastCall(vm::read32(spu_printf_dtcb), vm::read32(spu_printf_dtcb + 4), arg); }
int sys_lwmutex_unlock(mem_ptr_t<sys_lwmutex_t> lwmutex) { sc_lwmutex.Log("sys_lwmutex_unlock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->unlock(GetCurrentPPUThread().GetId()); }
int sys_cond_wait(u32 cond_id, u64 timeout) { sys_cond.Log("sys_cond_wait(cond_id=%d, timeout=%lld)", cond_id, timeout); Cond* cond; if (!Emu.GetIdManager().GetIDData(cond_id, cond)) { return CELL_ESRCH; } Mutex* mutex = cond->mutex; u32 tid = GetCurrentPPUThread().GetId(); if (mutex->m_mutex.GetOwner() != tid) { return CELL_EPERM; } cond->m_queue.push(tid); mutex->recursive = 0; mutex->m_mutex.unlock(tid); u32 counter = 0; const u32 max_counter = timeout ? (timeout / 1000) : ~0; while (true) { /* switch (mutex->m_mutex.trylock(tid)) { case SMR_OK: mutex->m_mutex.unlock(tid); break; case SMR_SIGNAL: mutex->recursive = 1; return CELL_OK; } */ if (mutex->m_mutex.GetOwner() == tid) { _mm_mfence(); mutex->recursive = 1; return CELL_OK; } Sleep(1); if (counter++ > max_counter) { cond->m_queue.invalidate(tid); return CELL_ETIMEDOUT; } if (Emu.IsStopped()) { ConLog.Warning("sys_cond_wait(id=%d) aborted", cond_id); return CELL_OK; } } }
s64 _cellSpursEventFlagInitialize(vm::ptr<CellSpurs> spurs, vm::ptr<CellSpursTaskset> taskset, vm::ptr<CellSpursEventFlag> eventFlag, u32 flagClearMode, u32 flagDirection) { #ifdef PRX_DEBUG cellSpurs->Warning("_cellSpursEventFlagInitialize(spurs_addr=0x%x, taskset_addr=0x%x, eventFlag_addr=0x%x, flagClearMode=%d, flagDirection=%d)", spurs.addr(), taskset.addr(), eventFlag.addr(), flagClearMode, flagDirection); return GetCurrentPPUThread().FastCall2(libsre + 0x1564C, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
int sys_lwmutex_lock(mem_ptr_t<sys_lwmutex_t> lwmutex, u64 timeout) { sc_lwmutex.Log("sys_lwmutex_lock(lwmutex_addr=0x%x, timeout=%lld)", lwmutex.GetAddr(), timeout); if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->lock(GetCurrentPPUThread().GetId(), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0); }
s64 cellSpursSetGlobalExceptionEventHandler(vm::ptr<CellSpurs> spurs, u32 eaHandler_addr, u32 arg_addr) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursSetGlobalExceptionEventHandler(spurs_addr=0x%x, eaHandler_addr=0x%x, arg_addr=0x%x)", spurs.addr(), eaHandler_addr, arg_addr); return GetCurrentPPUThread().FastCall2(libsre + 0xD6D0, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursAttachLv2EventQueue(vm::ptr<CellSpurs> spurs, u32 queue, vm::ptr<u8> port, s32 isDynamic) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursAttachLv2EventQueue(spurs_addr=0x%x, queue=%d, port_addr=0x%x, isDynamic=%d)", spurs.addr(), queue, port.addr(), isDynamic); return GetCurrentPPUThread().FastCall2(libsre + 0xAFE0, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
int cellFontRenderCharGlyphImage(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<CellFontRenderSurface> surface, float x, float y, mem_ptr_t<CellFontGlyphMetrics> metrics, mem_ptr_t<CellFontImageTransInfo> transInfo) { x = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments y = GetCurrentPPUThread().FPR[2]; // TODO: Something is wrong with the float arguments cellFont->Log("cellFontRenderCharGlyphImage(font_addr=0x%x, code=0x%x, surface_addr=0x%x, x=%f, y=%f, metrics_addr=0x%x, trans_addr=0x%x)", font.GetAddr(), code, surface.GetAddr(), x, y, metrics.GetAddr(), transInfo.GetAddr()); if (!font.IsGood() || !surface.IsGood() || !metrics.IsGood() || !transInfo.IsGood()) return CELL_FONT_ERROR_INVALID_PARAMETER; if (!font->renderer_addr) return CELL_FONT_ERROR_RENDERER_UNBIND; // Render the character int width, height, xoff, yoff; float scale = stbtt_ScaleForPixelHeight(&(font->stbfont), font->scale_y); unsigned char* box = stbtt_GetCodepointBitmap(&(font->stbfont), scale, scale, code, &width, &height, &xoff, &yoff); if (!box) return CELL_OK; // Get the baseLineY value int baseLineY; int ascent, descent, lineGap; stbtt_GetFontVMetrics(&(font->stbfont), &ascent, &descent, &lineGap); baseLineY = ascent * scale; // Move the rendered character to the surface unsigned char* buffer = (unsigned char*)Memory.VirtualToRealAddr(surface->buffer_addr); for (u32 ypos = 0; ypos < (u32)height; ypos++){ if ((u32)y + ypos + yoff + baseLineY >= surface->height) break; for (u32 xpos = 0; xpos < (u32)width; xpos++){ if ((u32)x + xpos >= surface->width) break; // TODO: There are some oddities in the position of the character in the final buffer buffer[((int)y + ypos + yoff + baseLineY)*surface->width + (int)x+xpos] = box[ypos*width + xpos]; } } stbtt_FreeBitmap(box, 0); return CELL_FONT_OK; }
s64 cellSpursAttributeSetMemoryContainerForSpuThread(vm::ptr<CellSpursAttribute> attr, u32 container) { cellSpurs->Warning("cellSpursAttributeSetMemoryContainerForSpuThread(attr_addr=0x%x, container=0x%x)", attr.addr(), container); #ifdef PRX_DEBUG return GetCurrentPPUThread().FastCall2(libsre + 0x6FF8, libsre_rtoc); #else attr->attr->_setMemoryContainerForSpuThread(container); return CELL_OK; #endif }
s64 cellSpursCreateTask(vm::ptr<CellSpursTaskset> taskset, vm::ptr<be_t<u32>> taskID, u32 elf_addr, u32 context_addr, u32 context_size, vm::ptr<CellSpursTaskLsPattern> lsPattern, vm::ptr<CellSpursTaskArgument> argument) { #ifdef PRX_DEBUG cellSpurs->Warning("cellSpursCreateTask(taskset_addr=0x%x, taskID_addr=0x%x, elf_addr_addr=0x%x, context_addr_addr=0x%x, context_size=%d, lsPattern_addr=0x%x, argument_addr=0x%x)", taskset.addr(), taskID.addr(), elf_addr, context_addr, context_size, lsPattern.addr(), argument.addr()); return GetCurrentPPUThread().FastCall2(libsre + 0x12414, libsre_rtoc); #else UNIMPLEMENTED_FUNC(cellSpurs); return CELL_OK; #endif }
s64 cellSpursInitializeWithAttribute2(vm::ptr<CellSpurs2> spurs, vm::ptr<const CellSpursAttribute> attr) { cellSpurs->Warning("cellSpursInitializeWithAttribute2(spurs_addr=0x%x, spurs_addr=0x%x)", spurs.addr(), attr.addr()); #ifdef PRX_DEBUG return GetCurrentPPUThread().FastCall2(libsre + 0x82B4, libsre_rtoc); #else spurs->spurs = new SPURSManager(attr->attr); return CELL_OK; #endif }
s64 cellSpursFinalize(vm::ptr<CellSpurs> spurs) { cellSpurs->Warning("cellSpursFinalize(spurs_addr=0x%x)", spurs.addr()); #ifdef PRX_DEBUG return GetCurrentPPUThread().FastCall2(libsre + 0x8568, libsre_rtoc); #else spurs->spurs->Finalize(); return CELL_OK; #endif }