public int sceKernelCancelEventFlag(HleEventFlag EventFlag, int NewPattern, int* NumWaitThread) { foreach (var WaitingThread in EventFlag.WaitingThreads) { WaitingThread.WakeUpCallback(); } //throw(new NotImplementedException()); return 0; }
public EventFlagId sceKernelCreateEventFlag(string Name, HleEventFlag.AttributesSet Attributes, uint BitPattern, SceKernelEventFlagOptParam* OptionsPtr) { if (OptionsPtr != null) throw (new NotImplementedException("(OptionsPtr != null)")); var HleEventFlag = new HleEventFlag() { Name = Name, Attributes = Attributes, BitPattern = BitPattern, }; HleEventFlag.Info.InitialPattern = BitPattern; return HleState.EventFlagManager.EventFlags.Create(HleEventFlag); }
public HleEventFlag sceKernelCreateEventFlag(string Name, HleEventFlag.AttributesSet Attributes, uint BitPattern, SceKernelEventFlagOptParam* OptionsPtr) { if (OptionsPtr != null) throw (new NotImplementedException("(OptionsPtr != null)")); return new HleEventFlag() { Name = Name, Info = new EventFlagInfo(0) { Name = Name, Attributes = Attributes, InitialPattern = BitPattern, CurrentPattern = BitPattern, }, }; }
public EventFlagId sceKernelCreateEventFlag(string Name, HleEventFlag.AttributesSet Attributes, uint BitPattern, SceKernelEventFlagOptParam* OptionsPtr) { if (OptionsPtr != null) throw (new NotImplementedException("(OptionsPtr != null)")); var HleEventFlag = new HleEventFlag() { Name = Name, Info = new EventFlagInfo(0) { Attributes = Attributes, InitialPattern = BitPattern, CurrentPattern = BitPattern, }, }; #if false HleEventFlag.Info.InitialPattern = 3; HleEventFlag.Info.CurrentPattern = 3; #endif return EventFlagManager.EventFlags.Create(HleEventFlag); }
public int sceKernelDeleteEventFlag(HleEventFlag EventFlag) { EventFlag.RemoveUid(InjectContext); return 0; }
public int sceKernelClearEventFlag(HleEventFlag EventFlag, uint BitsToClear) { EventFlag.ClearBits(BitsToClear); return 0; }
/// <summary> /// Wait for an event flag for a given bit pattern with callback. /// </summary> /// <param name="EventId">The event ID returned by <see cref="sceKernelCreateEventFlag"/>.</param> /// <param name="Bits">The bit pattern to poll for.</param> /// <param name="Wait">Wait type, one or more of PspEventFlagWaitTypes or'ed together</param> /// <param name="OutBits">The bit pattern that was matched.</param> /// <param name="Timeout">Timeout in microseconds</param> /// <param name="HandleCallbacks"></param> /// <returns> /// ERROR_KERNEL_NOT_FOUND_EVENT_FLAG - If can't find the eventFlag /// ERROR_KERNEL_WAIT_TIMEOUT - If there was a timeout /// 0 - On success /// </returns> public int _sceKernelWaitEventFlagCB(HleEventFlag EventFlag, uint Bits, EventFlagWaitTypeSet Wait, uint* OutBits, uint* Timeout, bool HandleCallbacks) { if ((Wait & ~(EventFlagWaitTypeSet.MaskValidBits)) != 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_ILLEGAL_MODE)); if (Bits == 0) throw (new SceKernelException(SceKernelErrors.ERROR_KERNEL_EVENT_FLAG_ILLEGAL_WAIT_PATTERN)); bool TimedOut = false; var PreviousPattern = EventFlag.Info.CurrentPattern; ThreadManager.Current.SetWaitAndPrepareWakeUp( HleThread.WaitType.Semaphore, String.Format("_sceKernelWaitEventFlagCB(EventId={0}, Bits={1:X}, Wait={2})", EventFlag.GetUidIndex(InjectContext), Bits, Wait), EventFlag, WakeUpCallback => { if (Timeout != null) { PspRtc.RegisterTimerInOnce(TimeSpanUtils.FromMicroseconds(*Timeout), () => { TimedOut = true; *Timeout = 0; WakeUpCallback(); }); } EventFlag.AddWaitingThread(new HleEventFlag.WaitThread() { HleThread = ThreadManager.Current, BitsToMatch = Bits, WaitType = Wait, WakeUpCallback = () => { WakeUpCallback(); }, OutBits = OutBits, }); }, HandleCallbacks: HandleCallbacks); if (OutBits != null) { *OutBits = PreviousPattern; } if (TimedOut) { throw(new SceKernelException(SceKernelErrors.ERROR_KERNEL_WAIT_TIMEOUT)); } //throw(new NotImplementedException()); return 0; }
public int sceKernelWaitEventFlagCB(HleEventFlag EventFlag, uint Bits, EventFlagWaitTypeSet WaitType, uint* OutBits, uint* Timeout) { return _sceKernelWaitEventFlagCB(EventFlag, Bits, WaitType, OutBits, Timeout, true); }
public int sceKernelSetEventFlag(HleEventFlag EventFlag, uint BitPattern) { //Console.WriteLine("FLAG:{0} : {1:X}", EventId, BitPattern); EventFlag.SetBits(BitPattern); return 0; }
public int sceKernelReferEventFlagStatus(HleEventFlag EventFlag, ref EventFlagInfo Info) { #if true if (Info.Size != 0) { Info = EventFlag.Info; } #else fixed (void* OutPtr = &Info) fixed (void* InPtr = &EventFlag.Info) { PointerUtils.Memcpy((byte*)OutPtr, (byte*)InPtr, Info.Size); } #endif //Console.WriteLine(Info); return 0; }