IpcPtrBuffDesc.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.IO;
  2. namespace Ryujinx.HLE.HOS.Ipc
  3. {
  4. struct IpcPtrBuffDesc
  5. {
  6. public long Position { get; private set; }
  7. public int Index { get; private set; }
  8. public long Size { get; private set; }
  9. public IpcPtrBuffDesc(long position, int index, long size)
  10. {
  11. Position = position;
  12. Index = index;
  13. Size = size;
  14. }
  15. public IpcPtrBuffDesc(BinaryReader reader)
  16. {
  17. long word0 = reader.ReadUInt32();
  18. long word1 = reader.ReadUInt32();
  19. Position = word1;
  20. Position |= (word0 << 20) & 0x0f00000000;
  21. Position |= (word0 << 30) & 0x7000000000;
  22. Index = ((int)word0 >> 0) & 0x03f;
  23. Index |= ((int)word0 >> 3) & 0x1c0;
  24. Size = (ushort)(word0 >> 16);
  25. }
  26. public uint GetWord0()
  27. {
  28. uint word0;
  29. word0 = (uint)((Position & 0x0f00000000) >> 20);
  30. word0 |= (uint)((Position & 0x7000000000) >> 30);
  31. word0 |= (uint)(Index & 0x03f) << 0;
  32. word0 |= (uint)(Index & 0x1c0) << 3;
  33. word0 |= (uint)Size << 16;
  34. return word0;
  35. }
  36. public uint GetWord1()
  37. {
  38. return (uint)Position;
  39. }
  40. }
  41. }