void _Assert(ARMv7Context& context, vm::psv::ptr<const char> text, vm::psv::ptr<const char> func) { sceLibc.Error("_Assert(text=*0x%x, func=*0x%x)", text, func); LOG_ERROR(TTY, "%s : %s\n", func.get_ptr(), text.get_ptr()); LOG_NOTICE(ARMv7, context.thread.RegsToString()); Emu.Pause(); }
void sprintf(ARMv7Context& context, vm::psv::ptr<char> str, vm::psv::ptr<const char> fmt) // va_args... { sceLibc.Warning("sprintf(str=*0x%x, fmt=*0x%x)", str, fmt); sceLibc.Log("*** *fmt = '%s'", fmt.get_ptr()); const std::string& result = armv7_fmt(context, fmt, 2, 0, 0); sceLibc.Log("*** -> '%s'", result); ::memcpy(str.get_ptr(), result.c_str(), result.size() + 1); }
s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::psv::ptr<const void> pArgBlock) { sceLibKernel.Warning("sceKernelStartThread(threadId=0x%x, argSize=0x%x, pArgBlock=*0x%x)", threadId, argSize, pArgBlock); const auto t = Emu.GetCPU().GetThread(threadId, CPU_THREAD_ARMv7); if (!t) { RETURN_ERROR(SCE_KERNEL_ERROR_INVALID_UID); } // thread should be in DORMANT state, but it's not possible to check it correctly atm if (t->IsAlive()) { RETURN_ERROR(SCE_KERNEL_ERROR_NOT_DORMANT); } ARMv7Thread& thread = static_cast<ARMv7Thread&>(*t); // push arg block onto the stack const u32 pos = (thread.context.SP -= argSize); memcpy(vm::get_ptr<void>(pos), pArgBlock.get_ptr(), argSize); // set SceKernelThreadEntry function arguments thread.context.GPR[0] = argSize; thread.context.GPR[1] = pos; thread.Exec(); return SCE_OK; }
void printf(ARMv7Context& context, vm::psv::ptr<const char> fmt) // va_args... { sceLibc.Warning("printf(fmt=*0x%x)", fmt); sceLibc.Log("*** *fmt = '%s'", fmt.get_ptr()); const std::string& result = armv7_fmt(context, fmt, 1, 0, 0); sceLibc.Log("*** -> '%s'", result); LOG_NOTICE(TTY, result); }
s32 sceKernelCreateCond(vm::psv::ptr<const char> pName, u32 attr, s32 mutexId, vm::psv::ptr<const SceKernelCondOptParam> pOptParam) { sceLibKernel.Error("sceKernelCreateCond(pName=*0x%x, attr=0x%x, mutexId=0x%x, pOptParam=*0x%x)", pName, attr, mutexId, pOptParam); if (s32 id = g_psv_cond_list.create(pName.get_ptr(), attr, mutexId)) { return id; } RETURN_ERROR(SCE_KERNEL_ERROR_ERROR); }
s32 sceKernelCreateMutex(vm::psv::ptr<const char> pName, u32 attr, s32 initCount, vm::psv::ptr<const SceKernelMutexOptParam> pOptParam) { sceLibKernel.Error("sceKernelCreateMutex(pName=*0x%x, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam); if (s32 id = g_psv_mutex_list.create(pName.get_ptr(), attr, initCount)) { return id; } RETURN_ERROR(SCE_KERNEL_ERROR_ERROR); }
s32 sceKernelCreateEventFlag(vm::psv::ptr<const char> pName, u32 attr, u32 initPattern, vm::psv::ptr<const SceKernelEventFlagOptParam> pOptParam) { sceLibKernel.Error("sceKernelCreateEventFlag(pName=*0x%x, attr=0x%x, initPattern=0x%x, pOptParam=*0x%x)", pName, attr, initPattern, pOptParam); if (s32 id = g_psv_ef_list.create(pName.get_ptr(), attr, initPattern)) { return id; } RETURN_ERROR(SCE_KERNEL_ERROR_ERROR); }
s32 sceKernelCreateThread( vm::psv::ptr<const char> pName, vm::psv::ptr<SceKernelThreadEntry> entry, s32 initPriority, u32 stackSize, u32 attr, s32 cpuAffinityMask, vm::psv::ptr<const SceKernelThreadOptParam> pOptParam) { sceLibKernel.Warning("sceKernelCreateThread(pName=*0x%x, entry=*0x%x, initPriority=%d, stackSize=0x%x, attr=0x%x, cpuAffinityMask=0x%x, pOptParam=*0x%x)", pName, entry, initPriority, stackSize, attr, cpuAffinityMask, pOptParam); auto t = Emu.GetCPU().AddThread(CPU_THREAD_ARMv7); auto& armv7 = static_cast<ARMv7Thread&>(*t); armv7.SetEntry(entry.addr()); armv7.SetPrio(initPriority); armv7.SetStackSize(stackSize); armv7.SetName(pName.get_ptr()); armv7.Run(); return armv7.GetId(); }
void memset(vm::psv::ptr<void> dst, s32 value, u32 size) { sceLibc.Warning("memset(dst=*0x%x, value=%d, size=0x%x)", dst, value, size); ::memset(dst.get_ptr(), value, size); }
void memcpy(vm::psv::ptr<void> dst, vm::psv::ptr<const void> src, u32 size) { sceLibc.Warning("memcpy(dst=*0x%x, src=*0x%x, size=0x%x)", dst, src, size); ::memcpy(dst.get_ptr(), src.get_ptr(), size); }