mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-11-16 10:05:25 +00:00
9426ef3f06
* 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
81 lines
3.1 KiB
C#
81 lines
3.1 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Memory;
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
|
|
{
|
|
abstract class NvDeviceFile
|
|
{
|
|
public readonly KProcess Owner;
|
|
|
|
public NvDeviceFile(ServiceCtx context)
|
|
{
|
|
Owner = context.Process;
|
|
}
|
|
|
|
public virtual NvInternalResult QueryEvent(out int eventHandle, uint eventId)
|
|
{
|
|
eventHandle = 0;
|
|
|
|
return NvInternalResult.NotImplemented;
|
|
}
|
|
|
|
public virtual NvInternalResult MapSharedMemory(KSharedMemory sharedMemory, uint argument)
|
|
{
|
|
return NvInternalResult.NotImplemented;
|
|
}
|
|
|
|
public virtual NvInternalResult Ioctl(NvIoctl command, Span<byte> arguments)
|
|
{
|
|
return NvInternalResult.NotImplemented;
|
|
}
|
|
|
|
public virtual NvInternalResult Ioctl2(NvIoctl command, Span<byte> arguments, Span<byte> inlineInBuffer)
|
|
{
|
|
return NvInternalResult.NotImplemented;
|
|
}
|
|
|
|
public virtual NvInternalResult Ioctl3(NvIoctl command, Span<byte> arguments, Span<byte> inlineOutBuffer)
|
|
{
|
|
return NvInternalResult.NotImplemented;
|
|
}
|
|
|
|
protected delegate NvInternalResult IoctlProcessor<T>(ref T arguments);
|
|
protected delegate NvInternalResult IoctlProcessorSpan<T>(Span<T> arguments);
|
|
protected delegate NvInternalResult IoctlProcessorInline<T, T1>(ref T arguments, ref T1 inlineData);
|
|
protected delegate NvInternalResult IoctlProcessorInlineSpan<T, T1>(ref T arguments, Span<T1> inlineData);
|
|
|
|
protected static NvInternalResult CallIoctlMethod<T>(IoctlProcessor<T> callback, Span<byte> arguments) where T : struct
|
|
{
|
|
Debug.Assert(arguments.Length == Unsafe.SizeOf<T>());
|
|
|
|
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0]);
|
|
}
|
|
|
|
protected static NvInternalResult CallIoctlMethod<T, T1>(IoctlProcessorInline<T, T1> callback, Span<byte> arguments, Span<byte> inlineBuffer) where T : struct where T1 : struct
|
|
{
|
|
Debug.Assert(arguments.Length == Unsafe.SizeOf<T>());
|
|
Debug.Assert(inlineBuffer.Length == Unsafe.SizeOf<T1>());
|
|
|
|
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0], ref MemoryMarshal.Cast<byte, T1>(inlineBuffer)[0]);
|
|
}
|
|
|
|
protected static NvInternalResult CallIoctlMethod<T>(IoctlProcessorSpan<T> callback, Span<byte> arguments) where T : struct
|
|
{
|
|
return callback(MemoryMarshal.Cast<byte, T>(arguments));
|
|
}
|
|
|
|
protected static NvInternalResult CallIoctlMethod<T, T1>(IoctlProcessorInlineSpan<T, T1> callback, Span<byte> arguments, Span<byte> inlineBuffer) where T : struct where T1 : struct
|
|
{
|
|
Debug.Assert(arguments.Length == Unsafe.SizeOf<T>());
|
|
|
|
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0], MemoryMarshal.Cast<byte, T1>(inlineBuffer));
|
|
}
|
|
|
|
public abstract void Close();
|
|
}
|
|
}
|