IHOSBinderDriver.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using ChocolArm64.Memory;
  2. using Ryujinx.Core.OsHle.Ipc;
  3. using Ryujinx.Core.OsHle.Objects.Android;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.Core.OsHle.Objects.Vi
  7. {
  8. class IHOSBinderDriver : IIpcInterface, IDisposable
  9. {
  10. private Dictionary<int, ServiceProcessRequest> m_Commands;
  11. public IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
  12. private NvFlinger Flinger;
  13. public IHOSBinderDriver()
  14. {
  15. m_Commands = new Dictionary<int, ServiceProcessRequest>()
  16. {
  17. { 0, TransactParcel },
  18. { 1, AdjustRefcount },
  19. { 2, GetNativeHandle }
  20. };
  21. Flinger = new NvFlinger();
  22. }
  23. public long TransactParcel(ServiceCtx Context)
  24. {
  25. int Id = Context.RequestData.ReadInt32();
  26. int Code = Context.RequestData.ReadInt32();
  27. long DataPos = Context.Request.SendBuff[0].Position;
  28. long DataSize = Context.Request.SendBuff[0].Size;
  29. byte[] Data = AMemoryHelper.ReadBytes(Context.Memory, DataPos, (int)DataSize);
  30. Data = Parcel.GetParcelData(Data);
  31. return Flinger.ProcessParcelRequest(Context, Data, Code);
  32. }
  33. public long AdjustRefcount(ServiceCtx Context)
  34. {
  35. int Id = Context.RequestData.ReadInt32();
  36. int AddVal = Context.RequestData.ReadInt32();
  37. int Type = Context.RequestData.ReadInt32();
  38. return 0;
  39. }
  40. public long GetNativeHandle(ServiceCtx Context)
  41. {
  42. int Id = Context.RequestData.ReadInt32();
  43. uint Unk = Context.RequestData.ReadUInt32();
  44. Context.Response.HandleDesc = IpcHandleDesc.MakeMove(0xbadcafe);
  45. return 0;
  46. }
  47. public void Dispose()
  48. {
  49. Dispose(true);
  50. }
  51. protected virtual void Dispose(bool disposing)
  52. {
  53. if (disposing)
  54. {
  55. Flinger.Dispose();
  56. }
  57. }
  58. }
  59. }