IDeliveryCacheDirectoryService.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 bufferAddress = context.Request.ReceiveBuff[0].Position;
  35. ulong bufferLen = context.Request.ReceiveBuff[0].Size;
  36. using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
  37. {
  38. Result result = _base.Get.Read(out int entriesRead, MemoryMarshal.Cast<byte, DeliveryCacheDirectoryEntry>(region.Memory.Span));
  39. context.ResponseData.Write(entriesRead);
  40. return (ResultCode)result.Value;
  41. }
  42. }
  43. [CommandHipc(2)]
  44. // GetCount() -> u32
  45. public ResultCode GetCount(ServiceCtx context)
  46. {
  47. Result result = _base.Get.GetCount(out int count);
  48. context.ResponseData.Write(count);
  49. return (ResultCode)result.Value;
  50. }
  51. }
  52. }