Address comments
This commit is contained in:
parent
5eccdda295
commit
760a7ec60a
14 changed files with 77 additions and 87 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu.Types
|
||||
{
|
||||
[Flags]
|
||||
enum AddressSpaceFlags : uint
|
||||
{
|
||||
FixedOffset = 1,
|
||||
RemapSubRange = 0x100,
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
Add a link
Reference in a new issue