NvIoctl.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Ryujinx.HLE.HOS.Services.Nv
  4. {
  5. [StructLayout(LayoutKind.Sequential)]
  6. struct NvIoctl
  7. {
  8. public const int NvHostCustomMagic = 0x00;
  9. public const int NvMapCustomMagic = 0x01;
  10. public const int NvGpuAsMagic = 0x41;
  11. public const int NvGpuMagic = 0x47;
  12. public const int NvHostMagic = 0x48;
  13. private const int NumberBits = 8;
  14. private const int TypeBits = 8;
  15. private const int SizeBits = 14;
  16. private const int DirectionBits = 2;
  17. private const int NumberShift = 0;
  18. private const int TypeShift = NumberShift + NumberBits;
  19. private const int SizeShift = TypeShift + TypeBits;
  20. private const int DirectionShift = SizeShift + SizeBits;
  21. private const int NumberMask = (1 << NumberBits) - 1;
  22. private const int TypeMask = (1 << TypeBits) - 1;
  23. private const int SizeMask = (1 << SizeBits) - 1;
  24. private const int DirectionMask = (1 << DirectionBits) - 1;
  25. [Flags]
  26. public enum Direction : uint
  27. {
  28. None = 0,
  29. Read = 1,
  30. Write = 2,
  31. }
  32. public uint RawValue;
  33. public uint Number => (RawValue >> NumberShift) & NumberMask;
  34. public uint Type => (RawValue >> TypeShift) & TypeMask;
  35. public uint Size => (RawValue >> SizeShift) & SizeMask;
  36. public Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask);
  37. }
  38. }