IDeliveryCacheProgressService.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.Cpu;
  4. using Ryujinx.HLE.HOS.Ipc;
  5. using Ryujinx.HLE.HOS.Kernel.Common;
  6. using Ryujinx.HLE.HOS.Kernel.Threading;
  7. using Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator.Types;
  8. using System;
  9. using System.IO;
  10. namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
  11. {
  12. class IDeliveryCacheProgressService : IpcService
  13. {
  14. private KEvent _event;
  15. private int _eventHandle;
  16. public IDeliveryCacheProgressService(ServiceCtx context)
  17. {
  18. _event = new KEvent(context.Device.System.KernelContext);
  19. }
  20. [CommandHipc(0)]
  21. // GetEvent() -> handle<copy>
  22. public ResultCode GetEvent(ServiceCtx context)
  23. {
  24. if (_eventHandle == 0)
  25. {
  26. if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out _eventHandle) != KernelResult.Success)
  27. {
  28. throw new InvalidOperationException("Out of handles!");
  29. }
  30. }
  31. context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_eventHandle);
  32. Logger.Stub?.PrintStub(LogClass.ServiceBcat);
  33. return ResultCode.Success;
  34. }
  35. [CommandHipc(1)]
  36. // GetImpl() -> buffer<nn::bcat::detail::DeliveryCacheProgressImpl, 0x1a>
  37. public ResultCode GetImpl(ServiceCtx context)
  38. {
  39. DeliveryCacheProgressImpl deliveryCacheProgress = new DeliveryCacheProgressImpl
  40. {
  41. State = DeliveryCacheProgressImpl.Status.Done,
  42. Result = 0
  43. };
  44. ulong dcpSize = WriteDeliveryCacheProgressImpl(context, context.Request.RecvListBuff[0], deliveryCacheProgress);
  45. context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(dcpSize);
  46. Logger.Stub?.PrintStub(LogClass.ServiceBcat);
  47. return ResultCode.Success;
  48. }
  49. private ulong WriteDeliveryCacheProgressImpl(ServiceCtx context, IpcRecvListBuffDesc ipcDesc, DeliveryCacheProgressImpl deliveryCacheProgress)
  50. {
  51. return MemoryHelper.Write(context.Memory, ipcDesc.Position, deliveryCacheProgress);
  52. }
  53. }
  54. }