IDeliveryCacheProgressService.cs 2.1 KB

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