public void ExecuteQueued(CpuThreadState BaseCpuThreadState) { if (Enabled) { HleCallback[] HleCallbackListCopy; lock (HleCallbackList) { HleCallbackListCopy = HleCallbackList.ToArray(); HleCallbackList.Clear(); } foreach (var HleCallback in HleCallbackListCopy) { var FakeCpuThreadState = new CpuThreadState(CpuProcessor); FakeCpuThreadState.CopyRegistersFrom(BaseCpuThreadState); HleCallback.SetArgumentsToCpuThreadState(FakeCpuThreadState); HleInterop.Execute(FakeCpuThreadState); //Console.Error.WriteLine("Execute queued"); // Execute just one! break; } } }
public int ExecuteQueued(CpuThreadState CpuThreadState, bool MustReschedule) { int ExecutedCount = 0; if (HasScheduledCallbacks) { //Console.Error.WriteLine("STARTED CALLBACKS"); while (HasScheduledCallbacks) { var HleCallback = DequeueScheduledCallback(); var FakeCpuThreadState = new CpuThreadState(CpuProcessor); FakeCpuThreadState.CopyRegistersFrom(CpuThreadState); HleCallback.SetArgumentsToCpuThreadState(FakeCpuThreadState); try { HleInterop.Execute(FakeCpuThreadState); } finally { ExecutedCount++; } //Console.Error.WriteLine(" CALLBACK ENDED : " + HleCallback); if (MustReschedule) { //Console.Error.WriteLine(" RESCHEDULE"); break; } } //Console.Error.WriteLine("ENDED CALLBACKS"); } return(ExecutedCount); }
public int sceKernelStartModule(CpuThreadState CpuThreadState, int ModuleId, int ArgumentsSize, uint ArgumentsPointer, int *Status, SceKernelSMOption *SceKernelSMOption) { var Module = Modules.Get(ModuleId); if (Module.Loaded) { var NewCpuThreadState = new CpuThreadState(CpuThreadState.CpuProcessor); NewCpuThreadState.CopyRegistersFrom(CpuThreadState); NewCpuThreadState.Gp = Module.InitInfo.Gp; NewCpuThreadState.CallerModule = Module; var ThreadId = (int)ThreadManForUser.sceKernelCreateThread(NewCpuThreadState, "ModuleThread", Module.InitInfo.Pc, 10, 1024, PspThreadAttributes.ClearStack, null); ThreadManForUser.sceKernelStartThread(NewCpuThreadState, ThreadId, ArgumentsSize, ArgumentsPointer); } //throw(new NotImplementedException()); if (Status != null) { *Status = 0; } return(0); }