1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-05 02:02:01 +00:00
Ryujinx/Ryujinx.HLE/HOS/Services/Nv/NvIoctl.cs
Thomas Guillemard 9426ef3f06 Rewrite nvservices (#800)
* Start rewriting nvservices internals

TODO:

- nvgpu device interface
- nvhost generic device interface

* Some clean up and fixes

- Make sure to remove the fd of a closed channel.
- NvFileDevice now doesn't implement Disposable as it was never used.
- Rename NvHostCtrlGetConfigurationArgument to GetConfigurationArguments
to follow calling convention.
- Make sure to check every ioctls magic.

* Finalize migration for ioctl standard variant

TODO: ioctl2 migration

* Implement SubmitGpfifoEx and fix nvdec

* Implement Ioctl3

* Implement some ioctl3 required by recent games

* Remove unused code and outdated comments

* Return valid event handles with QueryEvent

Also add an exception for unimplemented event ids.

This commit doesn't implement accurately the events, this only define
different events for different event ids.

* Rename all occurance of FileDevice to DeviceFile

* Restub SetClientPid to not cause regressions

* Address comments

* Remove GlobalStateTable

* Address comments

* Align variables in ioctl3

* Some missing alignments

* GetVaRegionsArguments realign

* Make Owner public in NvDeviceFile

* Address LDj3SNuD's comments
2019-11-03 09:47:56 +11:00

45 lines
1.6 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nv
{
[StructLayout(LayoutKind.Sequential)]
struct NvIoctl
{
public const int NvHostCustomMagic = 0x00;
public const int NvMapCustomMagic = 0x01;
public const int NvGpuAsMagic = 0x41;
public const int NvGpuMagic = 0x47;
public const int NvHostMagic = 0x48;
private const int NumberBits = 8;
private const int TypeBits = 8;
private const int SizeBits = 14;
private const int DirectionBits = 2;
private const int NumberShift = 0;
private const int TypeShift = NumberShift + NumberBits;
private const int SizeShift = TypeShift + TypeBits;
private const int DirectionShift = SizeShift + SizeBits;
private const int NumberMask = (1 << NumberBits) - 1;
private const int TypeMask = (1 << TypeBits) - 1;
private const int SizeMask = (1 << SizeBits) - 1;
private const int DirectionMask = (1 << DirectionBits) - 1;
[Flags]
public enum Direction : uint
{
None = 0,
Read = 1,
Write = 2,
}
public uint RawValue;
public uint Number => (RawValue >> NumberShift) & NumberMask;
public uint Type => (RawValue >> TypeShift) & TypeMask;
public uint Size => (RawValue >> SizeShift) & SizeMask;
public Direction DirectionValue => (Direction)((RawValue >> DirectionShift) & DirectionMask);
}
}