aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Nv
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Nv')
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs138
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvFd.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs146
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs244
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs200
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs243
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs282
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs4
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs76
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs12
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs230
11 files changed, 788 insertions, 793 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index 1b034bfa..a8459cf4 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
@@ -14,15 +14,15 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{
class INvDrvServices : IpcService
{
- private delegate int IoctlProcessor(ServiceCtx Context, int Cmd);
+ private delegate int IoctlProcessor(ServiceCtx context, int cmd);
- private Dictionary<int, ServiceProcessRequest> m_Commands;
+ private Dictionary<int, ServiceProcessRequest> _commands;
- public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
- private static Dictionary<string, IoctlProcessor> IoctlProcessors =
- new Dictionary<string, IoctlProcessor>()
- {
+ private static Dictionary<string, IoctlProcessor> _ioctlProcessors =
+ new Dictionary<string, IoctlProcessor>
+ {
{ "/dev/nvhost-as-gpu", ProcessIoctlNvGpuAS },
{ "/dev/nvhost-ctrl", ProcessIoctlNvHostCtrl },
{ "/dev/nvhost-ctrl-gpu", ProcessIoctlNvGpuGpu },
@@ -32,13 +32,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{ "/dev/nvmap", ProcessIoctlNvMap }
};
- public static GlobalStateTable Fds { get; private set; }
+ public static GlobalStateTable Fds { get; }
- private KEvent Event;
+ private KEvent _event;
- public INvDrvServices(Horizon System)
+ public INvDrvServices(Horizon system)
{
- m_Commands = new Dictionary<int, ServiceProcessRequest>()
+ _commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, Open },
{ 1, Ioctl },
@@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{ 13, FinishInitialize }
};
- Event = new KEvent(System);
+ _event = new KEvent(system);
}
static INvDrvServices()
@@ -58,166 +58,166 @@ namespace Ryujinx.HLE.HOS.Services.Nv
Fds = new GlobalStateTable();
}
- public long Open(ServiceCtx Context)
+ public long Open(ServiceCtx context)
{
- long NamePtr = Context.Request.SendBuff[0].Position;
+ long namePtr = context.Request.SendBuff[0].Position;
- string Name = MemoryHelper.ReadAsciiString(Context.Memory, NamePtr);
+ string name = MemoryHelper.ReadAsciiString(context.Memory, namePtr);
- int Fd = Fds.Add(Context.Process, new NvFd(Name));
+ int fd = Fds.Add(context.Process, new NvFd(name));
- Context.ResponseData.Write(Fd);
- Context.ResponseData.Write(0);
+ context.ResponseData.Write(fd);
+ context.ResponseData.Write(0);
return 0;
}
- public long Ioctl(ServiceCtx Context)
+ public long Ioctl(ServiceCtx context)
{
- int Fd = Context.RequestData.ReadInt32();
- int Cmd = Context.RequestData.ReadInt32();
+ int fd = context.RequestData.ReadInt32();
+ int cmd = context.RequestData.ReadInt32();
- NvFd FdData = Fds.GetData<NvFd>(Context.Process, Fd);
+ NvFd fdData = Fds.GetData<NvFd>(context.Process, fd);
- int Result;
+ int result;
- if (IoctlProcessors.TryGetValue(FdData.Name, out IoctlProcessor Process))
+ if (_ioctlProcessors.TryGetValue(fdData.Name, out IoctlProcessor process))
{
- Result = Process(Context, Cmd);
+ result = process(context, cmd);
}
else
{
- throw new NotImplementedException($"{FdData.Name} {Cmd:x4}");
+ throw new NotImplementedException($"{fdData.Name} {cmd:x4}");
}
//TODO: Verify if the error codes needs to be translated.
- Context.ResponseData.Write(Result);
+ context.ResponseData.Write(result);
return 0;
}
- public long Close(ServiceCtx Context)
+ public long Close(ServiceCtx context)
{
- int Fd = Context.RequestData.ReadInt32();
+ int fd = context.RequestData.ReadInt32();
- Fds.Delete(Context.Process, Fd);
+ Fds.Delete(context.Process, fd);
- Context.ResponseData.Write(0);
+ context.ResponseData.Write(0);
return 0;
}
- public long Initialize(ServiceCtx Context)
+ public long Initialize(ServiceCtx context)
{
- long TransferMemSize = Context.RequestData.ReadInt64();
- int TransferMemHandle = Context.Request.HandleDesc.ToCopy[0];
+ long transferMemSize = context.RequestData.ReadInt64();
+ int transferMemHandle = context.Request.HandleDesc.ToCopy[0];
- NvMapIoctl.InitializeNvMap(Context);
+ NvMapIoctl.InitializeNvMap(context);
- Context.ResponseData.Write(0);
+ context.ResponseData.Write(0);
return 0;
}
- public long QueryEvent(ServiceCtx Context)
+ public long QueryEvent(ServiceCtx context)
{
- int Fd = Context.RequestData.ReadInt32();
- int EventId = Context.RequestData.ReadInt32();
+ int fd = context.RequestData.ReadInt32();
+ int eventId = context.RequestData.ReadInt32();
//TODO: Use Fd/EventId, different channels have different events.
- if (Context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int Handle) != KernelResult.Success)
+ if (context.Process.HandleTable.GenerateHandle(_event.ReadableEvent, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
- Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
+ context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
- Context.ResponseData.Write(0);
+ context.ResponseData.Write(0);
return 0;
}
- public long SetClientPid(ServiceCtx Context)
+ public long SetClientPid(ServiceCtx context)
{
- long Pid = Context.RequestData.ReadInt64();
+ long pid = context.RequestData.ReadInt64();
- Context.ResponseData.Write(0);
+ context.ResponseData.Write(0);
return 0;
}
- public long FinishInitialize(ServiceCtx Context)
+ public long FinishInitialize(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return 0;
}
- private static int ProcessIoctlNvGpuAS(ServiceCtx Context, int Cmd)
+ private static int ProcessIoctlNvGpuAS(ServiceCtx context, int cmd)
{
- return ProcessIoctl(Context, Cmd, NvGpuASIoctl.ProcessIoctl);
+ return ProcessIoctl(context, cmd, NvGpuASIoctl.ProcessIoctl);
}
- private static int ProcessIoctlNvHostCtrl(ServiceCtx Context, int Cmd)
+ private static int ProcessIoctlNvHostCtrl(ServiceCtx context, int cmd)
{
- return ProcessIoctl(Context, Cmd, NvHostCtrlIoctl.ProcessIoctl);
+ return ProcessIoctl(context, cmd, NvHostCtrlIoctl.ProcessIoctl);
}
- private static int ProcessIoctlNvGpuGpu(ServiceCtx Context, int Cmd)
+ private static int ProcessIoctlNvGpuGpu(ServiceCtx context, int cmd)
{
- return ProcessIoctl(Context, Cmd, NvGpuGpuIoctl.ProcessIoctl);
+ return ProcessIoctl(context, cmd, NvGpuGpuIoctl.ProcessIoctl);
}
- private static int ProcessIoctlNvHostChannel(ServiceCtx Context, int Cmd)
+ private static int ProcessIoctlNvHostChannel(ServiceCtx context, int cmd)
{
- return ProcessIoctl(Context, Cmd, NvHostChannelIoctl.ProcessIoctl);
+ return ProcessIoctl(context, cmd, NvHostChannelIoctl.ProcessIoctl);
}
- private static int ProcessIoctlNvMap(ServiceCtx Context, int Cmd)
+ private static int ProcessIoctlNvMap(ServiceCtx context, int cmd)
{
- return ProcessIoctl(Context, Cmd, NvMapIoctl.ProcessIoctl);
+ return ProcessIoctl(context, cmd, NvMapIoctl.ProcessIoctl);
}
- private static int ProcessIoctl(ServiceCtx Context, int Cmd, IoctlProcessor Processor)
+ private static int ProcessIoctl(ServiceCtx context, int cmd, IoctlProcessor processor)
{
- if (CmdIn(Cmd) && Context.Request.GetBufferType0x21().Position == 0)
+ if (CmdIn(cmd) && context.Request.GetBufferType0x21().Position == 0)
{
Logger.PrintError(LogClass.ServiceNv, "Input buffer is null!");
return NvResult.InvalidInput;
}
- if (CmdOut(Cmd) && Context.Request.GetBufferType0x22().Position == 0)
+ if (CmdOut(cmd) && context.Request.GetBufferType0x22().Position == 0)
{
Logger.PrintError(LogClass.ServiceNv, "Output buffer is null!");
return NvResult.InvalidInput;
}
- return Processor(Context, Cmd);
+ return processor(context, cmd);
}
- private static bool CmdIn(int Cmd)
+ private static bool CmdIn(int cmd)
{
- return ((Cmd >> 30) & 1) != 0;
+ return ((cmd >> 30) & 1) != 0;
}
- private static bool CmdOut(int Cmd)
+ private static bool CmdOut(int cmd)
{
- return ((Cmd >> 31) & 1) != 0;
+ return ((cmd >> 31) & 1) != 0;
}
- public static void UnloadProcess(KProcess Process)
+ public static void UnloadProcess(KProcess process)
{
- Fds.DeleteProcess(Process);
+ Fds.DeleteProcess(process);
- NvGpuASIoctl.UnloadProcess(Process);
+ NvGpuASIoctl.UnloadProcess(process);
- NvHostChannelIoctl.UnloadProcess(Process);
+ NvHostChannelIoctl.UnloadProcess(process);
- NvHostCtrlIoctl.UnloadProcess(Process);
+ NvHostCtrlIoctl.UnloadProcess(process);
- NvMapIoctl.UnloadProcess(Process);
+ NvMapIoctl.UnloadProcess(process);
}
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs b/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs
index 96f97f41..0f7e4acd 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvFd.cs
@@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv
{
class NvFd
{
- public string Name { get; private set; }
+ public string Name { get; }
- public NvFd(string Name)
+ public NvFd(string name)
{
- this.Name = Name;
+ Name = name;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs
index 70275b2a..cd1ab7cd 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASCtx.cs
@@ -5,73 +5,73 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
{
class NvGpuASCtx
{
- public NvGpuVmm Vmm { get; private set; }
+ public NvGpuVmm Vmm { get; }
private class Range
{
- public ulong Start { get; private set; }
- public ulong End { get; private set; }
+ public ulong Start { get; }
+ public ulong End { get; }
- public Range(long Position, long Size)
+ public Range(long position, long size)
{
- Start = (ulong)Position;
- End = (ulong)Size + Start;
+ Start = (ulong)position;
+ End = (ulong)size + Start;
}
}
private class MappedMemory : Range
{
- public long PhysicalAddress { get; private set; }
- public bool VaAllocated { get; private set; }
+ public long PhysicalAddress { get; }
+ public bool VaAllocated { get; }
public MappedMemory(
- long Position,
- long Size,
- long PhysicalAddress,
- bool VaAllocated) : base(Position, Size)
+ long position,
+ long size,
+ long physicalAddress,
+ bool vaAllocated) : base(position, size)
{
- this.PhysicalAddress = PhysicalAddress;
- this.VaAllocated = VaAllocated;
+ PhysicalAddress = physicalAddress;
+ VaAllocated = vaAllocated;
}
}
- private SortedList<long, Range> Maps;
- private SortedList<long, Range> Reservations;
+ private SortedList<long, Range> _maps;
+ private SortedList<long, Range> _reservations;
- public NvGpuASCtx(ServiceCtx Context)
+ public NvGpuASCtx(ServiceCtx context)
{
- Vmm = new NvGpuVmm(Context.Memory);
+ Vmm = new NvGpuVmm(context.Memory);
- Maps = new SortedList<long, Range>();
- Reservations = new SortedList<long, Range>();
+ _maps = new SortedList<long, Range>();
+ _reservations = new SortedList<long, Range>();
}
- public bool ValidateFixedBuffer(long Position, long Size)
+ public bool ValidateFixedBuffer(long position, long size)
{
- long MapEnd = Position + Size;
+ long mapEnd = position + size;
//Check if size is valid (0 is also not allowed).
- if ((ulong)MapEnd <= (ulong)Position)
+ if ((ulong)mapEnd <= (ulong)position)
{
return false;
}
//Check if address is page aligned.
- if ((Position & NvGpuVmm.PageMask) != 0)
+ if ((position & NvGpuVmm.PageMask) != 0)
{
return false;
}
//Check if region is reserved.
- if (BinarySearch(Reservations, Position) == null)
+ if (BinarySearch(_reservations, position) == null)
{
return false;
}
//Check for overlap with already mapped buffers.
- Range Map = BinarySearchLt(Maps, MapEnd);
+ Range map = BinarySearchLt(_maps, mapEnd);
- if (Map != null && Map.End > (ulong)Position)
+ if (map != null && map.End > (ulong)position)
{
return false;
}
@@ -80,25 +80,25 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
}
public void AddMap(
- long Position,
- long Size,
- long PhysicalAddress,
- bool VaAllocated)
+ long position,
+ long size,
+ long physicalAddress,
+ bool vaAllocated)
{
- Maps.Add(Position, new MappedMemory(Position, Size, PhysicalAddress, VaAllocated));
+ _maps.Add(position, new MappedMemory(position, size, physicalAddress, vaAllocated));
}
- public bool RemoveMap(long Position, out long Size)
+ public bool RemoveMap(long position, out long size)
{
- Size = 0;
+ size = 0;
- if (Maps.Remove(Position, out Range Value))
+ if (_maps.Remove(position, out Range value))
{
- MappedMemory Map = (MappedMemory)Value;
+ MappedMemory map = (MappedMemory)value;
- if (Map.VaAllocated)
+ if (map.VaAllocated)
{
- Size = (long)(Map.End - Map.Start);
+ size = (long)(map.End - map.Start);
}
return true;
@@ -107,94 +107,94 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
return false;
}
- public bool TryGetMapPhysicalAddress(long Position, out long PhysicalAddress)
+ public bool TryGetMapPhysicalAddress(long position, out long physicalAddress)
{
- Range Map = BinarySearch(Maps, Position);
+ Range map = BinarySearch(_maps, position);
- if (Map != null)
+ if (map != null)
{
- PhysicalAddress = ((MappedMemory)Map).PhysicalAddress;
+ physicalAddress = ((MappedMemory)map).PhysicalAddress;
return true;
}
- PhysicalAddress = 0;
+ physicalAddress = 0;
return false;
}
- public void AddReservation(long Position, long Size)
+ public void AddReservation(long position, long size)
{
- Reservations.Add(Position, new Range(Position, Size));
+ _reservations.Add(position, new Range(position, size));
}
- public bool RemoveReservation(long Position)
+ public bool RemoveReservation(long position)
{
- return Reservations.Remove(Position);
+ return _reservations.Remove(position);
}
- private Range BinarySearch(SortedList<long, Range> Lst, long Position)
+ private Range BinarySearch(SortedList<long, Range> lst, long position)
{
- int Left = 0;
- int Right = Lst.Count - 1;
+ int left = 0;
+ int right = lst.Count - 1;
- while (Left <= Right)
+ while (left <= right)
{
- int Size = Right - Left;
+ int size = right - left;
- int Middle = Left + (Size >> 1);
+ int middle = left + (size >> 1);
- Range Rg = Lst.Values[Middle];
+ Range rg = lst.Values[middle];
- if ((ulong)Position >= Rg.Start && (ulong)Position < Rg.End)
+ if ((ulong)position >= rg.Start && (ulong)position < rg.End)
{
- return Rg;
+ return rg;
}
- if ((ulong)Position < Rg.Start)
+ if ((ulong)position < rg.Start)
{
- Right = Middle - 1;
+ right = middle - 1;
}
else
{
- Left = Middle + 1;
+ left = middle + 1;
}
}
return null;
}
- private Range BinarySearchLt(SortedList<long, Range> Lst, long Position)
+ private Range BinarySearchLt(SortedList<long, Range> lst, long position)
{
- Range LtRg = null;
+ Range ltRg = null;
- int Left = 0;
- int Right = Lst.Count - 1;
+ int left = 0;
+ int right = lst.Count - 1;
- while (Left <= Right)
+ while (left <= right)
{
- int Size = Right - Left;
+ int size = right - left;
- int Middle = Left + (Size >> 1);
+ int middle = left + (size >> 1);
- Range Rg = Lst.Values[Middle];
+ Range rg = lst.Values[middle];
- if ((ulong)Position < Rg.Start)
+ if ((ulong)position < rg.Start)
{
- Right = Middle - 1;
+ right = middle - 1;
}
else
{
- Left = Middle + 1;
+ left = middle + 1;
- if ((ulong)Position > Rg.Start)
+ if ((ulong)position > rg.Start)
{
- LtRg = Rg;
+ ltRg = rg;
}
}
}
- return LtRg;
+ return ltRg;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
index 7fe3bbed..8e128a0d 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
@@ -14,182 +14,182 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
private const int FlagRemapSubRange = 0x100;
- private static ConcurrentDictionary<KProcess, NvGpuASCtx> ASCtxs;
+ private static ConcurrentDictionary<KProcess, NvGpuASCtx> _asCtxs;
static NvGpuASIoctl()
{
- ASCtxs = new ConcurrentDictionary<KProcess, NvGpuASCtx>();
+ _asCtxs = new ConcurrentDictionary<KProcess, NvGpuASCtx>();
}
- public static int ProcessIoctl(ServiceCtx Context, int Cmd)
+ public static int ProcessIoctl(ServiceCtx context, int cmd)
{
- switch (Cmd & 0xffff)
+ switch (cmd & 0xffff)
{
- case 0x4101: return BindChannel (Context);
- case 0x4102: return AllocSpace (Context);
- case 0x4103: return FreeSpace (Context);
- case 0x4105: return UnmapBuffer (Context);
- case 0x4106: return MapBufferEx (Context);
- case 0x4108: return GetVaRegions(Context);
- case 0x4109: return InitializeEx(Context);
- case 0x4114: return Remap (Context, Cmd);
+ case 0x4101: return BindChannel (context);
+ case 0x4102: return AllocSpace (context);
+ case 0x4103: return FreeSpace (context);
+ case 0x4105: return UnmapBuffer (context);
+ case 0x4106: return MapBufferEx (context);
+ case 0x4108: return GetVaRegions(context);
+ case 0x4109: return InitializeEx(context);
+ case 0x4114: return Remap (context, cmd);
}
- throw new NotImplementedException(Cmd.ToString("x8"));
+ throw new NotImplementedException(cmd.ToString("x8"));
}
- private static int BindChannel(ServiceCtx Context)
+ private static int BindChannel(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int AllocSpace(ServiceCtx Context)
+ private static int AllocSpace(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuASAllocSpace Args = MemoryHelper.Read<NvGpuASAllocSpace>(Context.Memory, InputPosition);
+ NvGpuASAllocSpace args = MemoryHelper.Read<NvGpuASAllocSpace>(context.Memory, inputPosition);
- NvGpuASCtx ASCtx = GetASCtx(Context);
+ NvGpuASCtx asCtx = GetASCtx(context);
- ulong Size = (ulong)Args.Pages *
- (ulong)Args.PageSize;
+ ulong size = (ulong)args.Pages *
+ (ulong)args.PageSize;
- int Result = NvResult.Success;
+ int result = NvResult.Success;
- lock (ASCtx)
+ lock (asCtx)
{
//Note: When the fixed offset flag is not set,
//the Offset field holds the alignment size instead.
- if ((Args.Flags & FlagFixedOffset) != 0)
+ if ((args.Flags & FlagFixedOffset) != 0)
{
- Args.Offset = ASCtx.Vmm.ReserveFixed(Args.Offset, (long)Size);
+ args.Offset = asCtx.Vmm.ReserveFixed(args.Offset, (long)size);
}
else
{
- Args.Offset = ASCtx.Vmm.Reserve((long)Size, Args.Offset);
+ args.Offset = asCtx.Vmm.Reserve((long)size, args.Offset);
}
- if (Args.Offset < 0)
+ if (args.Offset < 0)
{
- Args.Offset = 0;
+ args.Offset = 0;
- Logger.PrintWarning(LogClass.ServiceNv, $"Failed to allocate size {Size:x16}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Failed to allocate size {size:x16}!");
- Result = NvResult.OutOfMemory;
+ result = NvResult.OutOfMemory;
}
else
{
- ASCtx.AddReservation(Args.Offset, (long)Size);
+ asCtx.AddReservation(args.Offset, (long)size);
}
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
- return Result;
+ return result;
}
- private static int FreeSpace(ServiceCtx Context)
+ private static int FreeSpace(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuASAllocSpace Args = MemoryHelper.Read<NvGpuASAllocSpace>(Context.Memory, InputPosition);
+ NvGpuASAllocSpace args = MemoryHelper.Read<NvGpuASAllocSpace>(context.Memory, inputPosition);
- NvGpuASCtx ASCtx = GetASCtx(Context);
+ NvGpuASCtx asCtx = GetASCtx(context);
- int Result = NvResult.Success;
+ int result = NvResult.Success;
- lock (ASCtx)
+ lock (asCtx)
{
- ulong Size = (ulong)Args.Pages *
- (ulong)Args.PageSize;
+ ulong size = (ulong)args.Pages *
+ (ulong)args.PageSize;
- if (ASCtx.RemoveReservation(Args.Offset))
+ if (asCtx.RemoveReservation(args.Offset))
{
- ASCtx.Vmm.Free(Args.Offset, (long)Size);
+ asCtx.Vmm.Free(args.Offset, (long)size);
}
else
{
Logger.PrintWarning(LogClass.ServiceNv,
- $"Failed to free offset 0x{Args.Offset:x16} size 0x{Size:x16}!");
+ $"Failed to free offset 0x{args.Offset:x16} size 0x{size:x16}!");
- Result = NvResult.InvalidInput;
+ result = NvResult.InvalidInput;
}
}
- return Result;
+ return result;
}
- private static int UnmapBuffer(ServiceCtx Context)
+ private static int UnmapBuffer(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuASUnmapBuffer Args = MemoryHelper.Read<NvGpuASUnmapBuffer>(Context.Memory, InputPosition);
+ NvGpuASUnmapBuffer args = MemoryHelper.Read<NvGpuASUnmapBuffer>(context.Memory, inputPosition);
- NvGpuASCtx ASCtx = GetASCtx(Context);
+ NvGpuASCtx asCtx = GetASCtx(context);
- lock (ASCtx)
+ lock (asCtx)
{
- if (ASCtx.RemoveMap(Args.Offset, out long Size))
+ if (asCtx.RemoveMap(args.Offset, out long size))
{
- if (Size != 0)
+ if (size != 0)
{
- ASCtx.Vmm.Free(Args.Offset, Size);
+ asCtx.Vmm.Free(args.Offset, size);
}
}
else
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid buffer offset {Args.Offset:x16}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid buffer offset {args.Offset:x16}!");
}
}
return NvResult.Success;
}
- private static int MapBufferEx(ServiceCtx Context)
+ private static int MapBufferEx(ServiceCtx context)
{
- const string MapErrorMsg = "Failed to map fixed buffer with offset 0x{0:x16} and size 0x{1:x16}!";
+ const string mapErrorMsg = "Failed to map fixed buffer with offset 0x{0:x16} and size 0x{1:x16}!";
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuASMapBufferEx Args = MemoryHelper.Read<NvGpuASMapBufferEx>(Context.Memory, InputPosition);
+ NvGpuASMapBufferEx args = MemoryHelper.Read<NvGpuASMapBufferEx>(context.Memory, inputPosition);
- NvGpuASCtx ASCtx = GetASCtx(Context);
+ NvGpuASCtx asCtx = GetASCtx(context);
- NvMapHandle Map = NvMapIoctl.GetNvMapWithFb(Context, Args.NvMapHandle);
+ NvMapHandle map = NvMapIoctl.GetNvMapWithFb(context, args.NvMapHandle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{Args.NvMapHandle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{args.NvMapHandle:x8}!");
return NvResult.InvalidInput;
}
- long PA;
+ long pa;
- if ((Args.Flags & FlagRemapSubRange) != 0)
+ if ((args.Flags & FlagRemapSubRange) != 0)
{
- lock (ASCtx)
+ lock (asCtx)
{
- if (ASCtx.TryGetMapPhysicalAddress(Args.Offset, out PA))
+ if (asCtx.TryGetMapPhysicalAddress(args.Offset, out pa))
{
- long VA = Args.Offset + Args.BufferOffset;
+ long va = args.Offset + args.BufferOffset;
- PA += Args.BufferOffset;
+ pa += args.BufferOffset;
- if (ASCtx.Vmm.Map(PA, VA, Args.MappingSize) < 0)
+ if (asCtx.Vmm.Map(pa, va, args.MappingSize) < 0)
{
- string Msg = string.Format(MapErrorMsg, VA, Args.MappingSize);
+ string msg = string.Format(mapErrorMsg, va, args.MappingSize);
- Logger.PrintWarning(LogClass.ServiceNv, Msg);
+ Logger.PrintWarning(LogClass.ServiceNv, msg);
return NvResult.InvalidInput;
}
@@ -198,117 +198,117 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
}
else
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Address 0x{Args.Offset:x16} not mapped!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Address 0x{args.Offset:x16} not mapped!");
return NvResult.InvalidInput;
}
}
}
- PA = Map.Address + Args.BufferOffset;
+ pa = map.Address + args.BufferOffset;
- long Size = Args.MappingSize;
+ long size = args.MappingSize;
- if (Size == 0)
+ if (size == 0)
{
- Size = (uint)Map.Size;
+ size = (uint)map.Size;
}
- int Result = NvResult.Success;
+ int result = NvResult.Success;
- lock (ASCtx)
+ lock (asCtx)
{
//Note: When the fixed offset flag is not set,
//the Offset field holds the alignment size instead.
- bool VaAllocated = (Args.Flags & FlagFixedOffset) == 0;
+ bool vaAllocated = (args.Flags & FlagFixedOffset) == 0;
- if (!VaAllocated)
+ if (!vaAllocated)
{
- if (ASCtx.ValidateFixedBuffer(Args.Offset, Size))
+ if (asCtx.ValidateFixedBuffer(args.Offset, size))
{
- Args.Offset = ASCtx.Vmm.Map(PA, Args.Offset, Size);
+ args.Offset = asCtx.Vmm.Map(pa, args.Offset, size);
}
else
{
- string Msg = string.Format(MapErrorMsg, Args.Offset, Size);
+ string msg = string.Format(mapErrorMsg, args.Offset, size);
- Logger.PrintWarning(LogClass.ServiceNv, Msg);
+ Logger.PrintWarning(LogClass.ServiceNv, msg);
- Result = NvResult.InvalidInput;
+ result = NvResult.InvalidInput;
}
}
else
{
- Args.Offset = ASCtx.Vmm.Map(PA, Size);
+ args.Offset = asCtx.Vmm.Map(pa, size);
}
- if (Args.Offset < 0)
+ if (args.Offset < 0)
{
- Args.Offset = 0;
+ args.Offset = 0;
- Logger.PrintWarning(LogClass.ServiceNv, $"Failed to map size 0x{Size:x16}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Failed to map size 0x{size:x16}!");
- Result = NvResult.InvalidInput;
+ result = NvResult.InvalidInput;
}
else
{
- ASCtx.AddMap(Args.Offset, Size, PA, VaAllocated);
+ asCtx.AddMap(args.Offset, size, pa, vaAllocated);
}
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
- return Result;
+ return result;
}
- private static int GetVaRegions(ServiceCtx Context)
+ private static int GetVaRegions(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int InitializeEx(ServiceCtx Context)
+ private static int InitializeEx(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int Remap(ServiceCtx Context, int Cmd)
+ private static int Remap(ServiceCtx context, int cmd)
{
- int Count = ((Cmd >> 16) & 0xff) / 0x14;
+ int count = ((cmd >> 16) & 0xff) / 0x14;
- long InputPosition = Context.Request.GetBufferType0x21().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
- for (int Index = 0; Index < Count; Index++, InputPosition += 0x14)
+ for (int index = 0; index < count; index++, inputPosition += 0x14)
{
- NvGpuASRemap Args = MemoryHelper.Read<NvGpuASRemap>(Context.Memory, InputPosition);
+ NvGpuASRemap args = MemoryHelper.Read<NvGpuASRemap>(context.Memory, inputPosition);
- NvGpuVmm Vmm = GetASCtx(Context).Vmm;
+ NvGpuVmm vmm = GetASCtx(context).Vmm;
- NvMapHandle Map = NvMapIoctl.GetNvMapWithFb(Context, Args.NvMapHandle);
+ NvMapHandle map = NvMapIoctl.GetNvMapWithFb(context, args.NvMapHandle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{Args.NvMapHandle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid NvMap handle 0x{args.NvMapHandle:x8}!");
return NvResult.InvalidInput;
}
- long Result = Vmm.Map(Map.Address, (long)(uint)Args.Offset << 16,
- (long)(uint)Args.Pages << 16);
+ long result = vmm.Map(map.Address, (long)(uint)args.Offset << 16,
+ (long)(uint)args.Pages << 16);
- if (Result < 0)
+ if (result < 0)
{
Logger.PrintWarning(LogClass.ServiceNv,
- $"Page 0x{Args.Offset:x16} size 0x{Args.Pages:x16} not allocated!");
+ $"Page 0x{args.Offset:x16} size 0x{args.Pages:x16} not allocated!");
return NvResult.InvalidInput;
}
@@ -317,14 +317,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
return NvResult.Success;
}
- public static NvGpuASCtx GetASCtx(ServiceCtx Context)
+ public static NvGpuASCtx GetASCtx(ServiceCtx context)
{
- return ASCtxs.GetOrAdd(Context.Process, (Key) => new NvGpuASCtx(Context));
+ return _asCtxs.GetOrAdd(context.Process, (key) => new NvGpuASCtx(context));
}
- public static void UnloadProcess(KProcess Process)
+ public static void UnloadProcess(KProcess process)
{
- ASCtxs.TryRemove(Process, out _);
+ _asCtxs.TryRemove(process, out _);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
index 7ee770f4..5680fb8e 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuGpu/NvGpuGpuIoctl.cs
@@ -7,181 +7,181 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuGpu
{
class NvGpuGpuIoctl
{
- private static Stopwatch PTimer;
+ private static Stopwatch _pTimer;
- private static double TicksToNs;
+ private static double _ticksToNs;
static NvGpuGpuIoctl()
{
- PTimer = new Stopwatch();
+ _pTimer = new Stopwatch();
- PTimer.Start();
+ _pTimer.Start();
- TicksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000;
+ _ticksToNs = (1.0 / Stopwatch.Frequency) * 1_000_000_000;
}
- public static int ProcessIoctl(ServiceCtx Context, int Cmd)
+ public static int ProcessIoctl(ServiceCtx context, int cmd)
{
- switch (Cmd & 0xffff)
+ switch (cmd & 0xffff)
{
- case 0x4701: return ZcullGetCtxSize (Context);
- case 0x4702: return ZcullGetInfo (Context);
- case 0x4703: return ZbcSetTable (Context);
- case 0x4705: return GetCharacteristics(Context);
- case 0x4706: return GetTpcMasks (Context);
- case 0x4714: return GetActiveSlotMask (Context);
- case 0x471c: return GetGpuTime (Context);
+ case 0x4701: return ZcullGetCtxSize (context);
+ case 0x4702: return ZcullGetInfo (context);
+ case 0x4703: return ZbcSetTable (context);
+ case 0x4705: return GetCharacteristics(context);
+ case 0x4706: return GetTpcMasks (context);
+ case 0x4714: return GetActiveSlotMask (context);
+ case 0x471c: return GetGpuTime (context);
}
- throw new NotImplementedException(Cmd.ToString("x8"));
+ throw new NotImplementedException(cmd.ToString("x8"));
}
- private static int ZcullGetCtxSize(ServiceCtx Context)
+ private static int ZcullGetCtxSize(ServiceCtx context)
{
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuGpuZcullGetCtxSize Args = new NvGpuGpuZcullGetCtxSize();
+ NvGpuGpuZcullGetCtxSize args = new NvGpuGpuZcullGetCtxSize();
- Args.Size = 1;
+ args.Size = 1;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int ZcullGetInfo(ServiceCtx Context)
+ private static int ZcullGetInfo(ServiceCtx context)
{
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuGpuZcullGetInfo Args = new NvGpuGpuZcullGetInfo();
+ NvGpuGpuZcullGetInfo args = new NvGpuGpuZcullGetInfo();
- Args.WidthAlignPixels = 0x20;
- Args.HeightAlignPixels = 0x20;
- Args.PixelSquaresByAliquots = 0x400;
- Args.AliquotTotal = 0x800;
- Args.RegionByteMultiplier = 0x20;
- Args.RegionHeaderSize = 0x20;
- Args.SubregionHeaderSize = 0xc0;
- Args.SubregionWidthAlignPixels = 0x20;
- Args.SubregionHeightAlignPixels = 0x40;
- Args.SubregionCount = 0x10;
+ args.WidthAlignPixels = 0x20;
+ args.HeightAlignPixels = 0x20;
+ args.PixelSquaresByAliquots = 0x400;
+ args.AliquotTotal = 0x800;
+ args.RegionByteMultiplier = 0x20;
+ args.RegionHeaderSize = 0x20;
+ args.SubregionHeaderSize = 0xc0;
+ args.SubregionWidthAlignPixels = 0x20;
+ args.SubregionHeightAlignPixels = 0x40;
+ args.SubregionCount = 0x10;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int ZbcSetTable(ServiceCtx Context)
+ private static int ZbcSetTable(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int GetCharacteristics(ServiceCtx Context)
+ private static int GetCharacteristics(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
-
- NvGpuGpuGetCharacteristics Args = MemoryHelper.Read<NvGpuGpuGetCharacteristics>(Context.Memory, InputPosition);
-
- Args.BufferSize = 0xa0;
-
- Args.Arch = 0x120;
- Args.Impl = 0xb;
- Args.Rev = 0xa1;
- Args.NumGpc = 0x1;
- Args.L2CacheSize = 0x40000;
- Args.OnBoardVideoMemorySize = 0x0;
- Args.NumTpcPerGpc = 0x2;
- Args.BusType = 0x20;
- Args.BigPageSize = 0x20000;
- Args.CompressionPageSize = 0x20000;
- Args.PdeCoverageBitCount = 0x1b;
- Args.AvailableBigPageSizes = 0x30000;
- Args.GpcMask = 0x1;
- Args.SmArchSmVersion = 0x503;
- Args.SmArchSpaVersion = 0x503;
- Args.SmArchWarpCount = 0x80;
- Args.GpuVaBitCount = 0x28;
- Args.Reserved = 0x0;
- Args.Flags = 0x55;
- Args.TwodClass = 0x902d;
- Args.ThreedClass = 0xb197;
- Args.ComputeClass = 0xb1c0;
- Args.GpfifoClass = 0xb06f;
- Args.InlineToMemoryClass = 0xa140;
- Args.DmaCopyClass = 0xb0b5;
- Args.MaxFbpsCount = 0x1;
- Args.FbpEnMask = 0x0;
- Args.MaxLtcPerFbp = 0x2;
- Args.MaxLtsPerLtc = 0x1;
- Args.MaxTexPerTpc = 0x0;
- Args.MaxGpcCount = 0x1;
- Args.RopL2EnMask0 = 0x21d70;
- Args.RopL2EnMask1 = 0x0;
- Args.ChipName = 0x6230326d67;
- Args.GrCompbitStoreBaseHw = 0x0;
-
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
+
+ NvGpuGpuGetCharacteristics args = MemoryHelper.Read<NvGpuGpuGetCharacteristics>(context.Memory, inputPosition);
+
+ args.BufferSize = 0xa0;
+
+ args.Arch = 0x120;
+ args.Impl = 0xb;
+ args.Rev = 0xa1;
+ args.NumGpc = 0x1;
+ args.L2CacheSize = 0x40000;
+ args.OnBoardVideoMemorySize = 0x0;
+ args.NumTpcPerGpc = 0x2;
+ args.BusType = 0x20;
+ args.BigPageSize = 0x20000;
+ args.CompressionPageSize = 0x20000;
+ args.PdeCoverageBitCount = 0x1b;
+ args.AvailableBigPageSizes = 0x30000;
+ args.GpcMask = 0x1;
+ args.SmArchSmVersion = 0x503;
+ args.SmArchSpaVersion = 0x503;
+ args.SmArchWarpCount = 0x80;
+ args.GpuVaBitCount = 0x28;
+ args.Reserved = 0x0;
+ args.Flags = 0x55;
+ args.TwodClass = 0x902d;
+ args.ThreedClass = 0xb197;
+ args.ComputeClass = 0xb1c0;
+ args.GpfifoClass = 0xb06f;
+ args.InlineToMemoryClass = 0xa140;
+ args.DmaCopyClass = 0xb0b5;
+ args.MaxFbpsCount = 0x1;
+ args.FbpEnMask = 0x0;
+ args.MaxLtcPerFbp = 0x2;
+ args.MaxLtsPerLtc = 0x1;
+ args.MaxTexPerTpc = 0x0;
+ args.MaxGpcCount = 0x1;
+ args.RopL2EnMask0 = 0x21d70;
+ args.RopL2EnMask1 = 0x0;
+ args.ChipName = 0x6230326d67;
+ args.GrCompbitStoreBaseHw = 0x0;
+
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int GetTpcMasks(ServiceCtx Context)
+ private static int GetTpcMasks(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuGpuGetTpcMasks Args = MemoryHelper.Read<NvGpuGpuGetTpcMasks>(Context.Memory, InputPosition);
+ NvGpuGpuGetTpcMasks args = MemoryHelper.Read<NvGpuGpuGetTpcMasks>(context.Memory, inputPosition);
- if (Args.MaskBufferSize != 0)
+ if (args.MaskBufferSize != 0)
{
- Args.TpcMask = 3;
+ args.TpcMask = 3;
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int GetActiveSlotMask(ServiceCtx Context)
+ private static int GetActiveSlotMask(ServiceCtx context)
{
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvGpuGpuGetActiveSlotMask Args = new NvGpuGpuGetActiveSlotMask();
+ NvGpuGpuGetActiveSlotMask args = new NvGpuGpuGetActiveSlotMask();
- Args.Slot = 0x07;
- Args.Mask = 0x01;
+ args.Slot = 0x07;
+ args.Mask = 0x01;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int GetGpuTime(ServiceCtx Context)
+ private static int GetGpuTime(ServiceCtx context)
{
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- Context.Memory.WriteInt64(OutputPosition, GetPTimerNanoSeconds());
+ context.Memory.WriteInt64(outputPosition, GetPTimerNanoSeconds());
return NvResult.Success;
}
private static long GetPTimerNanoSeconds()
{
- double Ticks = PTimer.ElapsedTicks;
+ double ticks = _pTimer.ElapsedTicks;
- return (long)(Ticks * TicksToNs) & 0xff_ffff_ffff_ffff;
+ return (long)(ticks * _ticksToNs) & 0xff_ffff_ffff_ffff;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
index 466f3e9b..140e8c96 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
@@ -11,62 +11,57 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
{
class NvHostChannelIoctl
{
- private static ConcurrentDictionary<KProcess, NvChannel> Channels;
+ private static ConcurrentDictionary<KProcess, NvChannel> _channels;
static NvHostChannelIoctl()
{
- Channels = new ConcurrentDictionary<KProcess, NvChannel>();
+ _channels = new ConcurrentDictionary<KProcess, NvChannel>();
}
- public static int ProcessIoctl(ServiceCtx Context, int Cmd)
+ public static int ProcessIoctl(ServiceCtx context, int cmd)
{
- switch (Cmd & 0xffff)
+ switch (cmd & 0xffff)
{
- case 0x0001: return Submit (Context);
- case 0x0002: return GetSyncpoint (Context);
- case 0x0003: return GetWaitBase (Context);
- case 0x0009: return MapBuffer (Context);
- case 0x000a: return UnmapBuffer (Context);
- case 0x4714: return SetUserData (Context);
- case 0x4801: return SetNvMap (Context);
- case 0x4803: return SetTimeout (Context);
- case 0x4808: return SubmitGpfifo (Context);
- case 0x4809: return AllocObjCtx (Context);
- case 0x480b: return ZcullBind (Context);
- case 0x480c: return SetErrorNotifier (Context);
- case 0x480d: return SetPriority (Context);
- case 0x481a: return AllocGpfifoEx2 (Context);
- case 0x481b: return KickoffPbWithAttr(Context);
+ case 0x0001: return Submit (context);
+ case 0x0002: return GetSyncpoint (context);
+ case 0x0003: return GetWaitBase (context);
+ case 0x0009: return MapBuffer (context);
+ case 0x000a: return UnmapBuffer (context);
+ case 0x480b: return ZcullBind (context);
+ case 0x480c: return SetErrorNotifier (context);
+ case 0x4803: return SetTimeout (context);
+ case 0x481a: return AllocGpfifoEx2 (context);
+ case 0x481b: return KickoffPbWithAttr(context);
}
- throw new NotImplementedException(Cmd.ToString("x8"));
+ throw new NotImplementedException(cmd.ToString("x8"));
}
- private static int Submit(ServiceCtx Context)
+ private static int Submit(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelSubmit Args = MemoryHelper.Read<NvHostChannelSubmit>(Context.Memory, InputPosition);
+ NvHostChannelSubmit args = MemoryHelper.Read<NvHostChannelSubmit>(context.Memory, inputPosition);
- NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
+ NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
- for (int Index = 0; Index < Args.CmdBufsCount; Index++)
+ for (int index = 0; index < args.CmdBufsCount; index++)
{
- long CmdBufOffset = InputPosition + 0x10 + Index * 0xc;
+ long cmdBufOffset = inputPosition + 0x10 + index * 0xc;
- NvHostChannelCmdBuf CmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(Context.Memory, CmdBufOffset);
+ NvHostChannelCmdBuf cmdBuf = MemoryHelper.Read<NvHostChannelCmdBuf>(context.Memory, cmdBufOffset);
- NvMapHandle Map = NvMapIoctl.GetNvMap(Context, CmdBuf.MemoryId);
+ NvMapHandle map = NvMapIoctl.GetNvMap(context, cmdBuf.MemoryId);
- int[] CmdBufData = new int[CmdBuf.WordsCount];
+ int[] cmdBufData = new int[cmdBuf.WordsCount];
- for (int Offset = 0; Offset < CmdBufData.Length; Offset++)
+ for (int offset = 0; offset < cmdBufData.Length; offset++)
{
- CmdBufData[Offset] = Context.Memory.ReadInt32(Map.Address + CmdBuf.Offset + Offset * 4);
+ cmdBufData[offset] = context.Memory.ReadInt32(map.Address + cmdBuf.Offset + offset * 4);
}
- Context.Device.Gpu.PushCommandBuffer(Vmm, CmdBufData);
+ context.Device.Gpu.PushCommandBuffer(vmm, cmdBufData);
}
//TODO: Relocation, waitchecks, etc.
@@ -74,99 +69,99 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
return NvResult.Success;
}
- private static int GetSyncpoint(ServiceCtx Context)
+ private static int GetSyncpoint(ServiceCtx context)
{
//TODO
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition);
+ NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition);
- Args.Value = 0;
+ args.Value = 0;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int GetWaitBase(ServiceCtx Context)
+ private static int GetWaitBase(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelGetParamArg Args = MemoryHelper.Read<NvHostChannelGetParamArg>(Context.Memory, InputPosition);
+ NvHostChannelGetParamArg args = MemoryHelper.Read<NvHostChannelGetParamArg>(context.Memory, inputPosition);
- Args.Value = 0;
+ args.Value = 0;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int MapBuffer(ServiceCtx Context)
+ private static int MapBuffer(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition);
+ NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition);
- NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
+ NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
- for (int Index = 0; Index < Args.NumEntries; Index++)
+ for (int index = 0; index < args.NumEntries; index++)
{
- int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8);
+ int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8);
- NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle);
+ NvMapHandle map = NvMapIoctl.GetNvMap(context, handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!");
return NvResult.InvalidInput;
}
- lock (Map)
+ lock (map)
{
- if (Map.DmaMapAddress == 0)
+ if (map.DmaMapAddress == 0)
{
- Map.DmaMapAddress = Vmm.MapLow(Map.Address, Map.Size);
+ map.DmaMapAddress = vmm.MapLow(map.Address, map.Size);
}
- Context.Memory.WriteInt32(OutputPosition + 0xc + 4 + Index * 8, (int)Map.DmaMapAddress);
+ context.Memory.WriteInt32(outputPosition + 0xc + 4 + index * 8, (int)map.DmaMapAddress);
}
}
return NvResult.Success;
}
- private static int UnmapBuffer(ServiceCtx Context)
+ private static int UnmapBuffer(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
- NvHostChannelMapBuffer Args = MemoryHelper.Read<NvHostChannelMapBuffer>(Context.Memory, InputPosition);
+ NvHostChannelMapBuffer args = MemoryHelper.Read<NvHostChannelMapBuffer>(context.Memory, inputPosition);
- NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
+ NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
- for (int Index = 0; Index < Args.NumEntries; Index++)
+ for (int index = 0; index < args.NumEntries; index++)
{
- int Handle = Context.Memory.ReadInt32(InputPosition + 0xc + Index * 8);
+ int handle = context.Memory.ReadInt32(inputPosition + 0xc + index * 8);
- NvMapHandle Map = NvMapIoctl.GetNvMap(Context, Handle);
+ NvMapHandle map = NvMapIoctl.GetNvMap(context, handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{handle:x8}!");
return NvResult.InvalidInput;
}
- lock (Map)
+ lock (map)
{
- if (Map.DmaMapAddress != 0)
+ if (map.DmaMapAddress != 0)
{
- Vmm.Free(Map.DmaMapAddress, Map.Size);
+ vmm.Free(map.DmaMapAddress, map.Size);
- Map.DmaMapAddress = 0;
+ map.DmaMapAddress = 0;
}
}
}
@@ -174,146 +169,146 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
return NvResult.Success;
}
- private static int SetUserData(ServiceCtx Context)
+ private static int SetUserData(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int SetNvMap(ServiceCtx Context)
+ private static int SetNvMap(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int SetTimeout(ServiceCtx Context)
+ private static int SetTimeout(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
- GetChannel(Context).Timeout = Context.Memory.ReadInt32(InputPosition);
+ GetChannel(context).Timeout = context.Memory.ReadInt32(inputPosition);
return NvResult.Success;
}
- private static int SubmitGpfifo(ServiceCtx Context)
+ private static int SubmitGpfifo(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);
+ NvHostChannelSubmitGpfifo args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(context.Memory, inputPosition);
- NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;;
+ NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
- for (int Index = 0; Index < Args.NumEntries; Index++)
+ for (int index = 0; index < args.NumEntries; index++)
{
- long Gpfifo = Context.Memory.ReadInt64(InputPosition + 0x18 + Index * 8);
+ long gpfifo = context.Memory.ReadInt64(inputPosition + 0x18 + index * 8);
- PushGpfifo(Context, Vmm, Gpfifo);
+ PushGpfifo(context, vmm, gpfifo);
}
- Args.SyncptId = 0;
- Args.SyncptValue = 0;
+ args.SyncptId = 0;
+ args.SyncptValue = 0;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int AllocObjCtx(ServiceCtx Context)
+ private static int AllocObjCtx(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int ZcullBind(ServiceCtx Context)
+ private static int ZcullBind(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int SetErrorNotifier(ServiceCtx Context)
+ private static int SetErrorNotifier(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int SetPriority(ServiceCtx Context)
+ private static int SetPriority(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int AllocGpfifoEx2(ServiceCtx Context)
+ private static int AllocGpfifoEx2(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int KickoffPbWithAttr(ServiceCtx Context)
+ private static int KickoffPbWithAttr(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostChannelSubmitGpfifo Args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(Context.Memory, InputPosition);
+ NvHostChannelSubmitGpfifo args = MemoryHelper.Read<NvHostChannelSubmitGpfifo>(context.Memory, inputPosition);
- NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;;
+ NvGpuVmm vmm = NvGpuASIoctl.GetASCtx(context).Vmm;
- for (int Index = 0; Index < Args.NumEntries; Index++)
+ for (int index = 0; index < args.NumEntries; index++)
{
- long Gpfifo = Context.Memory.ReadInt64(Args.Address + Index * 8);
+ long gpfifo = context.Memory.ReadInt64(args.Address + index * 8);
- PushGpfifo(Context, Vmm, Gpfifo);
+ PushGpfifo(context, vmm, gpfifo);
}
- Args.SyncptId = 0;
- Args.SyncptValue = 0;
+ args.SyncptId = 0;
+ args.SyncptValue = 0;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static void PushGpfifo(ServiceCtx Context, NvGpuVmm Vmm, long Gpfifo)
+ private static void PushGpfifo(ServiceCtx context, NvGpuVmm vmm, long gpfifo)
{
- Context.Device.Gpu.Pusher.Push(Vmm, Gpfifo);
+ context.Device.Gpu.Pusher.Push(vmm, gpfifo);
}
- public static NvChannel GetChannel(ServiceCtx Context)
+ public static NvChannel GetChannel(ServiceCtx context)
{
- return Channels.GetOrAdd(Context.Process, (Key) => new NvChannel());
+ return _channels.GetOrAdd(context.Process, (key) => new NvChannel());
}
- public static void UnloadProcess(KProcess Process)
+ public static void UnloadProcess(KProcess process)
{
- Channels.TryRemove(Process, out _);
+ _channels.TryRemove(process, out _);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
index bf92afb4..f13f7a68 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
@@ -10,116 +10,116 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
{
class NvHostCtrlIoctl
{
- private static ConcurrentDictionary<KProcess, NvHostCtrlUserCtx> UserCtxs;
+ private static ConcurrentDictionary<KProcess, NvHostCtrlUserCtx> _userCtxs;
- private static bool IsProductionMode = true;
+ private static bool _isProductionMode = true;
static NvHostCtrlIoctl()
{
- UserCtxs = new ConcurrentDictionary<KProcess, NvHostCtrlUserCtx>();
+ _userCtxs = new ConcurrentDictionary<KProcess, NvHostCtrlUserCtx>();
- if (Set.NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object ProductionModeSetting))
+ if (Set.NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object productionModeSetting))
{
- IsProductionMode = ((string)ProductionModeSetting) != "0"; // Default value is ""
+ _isProductionMode = ((string)productionModeSetting) != "0"; // Default value is ""
}
}
- public static int ProcessIoctl(ServiceCtx Context, int Cmd)
+ public static int ProcessIoctl(ServiceCtx context, int cmd)
{
- switch (Cmd & 0xffff)
+ switch (cmd & 0xffff)
{
- case 0x0014: return SyncptRead (Context);
- case 0x0015: return SyncptIncr (Context);
- case 0x0016: return SyncptWait (Context);
- case 0x0019: return SyncptWaitEx (Context);
- case 0x001a: return SyncptReadMax (Context);
- case 0x001b: return GetConfig (Context);
- case 0x001d: return EventWait (Context);
- case 0x001e: return EventWaitAsync(Context);
- case 0x001f: return EventRegister (Context);
+ case 0x0014: return SyncptRead (context);
+ case 0x0015: return SyncptIncr (context);
+ case 0x0016: return SyncptWait (context);
+ case 0x0019: return SyncptWaitEx (context);
+ case 0x001a: return SyncptReadMax (context);
+ case 0x001b: return GetConfig (context);
+ case 0x001d: return EventWait (context);
+ case 0x001e: return EventWaitAsync(context);
+ case 0x001f: return EventRegister (context);
}
- throw new NotImplementedException(Cmd.ToString("x8"));
+ throw new NotImplementedException(cmd.ToString("x8"));
}
- private static int SyncptRead(ServiceCtx Context)
+ private static int SyncptRead(ServiceCtx context)
{
- return SyncptReadMinOrMax(Context, Max: false);
+ return SyncptReadMinOrMax(context, max: false);
}
- private static int SyncptIncr(ServiceCtx Context)
+ private static int SyncptIncr(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
- int Id = Context.Memory.ReadInt32(InputPosition);
+ int id = context.Memory.ReadInt32(inputPosition);
- if ((uint)Id >= NvHostSyncpt.SyncptsCount)
+ if ((uint)id >= NvHostSyncpt.SyncptsCount)
{
return NvResult.InvalidInput;
}
- GetUserCtx(Context).Syncpt.Increment(Id);
+ GetUserCtx(context).Syncpt.Increment(id);
return NvResult.Success;
}
- private static int SyncptWait(ServiceCtx Context)
+ private static int SyncptWait(ServiceCtx context)
{
- return SyncptWait(Context, Extended: false);
+ return SyncptWait(context, extended: false);
}
- private static int SyncptWaitEx(ServiceCtx Context)
+ private static int SyncptWaitEx(ServiceCtx context)
{
- return SyncptWait(Context, Extended: true);
+ return SyncptWait(context, extended: true);
}
- private static int SyncptReadMax(ServiceCtx Context)
+ private static int SyncptReadMax(ServiceCtx context)
{
- return SyncptReadMinOrMax(Context, Max: true);
+ return SyncptReadMinOrMax(context, max: true);
}
- private static int GetConfig(ServiceCtx Context)
+ private static int GetConfig(ServiceCtx context)
{
- if (!IsProductionMode)
+ if (!_isProductionMode)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- string Domain = MemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0, 0x41);
- string Name = MemoryHelper.ReadAsciiString(Context.Memory, InputPosition + 0x41, 0x41);
+ string domain = MemoryHelper.ReadAsciiString(context.Memory, inputPosition + 0, 0x41);
+ string name = MemoryHelper.ReadAsciiString(context.Memory, inputPosition + 0x41, 0x41);
- if (Set.NxSettings.Settings.TryGetValue($"{Domain}!{Name}", out object NvSetting))
+ if (Set.NxSettings.Settings.TryGetValue($"{domain}!{name}", out object nvSetting))
{
- byte[] SettingBuffer = new byte[0x101];
+ byte[] settingBuffer = new byte[0x101];
- if (NvSetting is string StringValue)
+ if (nvSetting is string stringValue)
{
- if (StringValue.Length > 0x100)
+ if (stringValue.Length > 0x100)
{
- Logger.PrintError(LogClass.ServiceNv, $"{Domain}!{Name} String value size is too big!");
+ Logger.PrintError(LogClass.ServiceNv, $"{domain}!{name} String value size is too big!");
}
else
{
- SettingBuffer = Encoding.ASCII.GetBytes(StringValue + "\0");
+ settingBuffer = Encoding.ASCII.GetBytes(stringValue + "\0");
}
}
- if (NvSetting is int IntValue)
+ if (nvSetting is int intValue)
{
- SettingBuffer = BitConverter.GetBytes(IntValue);
+ settingBuffer = BitConverter.GetBytes(intValue);
}
- else if (NvSetting is bool BoolValue)
+ else if (nvSetting is bool boolValue)
{
- SettingBuffer[0] = BoolValue ? (byte)1 : (byte)0;
+ settingBuffer[0] = boolValue ? (byte)1 : (byte)0;
}
else
{
- throw new NotImplementedException(NvSetting.GetType().Name);
+ throw new NotImplementedException(nvSetting.GetType().Name);
}
- Context.Memory.WriteBytes(OutputPosition + 0x82, SettingBuffer);
+ context.Memory.WriteBytes(outputPosition + 0x82, settingBuffer);
- Logger.PrintDebug(LogClass.ServiceNv, $"Got setting {Domain}!{Name}");
+ Logger.PrintDebug(LogClass.ServiceNv, $"Got setting {domain}!{name}");
}
return NvResult.Success;
@@ -128,156 +128,156 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
return NvResult.NotAvailableInProduction;
}
- private static int EventWait(ServiceCtx Context)
+ private static int EventWait(ServiceCtx context)
{
- return EventWait(Context, Async: false);
+ return EventWait(context, async: false);
}
- private static int EventWaitAsync(ServiceCtx Context)
+ private static int EventWaitAsync(ServiceCtx context)
{
- return EventWait(Context, Async: true);
+ return EventWait(context, async: true);
}
- private static int EventRegister(ServiceCtx Context)
+ private static int EventRegister(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- int EventId = Context.Memory.ReadInt32(InputPosition);
+ int eventId = context.Memory.ReadInt32(inputPosition);
Logger.PrintStub(LogClass.ServiceNv, "Stubbed.");
return NvResult.Success;
}
- private static int SyncptReadMinOrMax(ServiceCtx Context, bool Max)
+ private static int SyncptReadMinOrMax(ServiceCtx context, bool max)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostCtrlSyncptRead Args = MemoryHelper.Read<NvHostCtrlSyncptRead>(Context.Memory, InputPosition);
+ NvHostCtrlSyncptRead args = MemoryHelper.Read<NvHostCtrlSyncptRead>(context.Memory, inputPosition);
- if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount)
+ if ((uint)args.Id >= NvHostSyncpt.SyncptsCount)
{
return NvResult.InvalidInput;
}
- if (Max)
+ if (max)
{
- Args.Value = GetUserCtx(Context).Syncpt.GetMax(Args.Id);
+ args.Value = GetUserCtx(context).Syncpt.GetMax(args.Id);
}
else
{
- Args.Value = GetUserCtx(Context).Syncpt.GetMin(Args.Id);
+ args.Value = GetUserCtx(context).Syncpt.GetMin(args.Id);
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int SyncptWait(ServiceCtx Context, bool Extended)
+ private static int SyncptWait(ServiceCtx context, bool extended)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostCtrlSyncptWait Args = MemoryHelper.Read<NvHostCtrlSyncptWait>(Context.Memory, InputPosition);
+ NvHostCtrlSyncptWait args = MemoryHelper.Read<NvHostCtrlSyncptWait>(context.Memory, inputPosition);
- NvHostSyncpt Syncpt = GetUserCtx(Context).Syncpt;
+ NvHostSyncpt syncpt = GetUserCtx(context).Syncpt;
- if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount)
+ if ((uint)args.Id >= NvHostSyncpt.SyncptsCount)
{
return NvResult.InvalidInput;
}
- int Result;
+ int result;
- if (Syncpt.MinCompare(Args.Id, Args.Thresh))
+ if (syncpt.MinCompare(args.Id, args.Thresh))
{
- Result = NvResult.Success;
+ result = NvResult.Success;
}
- else if (Args.Timeout == 0)
+ else if (args.Timeout == 0)
{
- Result = NvResult.TryAgain;
+ result = NvResult.TryAgain;
}
else
{
- Logger.PrintDebug(LogClass.ServiceNv, "Waiting syncpt with timeout of " + Args.Timeout + "ms...");
+ Logger.PrintDebug(LogClass.ServiceNv, "Waiting syncpt with timeout of " + args.Timeout + "ms...");
- using (ManualResetEvent WaitEvent = new ManualResetEvent(false))
+ using (ManualResetEvent waitEvent = new ManualResetEvent(false))
{
- Syncpt.AddWaiter(Args.Thresh, WaitEvent);
+ syncpt.AddWaiter(args.Thresh, waitEvent);
//Note: Negative (> INT_MAX) timeouts aren't valid on .NET,
//in this case we just use the maximum timeout possible.
- int Timeout = Args.Timeout;
+ int timeout = args.Timeout;
- if (Timeout < -1)
+ if (timeout < -1)
{
- Timeout = int.MaxValue;
+ timeout = int.MaxValue;
}
- if (Timeout == -1)
+ if (timeout == -1)
{
- WaitEvent.WaitOne();
+ waitEvent.WaitOne();
- Result = NvResult.Success;
+ result = NvResult.Success;
}
- else if (WaitEvent.WaitOne(Timeout))
+ else if (waitEvent.WaitOne(timeout))
{
- Result = NvResult.Success;
+ result = NvResult.Success;
}
else
{
- Result = NvResult.TimedOut;
+ result = NvResult.TimedOut;
}
}
Logger.PrintDebug(LogClass.ServiceNv, "Resuming...");
}
- if (Extended)
+ if (extended)
{
- Context.Memory.WriteInt32(OutputPosition + 0xc, Syncpt.GetMin(Args.Id));
+ context.Memory.WriteInt32(outputPosition + 0xc, syncpt.GetMin(args.Id));
}
- return Result;
+ return result;
}
- private static int EventWait(ServiceCtx Context, bool Async)
+ private static int EventWait(ServiceCtx context, bool async)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvHostCtrlSyncptWaitEx Args = MemoryHelper.Read<NvHostCtrlSyncptWaitEx>(Context.Memory, InputPosition);
+ NvHostCtrlSyncptWaitEx args = MemoryHelper.Read<NvHostCtrlSyncptWaitEx>(context.Memory, inputPosition);
- if ((uint)Args.Id >= NvHostSyncpt.SyncptsCount)
+ if ((uint)args.Id >= NvHostSyncpt.SyncptsCount)
{
return NvResult.InvalidInput;
}
void WriteArgs()
{
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
}
- NvHostSyncpt Syncpt = GetUserCtx(Context).Syncpt;
+ NvHostSyncpt syncpt = GetUserCtx(context).Syncpt;
- if (Syncpt.MinCompare(Args.Id, Args.Thresh))
+ if (syncpt.MinCompare(args.Id, args.Thresh))
{
- Args.Value = Syncpt.GetMin(Args.Id);
+ args.Value = syncpt.GetMin(args.Id);
WriteArgs();
return NvResult.Success;
}
- if (!Async)
+ if (!async)
{
- Args.Value = 0;
+ args.Value = 0;
}
- if (Args.Timeout == 0)
+ if (args.Timeout == 0)
{
WriteArgs();
@@ -286,114 +286,114 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
NvHostEvent Event;
- int Result, EventIndex;
+ int result, eventIndex;
- if (Async)
+ if (async)
{
- EventIndex = Args.Value;
+ eventIndex = args.Value;
- if ((uint)EventIndex >= NvHostCtrlUserCtx.EventsCount)
+ if ((uint)eventIndex >= NvHostCtrlUserCtx.EventsCount)
{
return NvResult.InvalidInput;
}
- Event = GetUserCtx(Context).Events[EventIndex];
+ Event = GetUserCtx(context).Events[eventIndex];
}
else
{
- Event = GetFreeEvent(Context, Syncpt, Args.Id, out EventIndex);
+ Event = GetFreeEvent(context, syncpt, args.Id, out eventIndex);
}
if (Event != null &&
(Event.State == NvHostEventState.Registered ||
Event.State == NvHostEventState.Free))
{
- Event.Id = Args.Id;
- Event.Thresh = Args.Thresh;
+ Event.Id = args.Id;
+ Event.Thresh = args.Thresh;
Event.State = NvHostEventState.Waiting;
- if (!Async)
+ if (!async)
{
- Args.Value = ((Args.Id & 0xfff) << 16) | 0x10000000;
+ args.Value = ((args.Id & 0xfff) << 16) | 0x10000000;
}
else
{
- Args.Value = Args.Id << 4;
+ args.Value = args.Id << 4;
}
- Args.Value |= EventIndex;
+ args.Value |= eventIndex;
- Result = NvResult.TryAgain;
+ result = NvResult.TryAgain;
}
else
{
- Result = NvResult.InvalidInput;
+ result = NvResult.InvalidInput;
}
WriteArgs();
- return Result;
+ return result;
}
private static NvHostEvent GetFreeEvent(
- ServiceCtx Context,
- NvHostSyncpt Syncpt,
- int Id,
- out int EventIndex)
+ ServiceCtx context,
+ NvHostSyncpt syncpt,
+ int id,
+ out int eventIndex)
{
- NvHostEvent[] Events = GetUserCtx(Context).Events;
+ NvHostEvent[] events = GetUserCtx(context).Events;
- EventIndex = NvHostCtrlUserCtx.EventsCount;
+ eventIndex = NvHostCtrlUserCtx.EventsCount;
- int NullIndex = NvHostCtrlUserCtx.EventsCount;
+ int nullIndex = NvHostCtrlUserCtx.EventsCount;
- for (int Index = 0; Index < NvHostCtrlUserCtx.EventsCount; Index++)
+ for (int index = 0; index < NvHostCtrlUserCtx.EventsCount; index++)
{
- NvHostEvent Event = Events[Index];
+ NvHostEvent Event = events[index];
if (Event != null)
{
if (Event.State == NvHostEventState.Registered ||
Event.State == NvHostEventState.Free)
{
- EventIndex = Index;
+ eventIndex = index;
- if (Event.Id == Id)
+ if (Event.Id == id)
{
return Event;
}
}
}
- else if (NullIndex == NvHostCtrlUserCtx.EventsCount)
+ else if (nullIndex == NvHostCtrlUserCtx.EventsCount)
{
- NullIndex = Index;
+ nullIndex = index;
}
}
- if (NullIndex < NvHostCtrlUserCtx.EventsCount)
+ if (nullIndex < NvHostCtrlUserCtx.EventsCount)
{
- EventIndex = NullIndex;
+ eventIndex = nullIndex;
- return Events[NullIndex] = new NvHostEvent();
+ return events[nullIndex] = new NvHostEvent();
}
- if (EventIndex < NvHostCtrlUserCtx.EventsCount)
+ if (eventIndex < NvHostCtrlUserCtx.EventsCount)
{
- return Events[EventIndex];
+ return events[eventIndex];
}
return null;
}
- public static NvHostCtrlUserCtx GetUserCtx(ServiceCtx Context)
+ public static NvHostCtrlUserCtx GetUserCtx(ServiceCtx context)
{
- return UserCtxs.GetOrAdd(Context.Process, (Key) => new NvHostCtrlUserCtx());
+ return _userCtxs.GetOrAdd(context.Process, (key) => new NvHostCtrlUserCtx());
}
- public static void UnloadProcess(KProcess Process)
+ public static void UnloadProcess(KProcess process)
{
- UserCtxs.TryRemove(Process, out _);
+ _userCtxs.TryRemove(process, out _);
}
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs
index fcb80836..aa4577ed 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlUserCtx.cs
@@ -5,9 +5,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
public const int LocksCount = 16;
public const int EventsCount = 64;
- public NvHostSyncpt Syncpt { get; private set; }
+ public NvHostSyncpt Syncpt { get; }
- public NvHostEvent[] Events { get; private set; }
+ public NvHostEvent[] Events { get; }
public NvHostCtrlUserCtx()
{
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs
index 9ffa93f2..d27f7c53 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs
@@ -9,98 +9,98 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
{
public const int SyncptsCount = 192;
- private int[] CounterMin;
- private int[] CounterMax;
+ private int[] _counterMin;
+ private int[] _counterMax;
- private long EventMask;
+ private long _eventMask;
- private ConcurrentDictionary<EventWaitHandle, int> Waiters;
+ private ConcurrentDictionary<EventWaitHandle, int> _waiters;
public NvHostSyncpt()
{
- CounterMin = new int[SyncptsCount];
- CounterMax = new int[SyncptsCount];
+ _counterMin = new int[SyncptsCount];
+ _counterMax = new int[SyncptsCount];
- Waiters = new ConcurrentDictionary<EventWaitHandle, int>();
+ _waiters = new ConcurrentDictionary<EventWaitHandle, int>();
}
- public int GetMin(int Id)
+ public int GetMin(int id)
{
- return CounterMin[Id];
+ return _counterMin[id];
}
- public int GetMax(int Id)
+ public int GetMax(int id)
{
- return CounterMax[Id];
+ return _counterMax[id];
}
- public int Increment(int Id)
+ public int Increment(int id)
{
- if (((EventMask >> Id) & 1) != 0)
+ if (((_eventMask >> id) & 1) != 0)
{
- Interlocked.Increment(ref CounterMax[Id]);
+ Interlocked.Increment(ref _counterMax[id]);
}
- return IncrementMin(Id);
+ return IncrementMin(id);
}
- public int IncrementMin(int Id)
+ public int IncrementMin(int id)
{
- int Value = Interlocked.Increment(ref CounterMin[Id]);
+ int value = Interlocked.Increment(ref _counterMin[id]);
- WakeUpWaiters(Id, Value);
+ WakeUpWaiters(id, value);
- return Value;
+ return value;
}
- public int IncrementMax(int Id)
+ public int IncrementMax(int id)
{
- return Interlocked.Increment(ref CounterMax[Id]);
+ return Interlocked.Increment(ref _counterMax[id]);
}
- public void AddWaiter(int Threshold, EventWaitHandle WaitEvent)
+ public void AddWaiter(int threshold, EventWaitHandle waitEvent)
{
- if (!Waiters.TryAdd(WaitEvent, Threshold))
+ if (!_waiters.TryAdd(waitEvent, threshold))
{
throw new InvalidOperationException();
}
}
- public bool RemoveWaiter(EventWaitHandle WaitEvent)
+ public bool RemoveWaiter(EventWaitHandle waitEvent)
{
- return Waiters.TryRemove(WaitEvent, out _);
+ return _waiters.TryRemove(waitEvent, out _);
}
- private void WakeUpWaiters(int Id, int NewValue)
+ private void WakeUpWaiters(int id, int newValue)
{
- foreach (KeyValuePair<EventWaitHandle, int> KV in Waiters)
+ foreach (KeyValuePair<EventWaitHandle, int> kv in _waiters)
{
- if (MinCompare(Id, NewValue, CounterMax[Id], KV.Value))
+ if (MinCompare(id, newValue, _counterMax[id], kv.Value))
{
- KV.Key.Set();
+ kv.Key.Set();
- Waiters.TryRemove(KV.Key, out _);
+ _waiters.TryRemove(kv.Key, out _);
}
}
}
- public bool MinCompare(int Id, int Threshold)
+ public bool MinCompare(int id, int threshold)
{
- return MinCompare(Id, CounterMin[Id], CounterMax[Id], Threshold);
+ return MinCompare(id, _counterMin[id], _counterMax[id], threshold);
}
- private bool MinCompare(int Id, int Min, int Max, int Threshold)
+ private bool MinCompare(int id, int min, int max, int threshold)
{
- int MinDiff = Min - Threshold;
- int MaxDiff = Max - Threshold;
+ int minDiff = min - threshold;
+ int maxDiff = max - threshold;
- if (((EventMask >> Id) & 1) != 0)
+ if (((_eventMask >> id) & 1) != 0)
{
- return MinDiff >= 0;
+ return minDiff >= 0;
}
else
{
- return (uint)MaxDiff >= (uint)MinDiff;
+ return (uint)maxDiff >= (uint)minDiff;
}
}
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs
index e97e4ff4..31bf8329 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapHandle.cs
@@ -13,26 +13,26 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap
public bool Allocated;
public long DmaMapAddress;
- private long Dupes;
+ private long _dupes;
public NvMapHandle()
{
- Dupes = 1;
+ _dupes = 1;
}
- public NvMapHandle(int Size) : this()
+ public NvMapHandle(int size) : this()
{
- this.Size = Size;
+ Size = size;
}
public void IncrementRefCount()
{
- Interlocked.Increment(ref Dupes);
+ Interlocked.Increment(ref _dupes);
}
public long DecrementRefCount()
{
- return Interlocked.Decrement(ref Dupes);
+ return Interlocked.Decrement(ref _dupes);
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
index adc523e5..75a76b91 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
@@ -11,290 +11,290 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap
{
private const int FlagNotFreedYet = 1;
- private static ConcurrentDictionary<KProcess, IdDictionary> Maps;
+ private static ConcurrentDictionary<KProcess, IdDictionary> _maps;
static NvMapIoctl()
{
- Maps = new ConcurrentDictionary<KProcess, IdDictionary>();
+ _maps = new ConcurrentDictionary<KProcess, IdDictionary>();
}
- public static int ProcessIoctl(ServiceCtx Context, int Cmd)
+ public static int ProcessIoctl(ServiceCtx context, int cmd)
{
- switch (Cmd & 0xffff)
+ switch (cmd & 0xffff)
{
- case 0x0101: return Create(Context);
- case 0x0103: return FromId(Context);
- case 0x0104: return Alloc (Context);
- case 0x0105: return Free (Context);
- case 0x0109: return Param (Context);
- case 0x010e: return GetId (Context);
+ case 0x0101: return Create(context);
+ case 0x0103: return FromId(context);
+ case 0x0104: return Alloc (context);
+ case 0x0105: return Free (context);
+ case 0x0109: return Param (context);
+ case 0x010e: return GetId (context);
}
- Logger.PrintWarning(LogClass.ServiceNv, $"Unsupported Ioctl command 0x{Cmd:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Unsupported Ioctl command 0x{cmd:x8}!");
return NvResult.NotSupported;
}
- private static int Create(ServiceCtx Context)
+ private static int Create(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapCreate Args = MemoryHelper.Read<NvMapCreate>(Context.Memory, InputPosition);
+ NvMapCreate args = MemoryHelper.Read<NvMapCreate>(context.Memory, inputPosition);
- if (Args.Size == 0)
+ if (args.Size == 0)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid size 0x{Args.Size:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid size 0x{args.Size:x8}!");
return NvResult.InvalidInput;
}
- int Size = IntUtils.AlignUp(Args.Size, NvGpuVmm.PageSize);
+ int size = IntUtils.AlignUp(args.Size, NvGpuVmm.PageSize);
- Args.Handle = AddNvMap(Context, new NvMapHandle(Size));
+ args.Handle = AddNvMap(context, new NvMapHandle(size));
- Logger.PrintInfo(LogClass.ServiceNv, $"Created map {Args.Handle} with size 0x{Size:x8}!");
+ Logger.PrintInfo(LogClass.ServiceNv, $"Created map {args.Handle} with size 0x{size:x8}!");
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int FromId(ServiceCtx Context)
+ private static int FromId(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapFromId Args = MemoryHelper.Read<NvMapFromId>(Context.Memory, InputPosition);
+ NvMapFromId args = MemoryHelper.Read<NvMapFromId>(context.Memory, inputPosition);
- NvMapHandle Map = GetNvMap(Context, Args.Id);
+ NvMapHandle map = GetNvMap(context, args.Id);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!");
return NvResult.InvalidInput;
}
- Map.IncrementRefCount();
+ map.IncrementRefCount();
- Args.Handle = Args.Id;
+ args.Handle = args.Id;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int Alloc(ServiceCtx Context)
+ private static int Alloc(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapAlloc Args = MemoryHelper.Read<NvMapAlloc>(Context.Memory, InputPosition);
+ NvMapAlloc args = MemoryHelper.Read<NvMapAlloc>(context.Memory, inputPosition);
- NvMapHandle Map = GetNvMap(Context, Args.Handle);
+ NvMapHandle map = GetNvMap(context, args.Handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!");
return NvResult.InvalidInput;
}
- if ((Args.Align & (Args.Align - 1)) != 0)
+ if ((args.Align & (args.Align - 1)) != 0)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid alignment 0x{Args.Align:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid alignment 0x{args.Align:x8}!");
return NvResult.InvalidInput;
}
- if ((uint)Args.Align < NvGpuVmm.PageSize)
+ if ((uint)args.Align < NvGpuVmm.PageSize)
{
- Args.Align = NvGpuVmm.PageSize;
+ args.Align = NvGpuVmm.PageSize;
}
- int Result = NvResult.Success;
+ int result = NvResult.Success;
- if (!Map.Allocated)
+ if (!map.Allocated)
{
- Map.Allocated = true;
+ map.Allocated = true;
- Map.Align = Args.Align;
- Map.Kind = (byte)Args.Kind;
+ map.Align = args.Align;
+ map.Kind = (byte)args.Kind;
- int Size = IntUtils.AlignUp(Map.Size, NvGpuVmm.PageSize);
+ int size = IntUtils.AlignUp(map.Size, NvGpuVmm.PageSize);
- long Address = Args.Address;
+ long address = args.Address;
- if (Address == 0)
+ if (address == 0)
{
//When the address is zero, we need to allocate
//our own backing memory for the NvMap.
//TODO: Is this allocation inside the transfer memory?
- Result = NvResult.OutOfMemory;
+ result = NvResult.OutOfMemory;
}
- if (Result == NvResult.Success)
+ if (result == NvResult.Success)
{
- Map.Size = Size;
- Map.Address = Address;
+ map.Size = size;
+ map.Address = address;
}
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
- return Result;
+ return result;
}
- private static int Free(ServiceCtx Context)
+ private static int Free(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapFree Args = MemoryHelper.Read<NvMapFree>(Context.Memory, InputPosition);
+ NvMapFree args = MemoryHelper.Read<NvMapFree>(context.Memory, inputPosition);
- NvMapHandle Map = GetNvMap(Context, Args.Handle);
+ NvMapHandle map = GetNvMap(context, args.Handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!");
return NvResult.InvalidInput;
}
- if (Map.DecrementRefCount() <= 0)
+ if (map.DecrementRefCount() <= 0)
{
- DeleteNvMap(Context, Args.Handle);
+ DeleteNvMap(context, args.Handle);
- Logger.PrintInfo(LogClass.ServiceNv, $"Deleted map {Args.Handle}!");
+ Logger.PrintInfo(LogClass.ServiceNv, $"Deleted map {args.Handle}!");
- Args.Address = Map.Address;
- Args.Flags = 0;
+ args.Address = map.Address;
+ args.Flags = 0;
}
else
{
- Args.Address = 0;
- Args.Flags = FlagNotFreedYet;
+ args.Address = 0;
+ args.Flags = FlagNotFreedYet;
}
- Args.Size = Map.Size;
+ args.Size = map.Size;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int Param(ServiceCtx Context)
+ private static int Param(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapParam Args = MemoryHelper.Read<NvMapParam>(Context.Memory, InputPosition);
+ NvMapParam args = MemoryHelper.Read<NvMapParam>(context.Memory, inputPosition);
- NvMapHandle Map = GetNvMap(Context, Args.Handle);
+ NvMapHandle map = GetNvMap(context, args.Handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!");
return NvResult.InvalidInput;
}
- switch ((NvMapHandleParam)Args.Param)
+ switch ((NvMapHandleParam)args.Param)
{
- case NvMapHandleParam.Size: Args.Result = Map.Size; break;
- case NvMapHandleParam.Align: Args.Result = Map.Align; break;
- case NvMapHandleParam.Heap: Args.Result = 0x40000000; break;
- case NvMapHandleParam.Kind: Args.Result = Map.Kind; break;
- case NvMapHandleParam.Compr: Args.Result = 0; break;
+ case NvMapHandleParam.Size: args.Result = map.Size; break;
+ case NvMapHandleParam.Align: args.Result = map.Align; break;
+ case NvMapHandleParam.Heap: args.Result = 0x40000000; break;
+ case NvMapHandleParam.Kind: args.Result = map.Kind; break;
+ case NvMapHandleParam.Compr: args.Result = 0; break;
//Note: Base is not supported and returns an error.
//Any other value also returns an error.
default: return NvResult.InvalidInput;
}
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int GetId(ServiceCtx Context)
+ private static int GetId(ServiceCtx context)
{
- long InputPosition = Context.Request.GetBufferType0x21().Position;
- long OutputPosition = Context.Request.GetBufferType0x22().Position;
+ long inputPosition = context.Request.GetBufferType0x21().Position;
+ long outputPosition = context.Request.GetBufferType0x22().Position;
- NvMapGetId Args = MemoryHelper.Read<NvMapGetId>(Context.Memory, InputPosition);
+ NvMapGetId args = MemoryHelper.Read<NvMapGetId>(context.Memory, inputPosition);
- NvMapHandle Map = GetNvMap(Context, Args.Handle);
+ NvMapHandle map = GetNvMap(context, args.Handle);
- if (Map == null)
+ if (map == null)
{
- Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{Args.Handle:x8}!");
+ Logger.PrintWarning(LogClass.ServiceNv, $"Invalid handle 0x{args.Handle:x8}!");
return NvResult.InvalidInput;
}
- Args.Id = Args.Handle;
+ args.Id = args.Handle;
- MemoryHelper.Write(Context.Memory, OutputPosition, Args);
+ MemoryHelper.Write(context.Memory, outputPosition, args);
return NvResult.Success;
}
- private static int AddNvMap(ServiceCtx Context, NvMapHandle Map)
+ private static int AddNvMap(ServiceCtx context, NvMapHandle map)
{
- IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) =>
+ IdDictionary dict = _maps.GetOrAdd(context.Process, (key) =>
{
- IdDictionary NewDict = new IdDictionary();
+ IdDictionary newDict = new IdDictionary();
- NewDict.Add(0, new NvMapHandle());
+ newDict.Add(0, new NvMapHandle());
- return NewDict;
+ return newDict;
});
- return Dict.Add(Map);
+ return dict.Add(map);
}
- private static bool DeleteNvMap(ServiceCtx Context, int Handle)
+ private static bool DeleteNvMap(ServiceCtx context, int handle)
{
- if (Maps.TryGetValue(Context.Process, out IdDictionary Dict))
+ if (_maps.TryGetValue(context.Process, out IdDictionary dict))
{
- return Dict.Delete(Handle) != null;
+ return dict.Delete(handle) != null;
}
return false;
}
- public static void InitializeNvMap(ServiceCtx Context)
+ public static void InitializeNvMap(ServiceCtx context)
{
- IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) =>new IdDictionary());
+ IdDictionary dict = _maps.GetOrAdd(context.Process, (key) =>new IdDictionary());
- Dict.Add(0, new NvMapHandle());
+ dict.Add(0, new NvMapHandle());
}
- public static NvMapHandle GetNvMapWithFb(ServiceCtx Context, int Handle)
+ public static NvMapHandle GetNvMapWithFb(ServiceCtx context, int handle)
{
- if (Maps.TryGetValue(Context.Process, out IdDictionary Dict))
+ if (_maps.TryGetValue(context.Process, out IdDictionary dict))
{
- return Dict.GetData<NvMapHandle>(Handle);
+ return dict.GetData<NvMapHandle>(handle);
}
return null;
}
- public static NvMapHandle GetNvMap(ServiceCtx Context, int Handle)
+ public static NvMapHandle GetNvMap(ServiceCtx context, int handle)
{
- if (Handle != 0 && Maps.TryGetValue(Context.Process, out IdDictionary Dict))
+ if (handle != 0 && _maps.TryGetValue(context.Process, out IdDictionary dict))
{
- return Dict.GetData<NvMapHandle>(Handle);
+ return dict.GetData<NvMapHandle>(handle);
}
return null;
}
- public static void UnloadProcess(KProcess Process)
+ public static void UnloadProcess(KProcess process)
{
- Maps.TryRemove(Process, out _);
+ _maps.TryRemove(process, out _);
}
}
} \ No newline at end of file