2019-11-02 23:47:56 +01:00
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
|
|
|
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types;
|
2020-12-02 00:23:43 +01:00
|
|
|
|
using Ryujinx.Memory;
|
2019-11-02 23:47:56 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|
|
|
|
{
|
|
|
|
|
internal class NvHostGpuDeviceFile : NvHostChannelDeviceFile
|
|
|
|
|
{
|
|
|
|
|
private KEvent _smExceptionBptIntReportEvent;
|
|
|
|
|
private KEvent _smExceptionBptPauseReportEvent;
|
|
|
|
|
private KEvent _errorNotifierEvent;
|
|
|
|
|
|
2020-12-02 00:23:43 +01:00
|
|
|
|
public NvHostGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, long owner) : base(context, memory, owner)
|
2019-11-02 23:47:56 +01:00
|
|
|
|
{
|
2020-05-04 05:41:29 +02:00
|
|
|
|
_smExceptionBptIntReportEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
|
_smExceptionBptPauseReportEvent = new KEvent(context.Device.System.KernelContext);
|
|
|
|
|
_errorNotifierEvent = new KEvent(context.Device.System.KernelContext);
|
2019-11-02 23:47:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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:
|
2019-10-13 08:02:07 +02:00
|
|
|
|
result = CallIoctlMethod<SubmitGpfifoArguments, ulong>(SubmitGpfifoEx, arguments, inlineInBuffer);
|
2019-11-02 23:47:56 +01:00
|
|
|
|
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)
|
|
|
|
|
{
|
2020-12-02 00:23:43 +01:00
|
|
|
|
if (Context.Process.HandleTable.GenerateHandle(targetEvent.ReadableEvent, out eventHandle) != KernelResult.Success)
|
2019-11-02 23:47:56 +01:00
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Out of handles!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
eventHandle = 0;
|
|
|
|
|
|
|
|
|
|
return NvInternalResult.InvalidInput;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NvInternalResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-13 08:02:07 +02:00
|
|
|
|
private NvInternalResult SubmitGpfifoEx(ref SubmitGpfifoArguments arguments, Span<ulong> inlineData)
|
2019-11-02 23:47:56 +01:00
|
|
|
|
{
|
|
|
|
|
return SubmitGpfifo(ref arguments, inlineData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|