Address comments
This commit is contained in:
parent
7215966b9a
commit
c7f19acf3f
12 changed files with 51 additions and 66 deletions
|
@ -73,8 +73,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
(long inputDataPosition, long inputDataSize) = context.Request.GetBufferType0x21(0);
|
||||
(long outputDataPosition, long outputDataSize) = context.Request.GetBufferType0x22(0);
|
||||
|
||||
NvIoctl.Direction ioctlDirection = ioctlCommand.GetDirectionValue();
|
||||
uint ioctlSize = ioctlCommand.GetSizeValue();
|
||||
NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue;
|
||||
uint ioctlSize = ioctlCommand.Size;
|
||||
|
||||
bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0;
|
||||
bool isWrite = (ioctlDirection & NvIoctl.Direction.Write) != 0;
|
||||
|
@ -261,7 +261,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
errorCode = ConvertInternalErrorCode(internalResult);
|
||||
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.GetDirectionValue() & NvIoctl.Direction.Write) == NvIoctl.Direction.Write)
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
errorCode = ConvertInternalErrorCode(internalResult);
|
||||
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.GetDirectionValue() & NvIoctl.Direction.Write) != 0)
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
errorCode = ConvertInternalErrorCode(internalResult);
|
||||
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.GetDirectionValue() & NvIoctl.Direction.Write) != 0)
|
||||
if (errorCode == NvResult.Success && (ioctlCommand.DirectionValue & NvIoctl.Direction.Write) != 0)
|
||||
{
|
||||
context.Memory.WriteBytes(context.Request.GetBufferType0x22(0).Position, arguments.ToArray());
|
||||
context.Memory.WriteBytes(inlineOutBufferPosition, inlineOutBuffer.ToArray());
|
||||
|
|
|
@ -50,8 +50,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
|
|||
|
||||
protected delegate NvInternalResult IoctlProcessor<T>(ref T arguments);
|
||||
protected delegate NvInternalResult IoctlProcessorSpan<T>(Span<T> arguments);
|
||||
protected delegate NvInternalResult IoctlProcessorInline<T, Y>(ref T arguments, ref Y inlineData);
|
||||
protected delegate NvInternalResult IoctlProcessorInlineSpan<T, Y>(ref T arguments, Span<Y> inlineData);
|
||||
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
|
||||
{
|
||||
|
@ -60,12 +60,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
|
|||
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0]);
|
||||
}
|
||||
|
||||
protected static NvInternalResult CallIoctlMethod<T, Y>(IoctlProcessorInline<T, Y> callback, Span<byte> arguments, Span<byte> inlineBuffer) where T : struct where Y : struct
|
||||
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<Y>());
|
||||
Debug.Assert(inlineBuffer.Length == Unsafe.SizeOf<T1>());
|
||||
|
||||
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0], ref MemoryMarshal.Cast<byte, Y>(inlineBuffer)[0]);
|
||||
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
|
||||
|
@ -73,11 +73,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
|
|||
return callback(MemoryMarshal.Cast<byte, T>(arguments));
|
||||
}
|
||||
|
||||
protected static NvInternalResult CallIoctlMethod<T, Y>(IoctlProcessorInlineSpan<T, Y> callback, Span<byte> arguments, Span<byte> inlineBuffer) where T : struct where Y : struct
|
||||
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, Y>(inlineBuffer));
|
||||
return callback(ref MemoryMarshal.Cast<byte, T>(arguments)[0], MemoryMarshal.Cast<byte, T1>(inlineBuffer));
|
||||
}
|
||||
|
||||
public abstract void Close();
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvGpuAsMagic)
|
||||
if (command.Type == NvIoctl.NvGpuAsMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x01:
|
||||
result = CallIoctlMethod<BindChannelArguments>(BindChannel, arguments);
|
||||
|
@ -62,9 +62,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvGpuAsMagic)
|
||||
if (command.Type == NvIoctl.NvGpuAsMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x08:
|
||||
// This is the same as the one in ioctl as inlineOutBuffer is empty.
|
||||
|
|
|
@ -6,6 +6,7 @@ using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu;
|
|||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
||||
|
@ -31,9 +32,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvHostCustomMagic)
|
||||
if (command.Type == NvIoctl.NvHostCustomMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x01:
|
||||
result = Submit(arguments);
|
||||
|
@ -55,9 +56,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (command.GetTypeValue() == NvIoctl.NvHostMagic)
|
||||
else if (command.Type == NvIoctl.NvHostMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x01:
|
||||
result = CallIoctlMethod<int>(SetNvMapFd, arguments);
|
||||
|
@ -91,9 +92,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (command.GetTypeValue() == NvIoctl.NvGpuMagic)
|
||||
else if (command.Type == NvIoctl.NvGpuMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x14:
|
||||
result = CallIoctlMethod<ulong>(SetUserData, arguments);
|
||||
|
@ -106,7 +107,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private NvInternalResult Submit(Span<byte> arguments)
|
||||
{
|
||||
int headerSize = Marshal.SizeOf<SubmitArguments>();
|
||||
int headerSize = Unsafe.SizeOf<SubmitArguments>();
|
||||
SubmitArguments submitHeader = MemoryMarshal.Cast<byte, SubmitArguments>(arguments)[0];
|
||||
Span<CommandBuffer> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBuffer>(arguments.Slice(headerSize)).Slice(0, submitHeader.CmdBufsCount);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
|
||||
|
@ -157,7 +158,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private NvInternalResult MapCommandBuffer(Span<byte> arguments)
|
||||
{
|
||||
int headerSize = Marshal.SizeOf<MapCommandBufferArguments>();
|
||||
int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>();
|
||||
MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0];
|
||||
Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
|
||||
|
@ -189,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private NvInternalResult UnmapCommandBuffer(Span<byte> arguments)
|
||||
{
|
||||
int headerSize = Marshal.SizeOf<MapCommandBufferArguments>();
|
||||
int headerSize = Unsafe.SizeOf<MapCommandBufferArguments>();
|
||||
MapCommandBufferArguments commandBufferHeader = MemoryMarshal.Cast<byte, MapCommandBufferArguments>(arguments)[0];
|
||||
Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
|
||||
|
@ -239,7 +240,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private NvInternalResult SubmitGpfifo(Span<byte> arguments)
|
||||
{
|
||||
int headerSize = Marshal.SizeOf<SubmitGpfifoArguments>();
|
||||
int headerSize = Unsafe.SizeOf<SubmitGpfifoArguments>();
|
||||
SubmitGpfifoArguments gpfifoSubmissionHeader = MemoryMarshal.Cast<byte, SubmitGpfifoArguments>(arguments)[0];
|
||||
Span<long> gpfifoEntries = MemoryMarshal.Cast<byte, long>(arguments.Slice(headerSize)).Slice(0, gpfifoSubmissionHeader.NumEntries);
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvHostMagic)
|
||||
if (command.Type == NvIoctl.NvHostMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x1b:
|
||||
result = CallIoctlMethod<SubmitGpfifoArguments, long>(SubmitGpfifoEx, arguments, inlineInBuffer);
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types
|
|||
{
|
||||
public int NumEntries;
|
||||
public int DataAddress; // Ignored by the driver.
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool AttachHostChDas;
|
||||
public byte Padding1;
|
||||
public short Padding2;
|
||||
|
|
|
@ -40,9 +40,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvHostCustomMagic)
|
||||
if (command.Type == NvIoctl.NvHostCustomMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x14:
|
||||
result = CallIoctlMethod<NvFence>(SyncptRead, arguments);
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvGpuMagic)
|
||||
if (command.Type == NvIoctl.NvGpuMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x01:
|
||||
result = CallIoctlMethod<ZcullGetCtxSizeArguments>(ZcullGetCtxSize, arguments);
|
||||
|
@ -66,9 +66,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvGpuMagic)
|
||||
if (command.Type == NvIoctl.NvGpuMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x05:
|
||||
result = CallIoctlMethod<GetCharacteristicsArguments, GpuCharacteristics>(GetCharacteristics, arguments, inlineOutBuffer);
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||
{
|
||||
NvInternalResult result = NvInternalResult.NotImplemented;
|
||||
|
||||
if (command.GetTypeValue() == NvIoctl.NvMapCustomMagic)
|
||||
if (command.Type == NvIoctl.NvMapCustomMagic)
|
||||
{
|
||||
switch (command.GetNumberValue())
|
||||
switch (command.Number)
|
||||
{
|
||||
case 0x01:
|
||||
result = CallIoctlMethod<NvMapCreate>(Create, arguments);
|
||||
|
|
|
@ -37,24 +37,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
public uint RawValue;
|
||||
|
||||
public uint GetNumberValue()
|
||||
{
|
||||
return (RawValue >> NumberShift) & NumberMask;
|
||||
}
|
||||
|
||||
public uint GetTypeValue()
|
||||
{
|
||||
return (RawValue >> TypeShift) & TypeMask;
|
||||
}
|
||||
|
||||
public uint GetSizeValue()
|
||||
{
|
||||
return (RawValue >> SizeShift) & SizeMask;
|
||||
}
|
||||
|
||||
public Direction GetDirectionValue()
|
||||
{
|
||||
return (Direction)((RawValue >> DirectionShift) & DirectionMask);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
|
|||
get
|
||||
{
|
||||
return base.Message +
|
||||
Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
BuildMessage();
|
||||
Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
BuildMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
|
|||
sb.AppendLine();
|
||||
|
||||
sb.AppendLine($"Ioctl (0x{Command.RawValue:x8})");
|
||||
sb.AppendLine($"\tNumber: 0x{Command.GetNumberValue():x8}");
|
||||
sb.AppendLine($"\tType: 0x{Command.GetTypeValue():x8}");
|
||||
sb.AppendLine($"\tSize: 0x{Command.GetSizeValue():x8}");
|
||||
sb.AppendLine($"\tDirection: {Command.GetDirectionValue()}");
|
||||
sb.AppendLine($"\tNumber: 0x{Command.Number:x8}");
|
||||
sb.AppendLine($"\tType: 0x{Command.Type:x8}");
|
||||
sb.AppendLine($"\tSize: 0x{Command.Size:x8}");
|
||||
sb.AppendLine($"\tDirection: {Command.DirectionValue}");
|
||||
|
||||
sb.AppendLine("Guest Stack Trace:");
|
||||
sb.AppendLine(Context.Thread.GetGuestStackTrace());
|
||||
|
|
|
@ -27,9 +27,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
|
|||
get
|
||||
{
|
||||
return base.Message +
|
||||
Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
BuildMessage();
|
||||
Environment.NewLine +
|
||||
Environment.NewLine +
|
||||
BuildMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue