mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-11 15:46:38 +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
78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types;
|
|
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|
{
|
|
internal class NvHostGpuDeviceFile : NvHostChannelDeviceFile
|
|
{
|
|
private KEvent _smExceptionBptIntReportEvent;
|
|
private KEvent _smExceptionBptPauseReportEvent;
|
|
private KEvent _errorNotifierEvent;
|
|
|
|
public NvHostGpuDeviceFile(ServiceCtx context) : base(context)
|
|
{
|
|
_smExceptionBptIntReportEvent = new KEvent(context.Device.System);
|
|
_smExceptionBptPauseReportEvent = new KEvent(context.Device.System);
|
|
_errorNotifierEvent = new KEvent(context.Device.System);
|
|
}
|
|
|
|
public override NvInternalResult Ioctl2(NvIoctl command, Span<byte> arguments, Span<byte> inlineInBuffer)
|
|
{
|
|
NvInternalResult result = NvInternalResult.NotImplemented;
|
|
|
|
if (command.Type == NvIoctl.NvHostMagic)
|
|
{
|
|
switch (command.Number)
|
|
{
|
|
case 0x1b:
|
|
result = CallIoctlMethod<SubmitGpfifoArguments, long>(SubmitGpfifoEx, arguments, inlineInBuffer);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public override NvInternalResult QueryEvent(out int eventHandle, uint eventId)
|
|
{
|
|
// TODO: accurately represent and implement those events.
|
|
KEvent targetEvent = null;
|
|
|
|
switch (eventId)
|
|
{
|
|
case 0x1:
|
|
targetEvent = _smExceptionBptIntReportEvent;
|
|
break;
|
|
case 0x2:
|
|
targetEvent = _smExceptionBptPauseReportEvent;
|
|
break;
|
|
case 0x3:
|
|
targetEvent = _errorNotifierEvent;
|
|
break;
|
|
}
|
|
|
|
if (targetEvent != null)
|
|
{
|
|
if (Owner.HandleTable.GenerateHandle(targetEvent.ReadableEvent, out eventHandle) != KernelResult.Success)
|
|
{
|
|
throw new InvalidOperationException("Out of handles!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
eventHandle = 0;
|
|
|
|
return NvInternalResult.InvalidInput;
|
|
}
|
|
|
|
return NvInternalResult.Success;
|
|
}
|
|
|
|
private NvInternalResult SubmitGpfifoEx(ref SubmitGpfifoArguments arguments, Span<long> inlineData)
|
|
{
|
|
return SubmitGpfifo(ref arguments, inlineData);
|
|
}
|
|
}
|
|
}
|