void __KernelInit() { if (kernelRunning) { ERROR_LOG(SCEKERNEL, "Can't init kernel when kernel is running"); return; } __KernelTimeInit(); __InterruptsInit(); __KernelMemoryInit(); __KernelThreadingInit(); __KernelAlarmInit(); __KernelVTimerInit(); __KernelEventFlagInit(); __KernelMbxInit(); __KernelMutexInit(); __KernelSemaInit(); __KernelMsgPipeInit(); __IoInit(); __JpegInit(); __AudioInit(); __SasInit(); __AtracInit(); __CccInit(); __DisplayInit(); __GeInit(); __PowerInit(); __UtilityInit(); __UmdInit(); __MpegInit(); __PsmfInit(); __CtrlInit(); __RtcInit(); __SslInit(); __ImposeInit(); __UsbInit(); __FontInit(); __NetInit(); __NetAdhocInit(); __VaudioInit(); __CheatInit(); __HeapInit(); __DmacInit(); __AudioCodecInit(); __VideoPmpInit(); SaveState::Init(); // Must be after IO, as it may create a directory Reporting::Init(); // "Internal" PSP libraries __PPGeInit(); kernelRunning = true; INFO_LOG(SCEKERNEL, "Kernel initialized."); }
void sceKernelCreateLwMutex(u32 workareaPtr, const char *name, u32 attr, int initialCount, u32 optionsPtr) { if (!mutexInitComplete) __KernelMutexInit(); DEBUG_LOG(HLE,"sceKernelCreateLwMutex(%08x, %s, %08x, %d, %08x)", workareaPtr, name, attr, initialCount, optionsPtr); u32 error = 0; if (!name) error = SCE_KERNEL_ERROR_ERROR; else if (initialCount < 0) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; else if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; if (error) { RETURN(error); return; } LwMutex *mutex = new LwMutex(); SceUID id = kernelObjects.Create(mutex); mutex->nm.size = sizeof(mutex); strncpy(mutex->nm.name, name, 31); mutex->nm.name[31] = 0; mutex->nm.attr = attr; mutex->nm.workareaPtr = workareaPtr; NativeLwMutexWorkarea workarea; workarea.init(); workarea.lockLevel = initialCount; if (initialCount == 0) workarea.lockThread = 0; else workarea.lockThread = __KernelGetCurThread(); workarea.attr = attr; workarea.uid = id; Memory::WriteStruct(workareaPtr, &workarea); if (optionsPtr != 0) WARN_LOG(HLE,"sceKernelCreateLwMutex(%s) unsupported options parameter.", name); RETURN(0); __KernelReSchedule("lwmutex created"); }
void __KernelInit() { if (kernelRunning) { ERROR_LOG(HLE, "Can't init kernel when kernel is running"); return; } __KernelTimeInit(); __InterruptsInit(); __KernelMemoryInit(); __KernelThreadingInit(); __KernelAlarmInit(); __KernelVTimerInit(); __KernelEventFlagInit(); __KernelMbxInit(); __KernelMutexInit(); __KernelSemaInit(); __IoInit(); __AudioInit(); __SasInit(); __AtracInit(); __DisplayInit(); __GeInit(); __PowerInit(); __UtilityInit(); __UmdInit(); __MpegInit(PSP_CoreParameter().useMediaEngine); __PsmfInit(); __CtrlInit(); __RtcInit(); __SslInit(); __ImposeInit(); __UsbInit(); __FontInit(); __NetInit(); __VaudioInit(); __CheatInit(); SaveState::Init(); // Must be after IO, as it may create a directory // "Internal" PSP libraries __PPGeInit(); kernelRunning = true; INFO_LOG(HLE, "Kernel initialized."); }
void sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr) { if (!mutexInitComplete) __KernelMutexInit(); u32 error = 0; if (!name) error = SCE_KERNEL_ERROR_ERROR; else if (initialCount < 0) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; else if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1) error = SCE_KERNEL_ERROR_ILLEGAL_COUNT; if (error) { RETURN(error); return; } DEBUG_LOG(HLE,"sceKernelCreateMutex(%s, %08x, %d, %08x)", name, attr, initialCount, optionsPtr); Mutex *mutex = new Mutex(); SceUID id = kernelObjects.Create(mutex); mutex->nm.size = sizeof(mutex); strncpy(mutex->nm.name, name, 31); mutex->nm.name[31] = 0; mutex->nm.attr = attr; if (initialCount == 0) { mutex->nm.lockLevel = 0; mutex->nm.lockThread = -1; } else __KernelMutexAcquireLock(mutex, initialCount); if (optionsPtr != 0) WARN_LOG(HLE,"sceKernelCreateMutex(%s) unsupported options parameter.", name); RETURN(id); __KernelReSchedule("mutex created"); }