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, 793 insertions, 788 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index a8459cf4..1b034bfa 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> _commands;
+ private Dictionary<int, ServiceProcessRequest> m_Commands;
- public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
+ public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_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; }
+ public static GlobalStateTable Fds { get; private set; }
- private KEvent _event;
+ private KEvent Event;
- public INvDrvServices(Horizon system)
+ public INvDrvServices(Horizon System)
{
- _commands = new Dictionary<int, ServiceProcessRequest>
+ m_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 0f7e4acd..96f97f41 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; }
+ public string Name { get; private set; }
- public NvFd(string name)
+ public NvFd(string Name)
{
- Name = name;
+ this.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 cd1ab7cd..70275b2a 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; }
+ public NvGpuVmm Vmm { get; private set; }
private class Range
{
- public ulong Start { get; }
- public ulong End { get; }
+ public ulong Start { get; private set; }
+ public ulong End { get; private set; }
- 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; }
- public bool VaAllocated { get; }
+ public long PhysicalAddress { get; private set; }
+ public bool VaAllocated { get; private set; }
public MappedMemory(
- long position,
- long size,
- long physicalAddress,
- bool vaAllocated) : base(position, size)
+ long Position,
+ long Size,
+ long PhysicalAddress,
+ bool VaAllocated) : base(Position, Size)
{
- PhysicalAddress = physicalAddress;
- VaAllocated = vaAllocated;
+ this.PhysicalAddress = PhysicalAddress;
+ this.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 8e128a0d..7fe3bbed 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 5680fb8e..7ee770f4 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 140e8c96..466f3e9b 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
@@ -11,57 +11,62 @@ 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 0x480b: return ZcullBind (context);
- case 0x480c: return SetErrorNotifier (context);
- case 0x4803: return SetTimeout (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 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);
}
- 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.
@@ -69,99 +74,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;
}
}
}
@@ -169,146 +174,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 f13f7a68..bf92afb4 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 aa4577ed..fcb80836 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; }
+ public NvHostSyncpt Syncpt { get; private set; }
- public NvHostEvent[] Events { get; }
+ public NvHostEvent[] Events { get; private set; }
public NvHostCtrlUserCtx()
{
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostSyncPt.cs
index d27f7c53..9ffa93f2 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 31bf8329..e97e4ff4 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()
{
- Size = size;
+ this.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 75a76b91..adc523e5 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