Address comments
This commit is contained in:
parent
5eccdda295
commit
760a7ec60a
14 changed files with 77 additions and 87 deletions
|
@ -32,14 +32,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
{ "/dev/nvhost-ctrl-gpu", typeof(NvHostCtrlGpuDeviceFile) },
|
||||
{ "/dev/nvhost-as-gpu", typeof(NvHostAsGpuDeviceFile) },
|
||||
{ "/dev/nvhost-gpu", typeof(NvHostGpuDeviceFile) },
|
||||
//{ "/dev/nvhost-msenc", typeof(NvHostChannelDeviceFile) },
|
||||
//{ "/dev/nvhost-msenc", typeof(NvHostChannelDeviceFile) },
|
||||
{ "/dev/nvhost-nvdec", typeof(NvHostChannelDeviceFile) },
|
||||
//{ "/dev/nvhost-nvjpg", typeof(NvHostChannelDeviceFile) },
|
||||
//{ "/dev/nvhost-nvjpg", typeof(NvHostChannelDeviceFile) },
|
||||
{ "/dev/nvhost-vic", typeof(NvHostChannelDeviceFile) },
|
||||
//{ "/dev/nvhost-display", typeof(NvHostChannelDeviceFile) },
|
||||
//{ "/dev/nvhost-display", typeof(NvHostChannelDeviceFile) },
|
||||
};
|
||||
|
||||
private static IdDictionary _deviceFileIdRegistry = new IdDictionary();
|
||||
|
||||
private KProcess _owner;
|
||||
|
||||
public INvDrvServices(ServiceCtx context)
|
||||
|
@ -76,7 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
NvIoctl.Direction ioctlDirection = ioctlCommand.DirectionValue;
|
||||
uint ioctlSize = ioctlCommand.Size;
|
||||
|
||||
bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0;
|
||||
bool isRead = (ioctlDirection & NvIoctl.Direction.Read) != 0;
|
||||
bool isWrite = (ioctlDirection & NvIoctl.Direction.Write) != 0;
|
||||
|
||||
if ((isWrite && ioctlSize > outputDataSize) || (isRead && ioctlSize > inputDataSize))
|
||||
|
@ -332,7 +333,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
|
||||
if (internalResult == NvInternalResult.NotImplemented)
|
||||
{
|
||||
throw new NvQueryEventlNotImplementedException(context, deviceFile, eventId);
|
||||
throw new NvQueryEventNotImplementedException(context, deviceFile, eventId);
|
||||
}
|
||||
|
||||
errorCode = ConvertInternalErrorCode(internalResult);
|
||||
|
|
|
@ -10,15 +10,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
class NvHostAsGpuDeviceFile : NvDeviceFile
|
||||
{
|
||||
private const int FlagFixedOffset = 1;
|
||||
private const int FlagRemapSubRange = 0x100;
|
||||
|
||||
private static ConcurrentDictionary<KProcess, AddressSpaceContext> _addressSpaceContextRegistry = new ConcurrentDictionary<KProcess, AddressSpaceContext>();
|
||||
|
||||
public NvHostAsGpuDeviceFile(ServiceCtx context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
public NvHostAsGpuDeviceFile(ServiceCtx context) : base(context) { }
|
||||
|
||||
public override NvInternalResult Ioctl(NvIoctl command, Span<byte> arguments)
|
||||
{
|
||||
|
@ -95,7 +89,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
// Note: When the fixed offset flag is not set,
|
||||
// the Offset field holds the alignment size instead.
|
||||
if ((arguments.Flags & FlagFixedOffset) != 0)
|
||||
if ((arguments.Flags & AddressSpaceFlags.FixedOffset) != 0)
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.ReserveFixed(arguments.Offset, (long)size);
|
||||
}
|
||||
|
@ -184,23 +178,23 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
||||
long pa;
|
||||
long physicalAddress;
|
||||
|
||||
if ((arguments.Flags & FlagRemapSubRange) != 0)
|
||||
if ((arguments.Flags & AddressSpaceFlags.RemapSubRange) != 0)
|
||||
{
|
||||
lock (addressSpaceContext)
|
||||
{
|
||||
if (addressSpaceContext.TryGetMapPhysicalAddress(arguments.Offset, out pa))
|
||||
if (addressSpaceContext.TryGetMapPhysicalAddress(arguments.Offset, out physicalAddress))
|
||||
{
|
||||
long va = arguments.Offset + arguments.BufferOffset;
|
||||
long virtualAddress = arguments.Offset + arguments.BufferOffset;
|
||||
|
||||
pa += arguments.BufferOffset;
|
||||
physicalAddress += arguments.BufferOffset;
|
||||
|
||||
if (addressSpaceContext.Vmm.Map(pa, va, arguments.MappingSize) < 0)
|
||||
if (addressSpaceContext.Vmm.Map(physicalAddress, virtualAddress, arguments.MappingSize) < 0)
|
||||
{
|
||||
string msg = string.Format(mapErrorMsg, va, arguments.MappingSize);
|
||||
string message = string.Format(mapErrorMsg, virtualAddress, arguments.MappingSize);
|
||||
|
||||
Logger.PrintWarning(LogClass.ServiceNv, msg);
|
||||
Logger.PrintWarning(LogClass.ServiceNv, message);
|
||||
|
||||
return NvInternalResult.InvalidInput;
|
||||
}
|
||||
|
@ -216,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
}
|
||||
}
|
||||
|
||||
pa = map.Address + arguments.BufferOffset;
|
||||
physicalAddress = map.Address + arguments.BufferOffset;
|
||||
|
||||
long size = arguments.MappingSize;
|
||||
|
||||
|
@ -231,26 +225,26 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
{
|
||||
// Note: When the fixed offset flag is not set,
|
||||
// the Offset field holds the alignment size instead.
|
||||
bool vaAllocated = (arguments.Flags & FlagFixedOffset) == 0;
|
||||
bool virtualAddressAllocated = (arguments.Flags & AddressSpaceFlags.FixedOffset) == 0;
|
||||
|
||||
if (!vaAllocated)
|
||||
if (!virtualAddressAllocated)
|
||||
{
|
||||
if (addressSpaceContext.ValidateFixedBuffer(arguments.Offset, size))
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(pa, arguments.Offset, size);
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(physicalAddress, arguments.Offset, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = string.Format(mapErrorMsg, arguments.Offset, size);
|
||||
string message = string.Format(mapErrorMsg, arguments.Offset, size);
|
||||
|
||||
Logger.PrintWarning(LogClass.ServiceNv, msg);
|
||||
Logger.PrintWarning(LogClass.ServiceNv, message);
|
||||
|
||||
result = NvInternalResult.InvalidInput;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(pa, size);
|
||||
arguments.Offset = addressSpaceContext.Vmm.Map(physicalAddress, size);
|
||||
}
|
||||
|
||||
if (arguments.Offset < 0)
|
||||
|
@ -263,7 +257,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
}
|
||||
else
|
||||
{
|
||||
addressSpaceContext.AddMap(arguments.Offset, size, pa, vaAllocated);
|
||||
addressSpaceContext.AddMap(arguments.Offset, size, physicalAddress, virtualAddressAllocated);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,10 +308,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Close() { }
|
||||
|
||||
public static AddressSpaceContext GetAddressSpaceContext(KProcess process)
|
||||
{
|
||||
|
|
|
@ -14,12 +14,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
private class Range
|
||||
{
|
||||
public ulong Start { get; private set; }
|
||||
public ulong End { get; private set; }
|
||||
public ulong End { get; private set; }
|
||||
|
||||
public Range(long position, long size)
|
||||
{
|
||||
Start = (ulong)position;
|
||||
End = (ulong)size + Start;
|
||||
End = (ulong)size + Start;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
bool vaAllocated) : base(position, size)
|
||||
{
|
||||
PhysicalAddress = physicalAddress;
|
||||
VaAllocated = vaAllocated;
|
||||
VaAllocated = vaAllocated;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
{
|
||||
Vmm = new NvGpuVmm(process.CpuMemory);
|
||||
|
||||
_maps = new SortedList<long, Range>();
|
||||
_maps = new SortedList<long, Range>();
|
||||
_reservations = new SortedList<long, Range>();
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
|
||||
private Range BinarySearch(SortedList<long, Range> lst, long position)
|
||||
{
|
||||
int left = 0;
|
||||
int left = 0;
|
||||
int right = lst.Count - 1;
|
||||
|
||||
while (left <= right)
|
||||
|
@ -172,7 +172,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
{
|
||||
Range ltRg = null;
|
||||
|
||||
int left = 0;
|
||||
int left = 0;
|
||||
int right = lst.Count - 1;
|
||||
|
||||
while (left <= right)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
||||
{
|
||||
[Flags]
|
||||
enum AddressSpaceFlags : uint
|
||||
{
|
||||
FixedOffset = 1,
|
||||
RemapSubRange = 0x100,
|
||||
}
|
||||
}
|
|
@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct AllocSpaceArguments
|
||||
{
|
||||
public uint Pages;
|
||||
public uint PageSize;
|
||||
public uint Flags;
|
||||
public uint Padding;
|
||||
public long Offset;
|
||||
public uint Pages;
|
||||
public uint PageSize;
|
||||
public AddressSpaceFlags Flags;
|
||||
public uint Padding;
|
||||
public long Offset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct MapBufferExArguments
|
||||
{
|
||||
public int Flags;
|
||||
public int Kind;
|
||||
public int NvMapHandle;
|
||||
public int PageSize;
|
||||
public long BufferOffset;
|
||||
public long MappingSize;
|
||||
public long Offset;
|
||||
public AddressSpaceFlags Flags;
|
||||
public int Kind;
|
||||
public int NvMapHandle;
|
||||
public int PageSize;
|
||||
public long BufferOffset;
|
||||
public long MappingSize;
|
||||
public long Offset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
public NvHostChannelDeviceFile(ServiceCtx context) : base(context)
|
||||
{
|
||||
_gpu = context.Device.Gpu;
|
||||
_memory = context.Memory;
|
||||
_timeout = 3000;
|
||||
_submitTimeout = 0;
|
||||
_timeslice = 0;
|
||||
_gpu = context.Device.Gpu;
|
||||
_memory = context.Memory;
|
||||
_timeout = 3000;
|
||||
_submitTimeout = 0;
|
||||
_timeslice = 0;
|
||||
}
|
||||
|
||||
public override NvInternalResult Ioctl(NvIoctl command, Span<byte> arguments)
|
||||
|
@ -116,14 +116,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
{
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, commandBufferEntry.MemoryId);
|
||||
|
||||
int[] cmdBufData = new int[commandBufferEntry.WordsCount];
|
||||
int[] commandBufferData = new int[commandBufferEntry.WordsCount];
|
||||
|
||||
for (int offset = 0; offset < cmdBufData.Length; offset++)
|
||||
for (int offset = 0; offset < commandBufferData.Length; offset++)
|
||||
{
|
||||
cmdBufData[offset] = _memory.ReadInt32(map.Address + commandBufferEntry.Offset + offset * 4);
|
||||
commandBufferData[offset] = _memory.ReadInt32(map.Address + commandBufferEntry.Offset + offset * 4);
|
||||
}
|
||||
|
||||
_gpu.PushCommandBuffer(vmm, cmdBufData);
|
||||
_gpu.PushCommandBuffer(vmm, commandBufferData);
|
||||
}
|
||||
|
||||
return NvInternalResult.Success;
|
||||
|
@ -195,8 +195,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
Span<CommandBufferHandle> commandBufferEntries = MemoryMarshal.Cast<byte, CommandBufferHandle>(arguments.Slice(headerSize)).Slice(0, commandBufferHeader.NumEntries);
|
||||
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
|
||||
|
||||
// TODO
|
||||
|
||||
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
||||
{
|
||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, commandBufferEntry.MapHandle);
|
||||
|
@ -240,9 +238,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
|
||||
private NvInternalResult SubmitGpfifo(Span<byte> arguments)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
return SubmitGpfifo(ref gpfifoSubmissionHeader, gpfifoEntries);
|
||||
}
|
||||
|
@ -344,9 +342,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Close() { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel.Types
|
|||
{
|
||||
public int NumEntries;
|
||||
public int DataAddress; // Ignored by the driver.
|
||||
public bool AttachHostChDas;
|
||||
public bool AttachHostChDas;
|
||||
public byte Padding1;
|
||||
public short Padding2;
|
||||
}
|
||||
|
|
|
@ -78,8 +78,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
|||
case 0x1f:
|
||||
result = CallIoctlMethod<uint>(EventRegister, arguments);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,9 +396,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
|
|||
return null;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Close() { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl.Types
|
|||
|
||||
public static GetConfigurationArguments FromSpan(Span<byte> span)
|
||||
{
|
||||
string domain = Encoding.ASCII.GetString(span.Slice(0, 0x41));
|
||||
string parameter = Encoding.ASCII.GetString(span.Slice(0x41, 0x41));
|
||||
string domain = Encoding.ASCII.GetString(span.Slice(0, 0x41));
|
||||
string parameter = Encoding.ASCII.GetString(span.Slice(0x41, 0x41));
|
||||
|
||||
GetConfigurationArguments result = new GetConfigurationArguments
|
||||
{
|
||||
|
|
|
@ -114,10 +114,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
|
|||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Close() { }
|
||||
|
||||
private NvInternalResult ZcullGetCtxSize(ref ZcullGetCtxSizeArguments arguments)
|
||||
{
|
||||
|
@ -212,7 +209,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
|
|||
arguments.TpcMask = tpcMask;
|
||||
}
|
||||
|
||||
|
||||
return NvInternalResult.Success;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct ZbcSetTableArguments
|
||||
{
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@ using System.Text;
|
|||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.Types
|
||||
{
|
||||
class NvQueryEventlNotImplementedException : Exception
|
||||
class NvQueryEventNotImplementedException : Exception
|
||||
{
|
||||
public ServiceCtx Context { get; }
|
||||
public NvDeviceFile DeviceFile { get; }
|
||||
public uint EventId { get; }
|
||||
|
||||
public NvQueryEventlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId)
|
||||
public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId)
|
||||
: this(context, deviceFile, eventId, "This query event is not implemented.")
|
||||
{ }
|
||||
|
||||
public NvQueryEventlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId, string message)
|
||||
public NvQueryEventNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId, string message)
|
||||
: base(message)
|
||||
{
|
||||
Context = context;
|
||||
|
|
Loading…
Add table
Reference in a new issue