IpcPtrBuffDesc.cs 1.4 KB

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