ILibraryAppletAccessor.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.Kernel.Common;
  4. using Ryujinx.HLE.HOS.Kernel.Threading;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace Ryujinx.HLE.HOS.Services.Am
  8. {
  9. class ILibraryAppletAccessor : IpcService
  10. {
  11. private Dictionary<int, ServiceProcessRequest> _commands;
  12. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  13. private KEvent _stateChangedEvent;
  14. public ILibraryAppletAccessor(Horizon system)
  15. {
  16. _commands = new Dictionary<int, ServiceProcessRequest>
  17. {
  18. { 0, GetAppletStateChangedEvent },
  19. { 10, Start },
  20. { 30, GetResult },
  21. { 100, PushInData },
  22. { 101, PopOutData }
  23. };
  24. _stateChangedEvent = new KEvent(system);
  25. }
  26. public long GetAppletStateChangedEvent(ServiceCtx context)
  27. {
  28. _stateChangedEvent.ReadableEvent.Signal();
  29. if (context.Process.HandleTable.GenerateHandle(_stateChangedEvent.ReadableEvent, out int handle) != KernelResult.Success)
  30. {
  31. throw new InvalidOperationException("Out of handles!");
  32. }
  33. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
  34. Logger.PrintStub(LogClass.ServiceAm);
  35. return 0;
  36. }
  37. public long Start(ServiceCtx context)
  38. {
  39. Logger.PrintStub(LogClass.ServiceAm);
  40. return 0;
  41. }
  42. public long GetResult(ServiceCtx context)
  43. {
  44. Logger.PrintStub(LogClass.ServiceAm);
  45. return 0;
  46. }
  47. public long PushInData(ServiceCtx context)
  48. {
  49. Logger.PrintStub(LogClass.ServiceAm);
  50. return 0;
  51. }
  52. public long PopOutData(ServiceCtx context)
  53. {
  54. MakeObject(context, new IStorage(StorageHelper.MakeLaunchParams()));
  55. return 0;
  56. }
  57. }
  58. }