SyscallHandler.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using ARMeilleure.State;
  2. using Ryujinx.HLE.HOS.Kernel.Threading;
  3. using System;
  4. namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
  5. {
  6. partial class SyscallHandler
  7. {
  8. private readonly KernelContext _context;
  9. private readonly Syscall32 _syscall32;
  10. private readonly Syscall64 _syscall64;
  11. public SyscallHandler(KernelContext context)
  12. {
  13. _context = context;
  14. _syscall32 = new Syscall32(context.Syscall);
  15. _syscall64 = new Syscall64(context.Syscall);
  16. }
  17. public void SvcCall(object sender, InstExceptionEventArgs e)
  18. {
  19. ExecutionContext context = (ExecutionContext)sender;
  20. if (context.IsAarch32)
  21. {
  22. var svcFunc = SyscallTable.SvcTable32[e.Id];
  23. if (svcFunc == null)
  24. {
  25. throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
  26. }
  27. svcFunc(_syscall32, context);
  28. }
  29. else
  30. {
  31. var svcFunc = SyscallTable.SvcTable64[e.Id];
  32. if (svcFunc == null)
  33. {
  34. throw new NotImplementedException($"SVC 0x{e.Id:X4} is not implemented.");
  35. }
  36. svcFunc(_syscall64, context);
  37. }
  38. PostSvcHandler();
  39. }
  40. private void PostSvcHandler()
  41. {
  42. KThread currentThread = KernelStatic.GetCurrentThread();
  43. currentThread.HandlePostSyscall();
  44. }
  45. }
  46. }