public int sceKernelCreateLwMutex(SceLwMutexWorkarea *WorkAreaPointer, string Name, ThreadManForUser.MutexAttributesEnum Attributes, int InitialCount, int OptionAddress) { WorkAreaPointer->attr = Attributes; WorkAreaPointer->lockLevel = 0; //throw(new NotImplementedException()); return(0); }
private int _sceKernelLockLwMutexCB(SceLwMutexWorkarea *workarea, int count, int *TimeOut, bool HandleCallbacks) { #if false if (count <= 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (count > 1 && workarea->attr.HasFlagGeneric(ThreadManForUser.MutexAttributesEnum.AllowRecursive)) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (count + workarea->lockLevel < 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_LOCK_OVERFLOW)); } if (workarea->uid == -1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_NOT_FOUND)); } if (workarea->lockLevel == 0) { if (workarea->lockThread != 0) { // Validate that it actually exists so we can return an error if not. kernelObjects.Get <LwMutex>(workarea->uid, error); if (error) { return(false); } } workarea->lockLevel = count; workarea->lockThread = __KernelGetCurThread(); return(true); } if (workarea->lockThread == __KernelGetCurThread()) { // Recursive mutex, let's just increase the lock count and keep going if (workarea->attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) { workarea->lockLevel += count; return(true); } else { error = PSP_LWMUTEX_ERROR_ALREADY_LOCKED; return(false); } } #endif return(0); }
private int _sceKernelUnlockLwMutex(SceLwMutexWorkarea *workarea, int count) { /*xDPx removed this section some resion the unclock function was not included*/ //return 0; if (workarea->uid == -1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_NOT_FOUND)); } if (count <= 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if ((workarea->attr & ThreadManForUser.MutexAttributesEnum.AllowRecursive) == 0 && count > 1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (workarea->lockLevel == 0 || workarea->lockThread != HleThreadManager.Current.Id) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_UNLOCKED)); } if (workarea->lockLevel < count) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_UNLOCK_UNDERFLOW)); } workarea->lockLevel -= count; if (workarea->lockLevel == 0) { HleThreadManager.GetThreadById(workarea->lockThread).WakeUpAndReschedule(); } return(0); }
private int _sceKernelTryLockLwMutex(SceLwMutexWorkarea *WorkAreaPointer, int Count) { return(0); }
public int sceKernelLockLwMutexCB(SceLwMutexWorkarea *WorkAreaPointer, int Count, int *TimeOut) { return(_sceKernelLockLwMutexCB(WorkAreaPointer, Count, TimeOut, HandleCallbacks: true)); }
public int sceKernelTryLockLwMutex_600(SceLwMutexWorkarea *WorkAreaPointer, int Count) { return(_sceKernelTryLockLwMutex(WorkAreaPointer, Count)); }
private int _sceKernelLockLwMutexCB(SceLwMutexWorkarea *workarea, int count, int *TimeOut, bool HandleCallbacks) { /*xDPx Uncomented IF false * We should be able to use ths code validate on kernel obejcts seems to cause an issue and no error defined*/ SceKernelErrors error = SceKernelErrors.ERROR_OK; //TODO! //: ADD VALIDATE FLAG if (count <= 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (count > 1 && workarea->attr.HasFlag(ThreadManForUser.MutexAttributesEnum.AllowRecursive)) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_COUNT)); } if (count + workarea->lockLevel < 0) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_LOCK_OVERFLOW)); } if (workarea->uid == -1) { throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_LWMUTEX_NOT_FOUND)); } if (workarea->lockLevel == 0) { if (workarea->lockThread != 0) { // Validate that it actually exists so we can return an error if not. // kernelObjects.Get<LwMutex>(workarea->uid, error); // Kernel_Library.GetObjectFromPoolHelper<SceKernelLwMutexInfo>(workarea->uid, error); //if (error) // return 0; } workarea->lockLevel = count; workarea->lockThread = sceKernelGetThreadId(); // __KernelGetCurThread()) return(1); } if (workarea->lockThread == sceKernelGetThreadId())// __KernelGetCurThread()) { // Recursive mutex, let's just increase the lock count and keep going if (workarea->attr == ThreadManForUser.MutexAttributesEnum.AllowRecursive) { workarea->lockLevel += count; return(1); } else { error = SceKernelErrors.ERROR_KERNEL_LWMUTEX_LOCKED; //PSP_LWMUTEX_ERROR_ALREADY_LOCKED; return(0); } } return(0); }
public int sceKernelDeleteLwMutex(SceLwMutexWorkarea *WorkAreaPointer) { //throw (new NotImplementedException()); return(0); }