IDeliveryCacheDirectoryService.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using LibHac;
  2. using LibHac.Bcat;
  3. using LibHac.Common;
  4. using Ryujinx.Common;
  5. using System.Runtime.InteropServices;
  6. namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
  7. {
  8. class IDeliveryCacheDirectoryService : DisposableIpcService
  9. {
  10. private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> _base;
  11. public IDeliveryCacheDirectoryService(ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService> baseService)
  12. {
  13. _base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>.CreateMove(ref baseService);
  14. }
  15. protected override void Dispose(bool isDisposing)
  16. {
  17. if (isDisposing)
  18. {
  19. _base.Destroy();
  20. }
  21. }
  22. [CommandHipc(0)]
  23. // Open(nn::bcat::DirectoryName)
  24. public ResultCode Open(ServiceCtx context)
  25. {
  26. DirectoryName directoryName = context.RequestData.ReadStruct<DirectoryName>();
  27. Result result = _base.Get.Open(ref directoryName);
  28. return (ResultCode)result.Value;
  29. }
  30. [CommandHipc(1)]
  31. // Read() -> (u32, buffer<nn::bcat::DeliveryCacheDirectoryEntry, 6>)
  32. public ResultCode Read(ServiceCtx context)
  33. {
  34. ulong position = context.Request.ReceiveBuff[0].Position;
  35. ulong size = context.Request.ReceiveBuff[0].Size;
  36. byte[] data = new byte[size];
  37. Result result = _base.Get.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(data));
  38. context.Memory.Write(position, data);
  39. context.ResponseData.Write(entriesRead);
  40. return (ResultCode)result.Value;
  41. }
  42. [CommandHipc(2)]
  43. // GetCount() -> u32
  44. public ResultCode GetCount(ServiceCtx context)
  45. {
  46. Result result = _base.Get.GetCount(out int count);
  47. context.ResponseData.Write(count);
  48. return (ResultCode)result.Value;
  49. }
  50. }
  51. }