SvcHandler.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using ARMeilleure.State;
  2. using Ryujinx.HLE.HOS.Kernel.Process;
  3. using Ryujinx.HLE.HOS.Kernel.Threading;
  4. using System;
  5. namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
  6. {
  7. partial class SvcHandler
  8. {
  9. private Switch _device;
  10. private KProcess _process;
  11. private Horizon _system;
  12. public SvcHandler(Switch device, KProcess process)
  13. {
  14. _device = device;
  15. _process = process;
  16. _system = device.System;
  17. }
  18. public void SvcCall(object sender, InstExceptionEventArgs e)
  19. {
  20. ExecutionContext context = (ExecutionContext)sender;
  21. Action<SvcHandler, ExecutionContext> svcFunc = context.IsAarch32 ? SvcTable.SvcTable32[e.Id] : SvcTable.SvcTable64[e.Id];
  22. if (svcFunc == null)
  23. {
  24. throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
  25. }
  26. svcFunc(this, context);
  27. PostSvcHandler();
  28. }
  29. private void PostSvcHandler()
  30. {
  31. KThread currentThread = _system.Scheduler.GetCurrentThread();
  32. currentThread.HandlePostSyscall();
  33. }
  34. }
  35. }