Address comments

This commit is contained in:
Thog 2019-10-30 01:53:03 +01:00
commit 760a7ec60a
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
14 changed files with 77 additions and 87 deletions

View file

@ -40,6 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
};
private static IdDictionary _deviceFileIdRegistry = new IdDictionary();
private KProcess _owner;
public INvDrvServices(ServiceCtx context)
@ -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);

View file

@ -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)
{

View file

@ -0,0 +1,11 @@
using System;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
{
[Flags]
enum AddressSpaceFlags : uint
{
FixedOffset = 1,
RemapSubRange = 0x100,
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
{
public uint Pages;
public uint PageSize;
public uint Flags;
public AddressSpaceFlags Flags;
public uint Padding;
public long Offset;
}

View file

@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
[StructLayout(LayoutKind.Sequential)]
struct MapBufferExArguments
{
public int Flags;
public AddressSpaceFlags Flags;
public int Kind;
public int NvMapHandle;
public int PageSize;

View file

@ -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);
@ -344,9 +342,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
return NvInternalResult.Success;
}
public override void Close()
{
}
public override void Close() { }
}
}

View file

@ -31,6 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
break;
}
}
return result;
}

View file

@ -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() { }
}
}

View file

@ -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;
}

View file

@ -5,6 +5,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types
[StructLayout(LayoutKind.Sequential)]
struct ZbcSetTableArguments
{
// TODO
}
}

View file

@ -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;