Rename all occurance of FileDevice to DeviceFile

This commit is contained in:
Thog 2019-10-29 02:30:46 +01:00
parent 16669d576d
commit 6ee9ee9ee7
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
11 changed files with 77 additions and 77 deletions

View file

@ -290,7 +290,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
int bufferOffset = _bufferQueue[slot].Data.Buffer.Surfaces[0].Offset;
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(context.Process, nvMapHandle);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(context.Process, nvMapHandle);
long fbAddr = map.Address + bufferOffset;
@ -312,7 +312,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
int right = crop.Right;
int bottom = crop.Bottom;
NvGpuVmm vmm = NvHostAsGpuFileDevice.GetAddressSpaceContext(context.Process).Vmm;
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(context.Process).Vmm;
_renderer.QueueAction(() =>
{

View file

@ -24,22 +24,22 @@ namespace Ryujinx.HLE.HOS.Services.Nv
[Service("nvdrv:t")]
class INvDrvServices : IpcService
{
private static Dictionary<string, Type> _fileDeviceRegistry =
private static Dictionary<string, Type> _deviceFileRegistry =
new Dictionary<string, Type>()
{
{ "/dev/nvmap", typeof(NvMapFileDevice) },
{ "/dev/nvhost-ctrl", typeof(NvHostCtrlFileDevice) },
{ "/dev/nvhost-ctrl-gpu", typeof(NvHostCtrlGpuFileDevice) },
{ "/dev/nvhost-as-gpu", typeof(NvHostAsGpuFileDevice) },
{ "/dev/nvhost-gpu", typeof(NvHostGpuFileDevice) },
//{ "/dev/nvhost-msenc", typeof(NvHostChannelFileDevice) },
{ "/dev/nvhost-nvdec", typeof(NvHostChannelFileDevice) },
//{ "/dev/nvhost-nvjpg", typeof(NvHostChannelFileDevice) },
{ "/dev/nvhost-vic", typeof(NvHostChannelFileDevice) },
//{ "/dev/nvhost-display", typeof(NvHostChannelFileDevice) },
{ "/dev/nvmap", typeof(NvMapDeviceFile) },
{ "/dev/nvhost-ctrl", typeof(NvHostCtrlDeviceFile) },
{ "/dev/nvhost-ctrl-gpu", typeof(NvHostCtrlGpuDeviceFile) },
{ "/dev/nvhost-as-gpu", typeof(NvHostAsGpuDeviceFile) },
{ "/dev/nvhost-gpu", typeof(NvHostGpuDeviceFile) },
//{ "/dev/nvhost-msenc", typeof(NvHostChannelDeviceFile) },
{ "/dev/nvhost-nvdec", typeof(NvHostChannelDeviceFile) },
//{ "/dev/nvhost-nvjpg", typeof(NvHostChannelDeviceFile) },
{ "/dev/nvhost-vic", typeof(NvHostChannelDeviceFile) },
//{ "/dev/nvhost-display", typeof(NvHostChannelDeviceFile) },
};
private static IdDictionary _fileDeviceIdRegistry = new IdDictionary();
private static IdDictionary _deviceFileIdRegistry = new IdDictionary();
private KProcess _owner;
public INvDrvServices(ServiceCtx context)
@ -51,13 +51,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{
if (context.Process == _owner)
{
if (_fileDeviceRegistry.TryGetValue(path, out Type fileDeviceClass))
if (_deviceFileRegistry.TryGetValue(path, out Type deviceFileClass))
{
ConstructorInfo constructor = fileDeviceClass.GetConstructor(new Type[] { typeof(ServiceCtx) });
ConstructorInfo constructor = deviceFileClass.GetConstructor(new Type[] { typeof(ServiceCtx) });
NvFileDevice fileDevice = (NvFileDevice)constructor.Invoke(new object[] { context });
NvDeviceFile deviceFile = (NvDeviceFile)constructor.Invoke(new object[] { context });
return _fileDeviceIdRegistry.Add(fileDevice);
return _deviceFileIdRegistry.Add(deviceFile);
}
else
{
@ -119,25 +119,25 @@ namespace Ryujinx.HLE.HOS.Services.Nv
return NvResult.Success;
}
private NvResult GetFileDeviceFromFd(int fd, out NvFileDevice fileDevice)
private NvResult GetDeviceFileFromFd(int fd, out NvDeviceFile deviceFile)
{
fileDevice = null;
deviceFile = null;
if (fd < 0)
{
return NvResult.InvalidParameter;
}
fileDevice = _fileDeviceIdRegistry.GetData<NvFileDevice>(fd);
deviceFile = _deviceFileIdRegistry.GetData<NvDeviceFile>(fd);
if (fileDevice == null)
if (deviceFile == null)
{
Logger.PrintWarning(LogClass.ServiceNv, $"Invalid file descriptor {fd}");
return NvResult.NotImplemented;
}
if (fileDevice.GetOwner().Pid != _owner.Pid)
if (deviceFile.GetOwner().Pid != _owner.Pid)
{
return NvResult.AccessDenied;
}
@ -248,15 +248,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
NvInternalResult internalResult = fileDevice.Ioctl(ioctlCommand, arguments);
NvInternalResult internalResult = deviceFile.Ioctl(ioctlCommand, arguments);
if (internalResult == NvInternalResult.NotImplemented)
{
throw new NvIoctlNotImplementedException(context, fileDevice, ioctlCommand);
throw new NvIoctlNotImplementedException(context, deviceFile, ioctlCommand);
}
errorCode = ConvertInternalErrorCode(internalResult);
@ -284,13 +284,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{
int fd = context.RequestData.ReadInt32();
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
fileDevice.Close();
deviceFile.Close();
_fileDeviceIdRegistry.Delete(fd);
_deviceFileIdRegistry.Delete(fd);
}
}
@ -324,15 +324,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
int fd = context.RequestData.ReadInt32();
uint eventId = context.RequestData.ReadUInt32();
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
NvInternalResult internalResult = fileDevice.QueryEvent(out int eventHandle, eventId);
NvInternalResult internalResult = deviceFile.QueryEvent(out int eventHandle, eventId);
if (internalResult == NvInternalResult.NotImplemented)
{
throw new NvQueryEventlNotImplementedException(context, fileDevice, eventId);
throw new NvQueryEventlNotImplementedException(context, deviceFile, eventId);
}
errorCode = ConvertInternalErrorCode(internalResult);
@ -361,13 +361,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
uint argument = context.RequestData.ReadUInt32();
int sharedMemoryHandle = context.Request.HandleDesc.ToCopy[0];
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
KSharedMemory sharedMemory = context.Process.HandleTable.GetObject<KSharedMemory>(sharedMemoryHandle);
errorCode = ConvertInternalErrorCode(fileDevice.MapSharedMemory(sharedMemory, argument));
errorCode = ConvertInternalErrorCode(deviceFile.MapSharedMemory(sharedMemory, argument));
}
}
@ -432,15 +432,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
NvInternalResult internalResult = fileDevice.Ioctl2(ioctlCommand, arguments, inlineInBuffer);
NvInternalResult internalResult = deviceFile.Ioctl2(ioctlCommand, arguments, inlineInBuffer);
if (internalResult == NvInternalResult.NotImplemented)
{
throw new NvIoctlNotImplementedException(context, fileDevice, ioctlCommand);
throw new NvIoctlNotImplementedException(context, deviceFile, ioctlCommand);
}
errorCode = ConvertInternalErrorCode(internalResult);
@ -477,15 +477,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
if (errorCode == NvResult.Success)
{
errorCode = GetFileDeviceFromFd(fd, out NvFileDevice fileDevice);
errorCode = GetDeviceFileFromFd(fd, out NvDeviceFile deviceFile);
if (errorCode == NvResult.Success)
{
NvInternalResult internalResult = fileDevice.Ioctl3(ioctlCommand, arguments, inlineOutBuffer);
NvInternalResult internalResult = deviceFile.Ioctl3(ioctlCommand, arguments, inlineOutBuffer);
if (internalResult == NvInternalResult.NotImplemented)
{
throw new NvIoctlNotImplementedException(context, fileDevice, ioctlCommand);
throw new NvIoctlNotImplementedException(context, deviceFile, ioctlCommand);
}
errorCode = ConvertInternalErrorCode(internalResult);

View file

@ -7,11 +7,11 @@ using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices
{
abstract class NvFileDevice
abstract class NvDeviceFile
{
protected KProcess _owner;
public NvFileDevice(ServiceCtx context)
public NvDeviceFile(ServiceCtx context)
{
_owner = context.Process;
}

View file

@ -8,14 +8,14 @@ using System.Collections.Concurrent;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
{
class NvHostAsGpuFileDevice : NvFileDevice
class NvHostAsGpuDeviceFile : NvDeviceFile
{
private const int FlagFixedOffset = 1;
private const int FlagRemapSubRange = 0x100;
private static ConcurrentDictionary<KProcess, AddressSpaceContext> _addressSpaceContextRegistry = new ConcurrentDictionary<KProcess, AddressSpaceContext>();
public NvHostAsGpuFileDevice(ServiceCtx context) : base(context)
public NvHostAsGpuDeviceFile(ServiceCtx context) : base(context)
{
}
@ -175,7 +175,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
AddressSpaceContext addressSpaceContext = GetAddressSpaceContext(_owner);
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(_owner, arguments.NvMapHandle, true);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, arguments.NvMapHandle, true);
if (map == null)
{
@ -290,7 +290,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
{
NvGpuVmm vmm = GetAddressSpaceContext(_owner).Vmm;
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(_owner, arguments[index].NvMapHandle, true);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, arguments[index].NvMapHandle, true);
if (map == null)
{

View file

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
{
class NvHostChannelFileDevice : NvFileDevice
class NvHostChannelDeviceFile : NvDeviceFile
{
private uint _timeout;
private uint _submitTimeout;
@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
private NvGpu _gpu;
private MemoryManager _memory;
public NvHostChannelFileDevice(ServiceCtx context) : base(context)
public NvHostChannelDeviceFile(ServiceCtx context) : base(context)
{
_gpu = context.Device.Gpu;
_memory = context.Memory;
@ -109,11 +109,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
int headerSize = Marshal.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 = NvHostAsGpuFileDevice.GetAddressSpaceContext(_owner).Vmm;
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
foreach (CommandBuffer commandBufferEntry in commandBufferEntries)
{
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(_owner, commandBufferEntry.MemoryId);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, commandBufferEntry.MemoryId);
int[] cmdBufData = new int[commandBufferEntry.WordsCount];
@ -160,11 +160,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
int headerSize = Marshal.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 = NvHostAsGpuFileDevice.GetAddressSpaceContext(_owner).Vmm;
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
{
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(_owner, commandBufferEntry.MapHandle);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, commandBufferEntry.MapHandle);
if (map == null)
{
@ -192,13 +192,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
int headerSize = Marshal.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 = NvHostAsGpuFileDevice.GetAddressSpaceContext(_owner).Vmm;
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
// TODO
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
{
NvMapHandle map = NvMapFileDevice.GetMapFromHandle(_owner, commandBufferEntry.MapHandle);
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(_owner, commandBufferEntry.MapHandle);
if (map == null)
{
@ -330,7 +330,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
protected NvInternalResult SubmitGpfifo(ref SubmitGpfifoArguments header, Span<long> entries)
{
NvGpuVmm vmm = NvHostAsGpuFileDevice.GetAddressSpaceContext(_owner).Vmm;
NvGpuVmm vmm = NvHostAsGpuDeviceFile.GetAddressSpaceContext(_owner).Vmm;
foreach (long entry in entries)
{

View file

@ -5,13 +5,13 @@ using System;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
{
internal class NvHostGpuFileDevice : NvHostChannelFileDevice
internal class NvHostGpuDeviceFile : NvHostChannelDeviceFile
{
private KEvent _smExceptionBptIntReportEvent;
private KEvent _smExceptionBptPauseReportEvent;
private KEvent _errorNotifierEvent;
public NvHostGpuFileDevice(ServiceCtx context) : base(context)
public NvHostGpuDeviceFile(ServiceCtx context) : base(context)
{
_smExceptionBptIntReportEvent = new KEvent(context.Device.System);
_smExceptionBptPauseReportEvent = new KEvent(context.Device.System);

View file

@ -11,7 +11,7 @@ using System.Threading;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
{
internal class NvHostCtrlFileDevice : NvFileDevice
internal class NvHostCtrlDeviceFile : NvDeviceFile
{
private const int EventsCount = 64;
@ -20,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl
private NvHostEvent[] _events;
private KEvent _dummyEvent;
public NvHostCtrlFileDevice(ServiceCtx context) : base(context)
public NvHostCtrlDeviceFile(ServiceCtx context) : base(context)
{
if (NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object productionModeSetting))
{

View file

@ -8,7 +8,7 @@ using System.Diagnostics;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
{
class NvHostCtrlGpuFileDevice : NvFileDevice
class NvHostCtrlGpuDeviceFile : NvDeviceFile
{
private static Stopwatch _pTimer = new Stopwatch();
private static double _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000;
@ -16,13 +16,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu
private KEvent _errorEvent;
private KEvent _unknownEvent;
public NvHostCtrlGpuFileDevice(ServiceCtx context) : base(context)
public NvHostCtrlGpuDeviceFile(ServiceCtx context) : base(context)
{
_errorEvent = new KEvent(context.Device.System);
_unknownEvent = new KEvent(context.Device.System);
}
static NvHostCtrlGpuFileDevice()
static NvHostCtrlGpuDeviceFile()
{
_pTimer.Start();
}

View file

@ -7,13 +7,13 @@ using System.Collections.Concurrent;
namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
{
internal class NvMapFileDevice : NvFileDevice
internal class NvMapDeviceFile : NvDeviceFile
{
private const int FlagNotFreedYet = 1;
private static ConcurrentDictionary<KProcess, IdDictionary> _maps = new ConcurrentDictionary<KProcess, IdDictionary>();
public NvMapFileDevice(ServiceCtx context) : base(context)
public NvMapDeviceFile(ServiceCtx context) : base(context)
{
IdDictionary dict = _maps.GetOrAdd(_owner, (key) => new IdDictionary());
@ -230,7 +230,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
public override void Close()
{
// TODO: refcount NvMapFileDevice instances and remove when closing
// TODO: refcount NvMapDeviceFile instances and remove when closing
// _maps.TryRemove(GetOwner(), out _);
}

View file

@ -7,18 +7,18 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
class NvIoctlNotImplementedException : Exception
{
public ServiceCtx Context { get; }
public NvFileDevice FileDevice { get; }
public NvDeviceFile DeviceFile { get; }
public NvIoctl Command { get; }
public NvIoctlNotImplementedException(ServiceCtx context, NvFileDevice fileDevice, NvIoctl command)
: this(context, fileDevice, command, "The ioctl is not implemented.")
public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command)
: this(context, deviceFile, command, "The ioctl is not implemented.")
{ }
public NvIoctlNotImplementedException(ServiceCtx context, NvFileDevice fileDevice, NvIoctl command, string message)
public NvIoctlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, NvIoctl command, string message)
: base(message)
{
Context = context;
FileDevice = fileDevice;
DeviceFile = deviceFile;
Command = command;
}
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Device File: {FileDevice.GetType().Name}");
sb.AppendLine($"Device File: {DeviceFile.GetType().Name}");
sb.AppendLine();
sb.AppendLine($"Ioctl (0x{Command.RawValue:x8})");

View file

@ -7,18 +7,18 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
class NvQueryEventlNotImplementedException : Exception
{
public ServiceCtx Context { get; }
public NvFileDevice FileDevice { get; }
public NvDeviceFile DeviceFile { get; }
public uint EventId { get; }
public NvQueryEventlNotImplementedException(ServiceCtx context, NvFileDevice fileDevice, uint eventId)
: this(context, fileDevice, eventId, "The ioctl is not implemented.")
public NvQueryEventlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId)
: this(context, deviceFile, eventId, "This query event is not implemented.")
{ }
public NvQueryEventlNotImplementedException(ServiceCtx context, NvFileDevice fileDevice, uint eventId, string message)
public NvQueryEventlNotImplementedException(ServiceCtx context, NvDeviceFile deviceFile, uint eventId, string message)
: base(message)
{
Context = context;
FileDevice = fileDevice;
DeviceFile = deviceFile;
EventId = eventId;
}
@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.Types
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Device File: {FileDevice.GetType().Name}");
sb.AppendLine($"Device File: {DeviceFile.GetType().Name}");
sb.AppendLine();
sb.AppendLine($"Event ID: (0x{EventId:x8})");