aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary-nyan <mary@mary.zone>2022-12-21 19:23:11 +0100
committerGitHub <noreply@github.com>2022-12-21 18:23:11 +0000
commit479d1fd8b03528b7bbfdd38925475dce54a79f58 (patch)
tree46fd97d8fcbd14fb3b8c72749e4d30b1decb2df0
parentcb70e7bb30e8ecf5bcdd58b976f2ed5ea8cff947 (diff)
hle: Handle GPU profiler and debugger device path correctly (#4138)1.1.484
This fix a warning on "慟哭そして…" by handling correctly the debug mode flag. When debug mode isn't enabled, opening /dev/nvhost-dbg-gpu or /dev/nvhost-prof-gpu should fail with a not implemented error code. This implement this behaviour and also define stubbed interfaces for completness.
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs43
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs11
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostProfGpu/NvHostProfGpuDeviceFile.cs11
-rw-r--r--Ryujinx.HLE/Ryujinx.HLE.csproj4
4 files changed, 52 insertions, 17 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index 9a184226..32b429a6 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
@@ -8,6 +8,8 @@ using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu;
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel;
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl;
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu;
+using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostDbgGpu;
+using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostProfGpu;
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
using Ryujinx.HLE.HOS.Services.Nv.Types;
using Ryujinx.Memory;
@@ -23,7 +25,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv
[Service("nvdrv:t")]
class INvDrvServices : IpcService
{
- private static Dictionary<string, Type> _deviceFileRegistry = new Dictionary<string, Type>()
+ private static readonly List<string> _deviceFileDebugRegistry = new List<string>()
+ {
+ "/dev/nvhost-dbg-gpu",
+ "/dev/nvhost-prof-gpu"
+ };
+
+ private static readonly Dictionary<string, Type> _deviceFileRegistry = new Dictionary<string, Type>()
{
{ "/dev/nvmap", typeof(NvMapDeviceFile) },
{ "/dev/nvhost-ctrl", typeof(NvHostCtrlDeviceFile) },
@@ -35,6 +43,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv
//{ "/dev/nvhost-nvjpg", typeof(NvHostChannelDeviceFile) },
{ "/dev/nvhost-vic", typeof(NvHostChannelDeviceFile) },
//{ "/dev/nvhost-display", typeof(NvHostChannelDeviceFile) },
+ { "/dev/nvhost-dbg-gpu", typeof(NvHostDbgGpuDeviceFile) },
+ { "/dev/nvhost-prof-gpu", typeof(NvHostProfGpuDeviceFile) },
};
public static IdDictionary DeviceFileIdRegistry = new IdDictionary();
@@ -44,13 +54,23 @@ namespace Ryujinx.HLE.HOS.Services.Nv
private bool _transferMemInitialized = false;
+ // TODO: This should call set:sys::GetDebugModeFlag
+ private bool _debugModeEnabled = false;
+
public INvDrvServices(ServiceCtx context) : base(context.Device.System.NvDrvServer)
{
_owner = 0;
}
- private int Open(ServiceCtx context, string path)
+ private NvResult Open(ServiceCtx context, string path, out int fd)
{
+ fd = -1;
+
+ if (!_debugModeEnabled && _deviceFileDebugRegistry.Contains(path))
+ {
+ return NvResult.NotSupported;
+ }
+
if (_deviceFileRegistry.TryGetValue(path, out Type deviceFileClass))
{
ConstructorInfo constructor = deviceFileClass.GetConstructor(new Type[] { typeof(ServiceCtx), typeof(IVirtualMemoryManager), typeof(ulong) });
@@ -59,14 +79,14 @@ namespace Ryujinx.HLE.HOS.Services.Nv
deviceFile.Path = path;
- return DeviceFileIdRegistry.Add(deviceFile);
- }
- else
- {
- Logger.Warning?.Print(LogClass.ServiceNv, $"Cannot find file device \"{path}\"!");
+ fd = DeviceFileIdRegistry.Add(deviceFile);
+
+ return NvResult.Success;
}
- return -1;
+ Logger.Warning?.Print(LogClass.ServiceNv, $"Cannot find file device \"{path}\"!");
+
+ return NvResult.FileOperationFailed;
}
private NvResult GetIoctlArgument(ServiceCtx context, NvIoctl ioctlCommand, out Span<byte> arguments)
@@ -229,12 +249,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
string path = MemoryHelper.ReadAsciiString(context.Memory, pathPtr, (long)pathSize);
- fd = Open(context, path);
-
- if (fd == -1)
- {
- errorCode = NvResult.FileOperationFailed;
- }
+ errorCode = Open(context, path, out fd);
}
context.ResponseData.Write(fd);
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs
new file mode 100644
index 00000000..fe302b98
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostDbgGpu/NvHostDbgGpuDeviceFile.cs
@@ -0,0 +1,11 @@
+using Ryujinx.Memory;
+using System;
+namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostDbgGpu
+{
+ class NvHostDbgGpuDeviceFile : NvDeviceFile
+ {
+ public NvHostDbgGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { }
+
+ public override void Close() { }
+ }
+}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostProfGpu/NvHostProfGpuDeviceFile.cs b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostProfGpu/NvHostProfGpuDeviceFile.cs
new file mode 100644
index 00000000..0a2087ed
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostProfGpu/NvHostProfGpuDeviceFile.cs
@@ -0,0 +1,11 @@
+using Ryujinx.Memory;
+
+namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostProfGpu
+{
+ class NvHostProfGpuDeviceFile : NvDeviceFile
+ {
+ public NvHostProfGpuDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, ulong owner) : base(context, owner) { }
+
+ public override void Close() { }
+ }
+}
diff --git a/Ryujinx.HLE/Ryujinx.HLE.csproj b/Ryujinx.HLE/Ryujinx.HLE.csproj
index 1e814ca9..f1f295a2 100644
--- a/Ryujinx.HLE/Ryujinx.HLE.csproj
+++ b/Ryujinx.HLE/Ryujinx.HLE.csproj
@@ -11,9 +11,7 @@
<ProjectReference Include="..\Ryujinx.Graphics.Host1x\Ryujinx.Graphics.Host1x.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Nvdec\Ryujinx.Graphics.Nvdec.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Vic\Ryujinx.Graphics.Vic.csproj" />
- <ProjectReference Include="..\Ryujinx.Horizon.Generators\Ryujinx.Horizon.Generators.csproj"
- OutputItemType="Analyzer"
- ReferenceOutputAssembly="false" />
+ <ProjectReference Include="..\Ryujinx.Horizon.Generators\Ryujinx.Horizon.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\Ryujinx.Memory\Ryujinx.Memory.csproj" />
<ProjectReference Include="..\ARMeilleure\ARMeilleure.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Gpu\Ryujinx.Graphics.Gpu.csproj" />