Просмотр исходного кода

Code style fixes and nits on the HLE project (#355)

* Some style fixes and nits on ITimeZoneService

* Remove some unneeded usings

* Remove the Ryujinx.HLE.OsHle.Handles namespace

* Remove hbmenu automatic load on process exit

* Rename Ns to Device, rename Os to System, rename SystemState to State

* Move Exceptions and Utilities out of OsHle

* Rename OsHle to HOS

* Rename OsHle folder to HOS

* IManagerDisplayService and ISystemDisplayService style fixes

* BsdError shouldn't be public

* Add a empty new line before using static

* Remove unused file

* Some style fixes on NPDM

* Exit gracefully when the application is closed

* Code style fixes on IGeneralService

* Add 0x prefix on values printed as hex

* Small improvements on finalization code

* Move ProcessId and ThreadId out of AThreadState

* Rename VFs to FileSystem

* FsAccessHeader shouldn't be public. Also fix file names casing

* More case changes on NPDM

* Remove unused files

* Move using to the correct place on NPDM

* Use properties on KernelAccessControlMmio

* Address PR feedback
gdkchan 7 лет назад
Родитель
Сommit
521751795a
100 измененных файлов с 506 добавлено и 507 удалено
  1. 0 2
      ChocolArm64/AThread.cs
  2. 8 8
      ChocolArm64/Memory/AMemory.cs
  3. 5 3
      ChocolArm64/State/AThreadState.cs
  4. 21 0
      ChocolArm64/Translation/AILEmitterCtx.cs
  5. 3 1
      Ryujinx.Audio/IAalOutput.cs
  6. 22 2
      Ryujinx.Audio/OpenAL/OpenALAudioOut.cs
  7. 0 1
      Ryujinx.Graphics/Gal/IGalShader.cs
  8. 0 1
      Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs
  9. 0 1
      Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs
  10. 0 1
      Ryujinx.Graphics/Gal/OpenGL/OGLShaderProgram.cs
  11. 1 3
      Ryujinx.Graphics/Gal/Shader/ShaderDecodeSpecial.cs
  12. 1 1
      Ryujinx.HLE/Exceptions/GuestBrokeExecutionException.cs
  13. 9 9
      Ryujinx.HLE/Exceptions/InvalidNpdmException.cs
  14. 1 1
      Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs
  15. 1 1
      Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
  16. 1 1
      Ryujinx.HLE/Gpu/Texture/TextureReader.cs
  17. 0 2
      Ryujinx.HLE/Gpu/Texture/TextureWriter.cs
  18. 1 1
      Ryujinx.HLE/HOS/Diagnostics/Demangler.cs
  19. 1 1
      Ryujinx.HLE/HOS/ErrorCode.cs
  20. 1 1
      Ryujinx.HLE/HOS/ErrorModule.cs
  21. 3 3
      Ryujinx.HLE/HOS/Font/SharedFontManager.cs
  22. 1 1
      Ryujinx.HLE/HOS/Font/SharedFontType.cs
  23. 1 1
      Ryujinx.HLE/HOS/GlobalStateTable.cs
  24. 1 1
      Ryujinx.HLE/HOS/Homebrew.cs
  25. 30 51
      Ryujinx.HLE/HOS/Horizon.cs
  26. 1 1
      Ryujinx.HLE/HOS/IdDictionary.cs
  27. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcBuffDesc.cs
  28. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcHandleDesc.cs
  29. 2 2
      Ryujinx.HLE/HOS/Ipc/IpcHandler.cs
  30. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcMagic.cs
  31. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcMessage.cs
  32. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcMessageType.cs
  33. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcPtrBuffDesc.cs
  34. 1 1
      Ryujinx.HLE/HOS/Ipc/IpcRecvListBuffDesc.cs
  35. 1 1
      Ryujinx.HLE/HOS/Ipc/ServiceProcessRequest.cs
  36. 13 14
      Ryujinx.HLE/HOS/Kernel/AddressArbiter.cs
  37. 1 1
      Ryujinx.HLE/HOS/Kernel/AddressSpaceType.cs
  38. 1 1
      Ryujinx.HLE/HOS/Kernel/KEvent.cs
  39. 1 1
      Ryujinx.HLE/HOS/Kernel/KMemoryBlock.cs
  40. 1 1
      Ryujinx.HLE/HOS/Kernel/KMemoryInfo.cs
  41. 3 4
      Ryujinx.HLE/HOS/Kernel/KMemoryManager.cs
  42. 1 1
      Ryujinx.HLE/HOS/Kernel/KProcessHandleTable.cs
  43. 11 1
      Ryujinx.HLE/HOS/Kernel/KProcessScheduler.cs
  44. 2 2
      Ryujinx.HLE/HOS/Kernel/KSession.cs
  45. 1 1
      Ryujinx.HLE/HOS/Kernel/KSharedMemory.cs
  46. 1 1
      Ryujinx.HLE/HOS/Kernel/KSynchronizationObject.cs
  47. 5 3
      Ryujinx.HLE/HOS/Kernel/KThread.cs
  48. 1 1
      Ryujinx.HLE/HOS/Kernel/KTlsPageManager.cs
  49. 1 1
      Ryujinx.HLE/HOS/Kernel/KTransferMemory.cs
  50. 1 1
      Ryujinx.HLE/HOS/Kernel/KernelErr.cs
  51. 1 1
      Ryujinx.HLE/HOS/Kernel/MemoryAttribute.cs
  52. 1 1
      Ryujinx.HLE/HOS/Kernel/MemoryPermission.cs
  53. 1 1
      Ryujinx.HLE/HOS/Kernel/MemoryState.cs
  54. 1 1
      Ryujinx.HLE/HOS/Kernel/NsTimeConverter.cs
  55. 1 1
      Ryujinx.HLE/HOS/Kernel/SchedulerThread.cs
  56. 7 8
      Ryujinx.HLE/HOS/Kernel/SvcHandler.cs
  57. 48 49
      Ryujinx.HLE/HOS/Kernel/SvcMemory.cs
  58. 20 21
      Ryujinx.HLE/HOS/Kernel/SvcSystem.cs
  59. 25 26
      Ryujinx.HLE/HOS/Kernel/SvcThread.cs
  60. 45 46
      Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
  61. 1 1
      Ryujinx.HLE/HOS/Kernel/ThreadQueue.cs
  62. 59 78
      Ryujinx.HLE/HOS/Process.cs
  63. 6 6
      Ryujinx.HLE/HOS/ServiceCtx.cs
  64. 1 1
      Ryujinx.HLE/HOS/Services/Acc/AccErr.cs
  65. 12 13
      Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs
  66. 4 4
      Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs
  67. 5 5
      Ryujinx.HLE/HOS/Services/Acc/IProfile.cs
  68. 1 1
      Ryujinx.HLE/HOS/Services/Am/AmErr.cs
  69. 1 1
      Ryujinx.HLE/HOS/Services/Am/FocusState.cs
  70. 2 2
      Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs
  71. 2 2
      Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs
  72. 8 8
      Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs
  73. 2 2
      Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs
  74. 2 2
      Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs
  75. 7 7
      Ryujinx.HLE/HOS/Services/Am/IAudioController.cs
  76. 8 8
      Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs
  77. 2 2
      Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs
  78. 2 2
      Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs
  79. 2 2
      Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs
  80. 5 5
      Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs
  81. 8 8
      Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs
  82. 2 2
      Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs
  83. 19 19
      Ryujinx.HLE/HOS/Services/Am/ISelfController.cs
  84. 2 2
      Ryujinx.HLE/HOS/Services/Am/IStorage.cs
  85. 2 2
      Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs
  86. 2 2
      Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs
  87. 4 4
      Ryujinx.HLE/HOS/Services/Am/IWindowController.cs
  88. 1 1
      Ryujinx.HLE/HOS/Services/Am/MessageInfo.cs
  89. 1 1
      Ryujinx.HLE/HOS/Services/Am/OperationMode.cs
  90. 1 1
      Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs
  91. 2 2
      Ryujinx.HLE/HOS/Services/Apm/IManager.cs
  92. 3 3
      Ryujinx.HLE/HOS/Services/Apm/ISession.cs
  93. 1 1
      Ryujinx.HLE/HOS/Services/Apm/PerformanceConfiguration.cs
  94. 1 1
      Ryujinx.HLE/HOS/Services/Apm/PerformanceMode.cs
  95. 1 1
      Ryujinx.HLE/HOS/Services/Aud/AudErr.cs
  96. 1 1
      Ryujinx.HLE/HOS/Services/Aud/AudioOut/AudioOutData.cs
  97. 3 3
      Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs
  98. 1 1
      Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/AudioConsts.cs
  99. 1 1
      Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/BehaviorIn.cs
  100. 1 1
      Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/BiquadFilter.cs

+ 0 - 2
ChocolArm64/AThread.cs

@@ -18,8 +18,6 @@ namespace ChocolArm64
 
         public event EventHandler WorkFinished;
 
-        public int ThreadId => ThreadState.ThreadId;
-
         private int IsExecuting;
 
         public AThread(ATranslator Translator, AMemory Memory, long EntryPoint)

+ 8 - 8
ChocolArm64/Memory/AMemory.cs

@@ -41,7 +41,7 @@ namespace ChocolArm64.Memory
             }
         }
 
-        private Dictionary<int, ArmMonitor> Monitors;
+        private Dictionary<AThreadState, ArmMonitor> Monitors;
 
         private ConcurrentDictionary<long, IntPtr> ObservedPages;
 
@@ -53,7 +53,7 @@ namespace ChocolArm64.Memory
 
         public AMemory(IntPtr Ram)
         {
-            Monitors = new Dictionary<int, ArmMonitor>();
+            Monitors = new Dictionary<AThreadState, ArmMonitor>();
 
             ObservedPages = new ConcurrentDictionary<long, IntPtr>();
 
@@ -75,7 +75,7 @@ namespace ChocolArm64.Memory
             {
                 ClearExclusive(State);
 
-                Monitors.Remove(State.ThreadId);
+                Monitors.Remove(State);
             }
         }
 
@@ -93,11 +93,11 @@ namespace ChocolArm64.Memory
                     }
                 }
 
-                if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
+                if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
                 {
                     ThreadMon = new ArmMonitor();
 
-                    Monitors.Add(ThreadState.ThreadId, ThreadMon);
+                    Monitors.Add(ThreadState, ThreadMon);
                 }
 
                 ThreadMon.Position = Position;
@@ -113,7 +113,7 @@ namespace ChocolArm64.Memory
 
             Monitor.Enter(Monitors);
 
-            if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
+            if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
             {
                 return false;
             }
@@ -130,7 +130,7 @@ namespace ChocolArm64.Memory
 
         public void ClearExclusiveForStore(AThreadState ThreadState)
         {
-            if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
+            if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
             {
                 ThreadMon.ExState = false;
             }
@@ -142,7 +142,7 @@ namespace ChocolArm64.Memory
         {
             lock (Monitors)
             {
-                if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
+                if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
                 {
                     ThreadMon.ExState = false;
                 }

+ 5 - 3
ChocolArm64/State/AThreadState.cs

@@ -40,9 +40,6 @@ namespace ChocolArm64.State
         public bool Zero;
         public bool Negative;
 
-        public int ProcessId;
-        public int ThreadId;
-
         public bool Running { get; set; }
 
         public long TpidrEl0 { get; set; }
@@ -100,6 +97,11 @@ namespace ChocolArm64.State
             TickCounter.Start();
         }
 
+        internal bool Synchronize()
+        {
+            return Running;
+        }
+
         internal void OnBreak(long Position, int Imm)
         {
             Break?.Invoke(this, new AInstExceptionEventArgs(Position, Imm));

+ 21 - 0
ChocolArm64/Translation/AILEmitterCtx.cs

@@ -110,6 +110,8 @@ namespace ChocolArm64.Translation
             if (OpcIndex == 0)
             {
                 MarkLabel(GetLabel(CurrBlock.Position));
+
+                EmitSynchronization();
             }
 
             CurrOp.Emitter(this);
@@ -117,6 +119,25 @@ namespace ChocolArm64.Translation
             ILBlock.Add(new AILBarrier());
         }
 
+        private void EmitSynchronization()
+        {
+            EmitLdarg(ATranslatedSub.StateArgIdx);
+
+            EmitPrivateCall(typeof(AThreadState), nameof(AThreadState.Synchronize));
+
+            EmitLdc_I4(0);
+
+            AILLabel LblContinue = new AILLabel();
+
+            Emit(OpCodes.Bne_Un_S, LblContinue);
+
+            EmitLdc_I8(0);
+
+            Emit(OpCodes.Ret);
+
+            MarkLabel(LblContinue);
+        }
+
         public bool TryOptEmitSubroutineCall()
         {
             if (CurrBlock.Next == null)

+ 3 - 1
Ryujinx.Audio/IAalOutput.cs

@@ -1,6 +1,8 @@
+using System;
+
 namespace Ryujinx.Audio
 {
-    public interface IAalOutput
+    public interface IAalOutput : IDisposable
     {
         int OpenTrack(int SampleRate, int Channels, ReleaseCallback Callback);
 

+ 22 - 2
Ryujinx.Audio/OpenAL/OpenALAudioOut.cs

@@ -8,7 +8,7 @@ using System.Threading;
 
 namespace Ryujinx.Audio.OpenAL
 {
-    public class OpenALAudioOut : IAalOutput
+    public class OpenALAudioOut : IAalOutput, IDisposable
     {
         private const int MaxTracks = 256;
 
@@ -222,10 +222,17 @@ namespace Ryujinx.Audio.OpenAL
                     Td.CallReleaseCallbackIfNeeded();
                 }
 
-                //If it's not slept it will waste cycles
+                //If it's not slept it will waste cycles.
                 Thread.Sleep(10);
             }
             while (KeepPolling);
+
+            foreach (Track Td in Tracks.Values)
+            {
+                Td.Dispose();
+            }
+
+            Tracks.Clear();
         }
 
         public int OpenTrack(int SampleRate, int Channels, ReleaseCallback Callback)
@@ -342,5 +349,18 @@ namespace Ryujinx.Audio.OpenAL
 
             return PlaybackState.Stopped;
         }
+
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+
+        protected virtual void Dispose(bool Disposing)
+        {
+            if (Disposing)
+            {
+                KeepPolling = false;
+            }
+        }
     }
 }

+ 0 - 1
Ryujinx.Graphics/Gal/IGalShader.cs

@@ -1,4 +1,3 @@
-using System;
 using System.Collections.Generic;
 
 namespace Ryujinx.Graphics.Gal

+ 0 - 1
Ryujinx.Graphics/Gal/OpenGL/OGLFrameBuffer.cs

@@ -1,4 +1,3 @@
-using OpenTK;
 using OpenTK.Graphics.OpenGL;
 using System;
 using System.Collections.Generic;

+ 0 - 1
Ryujinx.Graphics/Gal/OpenGL/OGLRasterizer.cs

@@ -1,6 +1,5 @@
 using OpenTK.Graphics.OpenGL;
 using System;
-using System.Collections.Generic;
 
 namespace Ryujinx.Graphics.Gal.OpenGL
 {

+ 0 - 1
Ryujinx.Graphics/Gal/OpenGL/OGLShaderProgram.cs

@@ -1,7 +1,6 @@
 using OpenTK.Graphics.OpenGL;
 using System;
 using System.Collections.Generic;
-using System.Linq;
 
 namespace Ryujinx.Graphics.Gal.OpenGL
 {

+ 1 - 3
Ryujinx.Graphics/Gal/Shader/ShaderDecodeSpecial.cs

@@ -1,6 +1,4 @@
-using System;
-
-using static Ryujinx.Graphics.Gal.Shader.ShaderDecodeHelper;
+using static Ryujinx.Graphics.Gal.Shader.ShaderDecodeHelper;
 
 namespace Ryujinx.Graphics.Gal.Shader
 {

+ 1 - 1
Ryujinx.HLE/OsHle/Exceptions/GuestBrokeExecutionException.cs → Ryujinx.HLE/Exceptions/GuestBrokeExecutionException.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle.Exceptions
+namespace Ryujinx.HLE.Exceptions
 {
     public class GuestBrokeExecutionException : Exception
     {

+ 9 - 9
Ryujinx.HLE/Loaders/Npdm/NpdmException.cs → Ryujinx.HLE/Exceptions/InvalidNpdmException.cs

@@ -1,9 +1,9 @@
-using System;
-
-namespace Ryujinx.HLE.Loaders.Npdm
-{
-    public class InvalidNpdmException : Exception
-    {
-        public InvalidNpdmException(string ExMsg) : base(ExMsg) { }
-    }
-}
+using System;
+
+namespace Ryujinx.HLE.Exceptions
+{
+    public class InvalidNpdmException : Exception
+    {
+        public InvalidNpdmException(string ExMsg) : base(ExMsg) { }
+    }
+}

+ 1 - 1
Ryujinx.HLE/OsHle/Exceptions/UndefinedInstructionException.cs → Ryujinx.HLE/Exceptions/UndefinedInstructionException.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle.Exceptions
+namespace Ryujinx.HLE.Exceptions
 {
     public class UndefinedInstructionException : Exception
     {

+ 1 - 1
Ryujinx.HLE/Gpu/Texture/TextureHelper.cs

@@ -140,7 +140,7 @@ namespace Ryujinx.HLE.Gpu.Texture
                 }
             }
 
-            throw new NotImplementedException(Texture.Format.ToString());
+            throw new NotImplementedException("0x" + Texture.Format.ToString("x2"));
         }
 
         public static int CompressedTextureSize(int TextureWidth, int TextureHeight, int BlockWidth, int BlockHeight, int Bpb)

+ 1 - 1
Ryujinx.HLE/Gpu/Texture/TextureReader.cs

@@ -47,7 +47,7 @@ namespace Ryujinx.HLE.Gpu.Texture
                 case GalTextureFormat.Astc2D10x6:   return Read16BptCompressedTexture(Memory, Texture, 10, 6);
              }
 
-            throw new NotImplementedException(Texture.Format.ToString());
+            throw new NotImplementedException("0x" + Texture.Format.ToString("x2"));
         }
 
         private unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture)

+ 0 - 2
Ryujinx.HLE/Gpu/Texture/TextureWriter.cs

@@ -1,6 +1,4 @@
 using ChocolArm64.Memory;
-using Ryujinx.Graphics.Gal;
-using System;
 
 namespace Ryujinx.HLE.Gpu.Texture
 {

+ 1 - 1
Ryujinx.HLE/OsHle/Diagnostics/Demangler.cs → Ryujinx.HLE/HOS/Diagnostics/Demangler.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 
-namespace Ryujinx.HLE.OsHle.Diagnostics
+namespace Ryujinx.HLE.HOS.Diagnostics
 {
     static class Demangler
     {

+ 1 - 1
Ryujinx.HLE/OsHle/ErrorCode.cs → Ryujinx.HLE/HOS/ErrorCode.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     static class ErrorCode
     {

+ 1 - 1
Ryujinx.HLE/OsHle/ErrorModule.cs → Ryujinx.HLE/HOS/ErrorModule.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     enum ErrorModule
     {

+ 3 - 3
Ryujinx.HLE/OsHle/Font/SharedFontManager.cs → Ryujinx.HLE/HOS/Font/SharedFontManager.cs

@@ -1,10 +1,10 @@
 using Ryujinx.HLE.Memory;
-using Ryujinx.HLE.OsHle.Utilities;
 using Ryujinx.HLE.Resource;
+using Ryujinx.HLE.Utilities;
 using System.Collections.Generic;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Font
+namespace Ryujinx.HLE.HOS.Font
 {
     class SharedFontManager
     {
@@ -34,7 +34,7 @@ namespace Ryujinx.HLE.OsHle.Font
 
             Memory = Device.Memory;
 
-            FontsPath = Path.Combine(Device.VFs.GetSystemPath(), "fonts");
+            FontsPath = Path.Combine(Device.FileSystem.GetSystemPath(), "fonts");
         }
 
         public void EnsureInitialized()

+ 1 - 1
Ryujinx.HLE/OsHle/Font/SharedFontType.cs → Ryujinx.HLE/HOS/Font/SharedFontType.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Font
+namespace Ryujinx.HLE.HOS.Font
 {
     public enum SharedFontType
     {

+ 1 - 1
Ryujinx.HLE/OsHle/GlobalStateTable.cs → Ryujinx.HLE/HOS/GlobalStateTable.cs

@@ -1,7 +1,7 @@
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     class GlobalStateTable
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Homebrew.cs → Ryujinx.HLE/HOS/Homebrew.cs

@@ -1,7 +1,7 @@
 using ChocolArm64.Memory;
 using System.Text;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     static class Homebrew
     {

+ 30 - 51
Ryujinx.HLE/OsHle/Horizon.cs → Ryujinx.HLE/HOS/Horizon.cs

@@ -1,27 +1,27 @@
+using Ryujinx.HLE.HOS.Font;
+using Ryujinx.HLE.HOS.Kernel;
+using Ryujinx.HLE.HOS.SystemState;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.HLE.Loaders.Npdm;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Font;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.SystemState;
 using System;
 using System.Collections.Concurrent;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     public class Horizon : IDisposable
     {
         internal const int HidSize  = 0x40000;
         internal const int FontSize = 0x1100000;
 
-        private Switch Ns;
+        private Switch Device;
 
         private KProcessScheduler Scheduler;
 
         private ConcurrentDictionary<int, Process> Processes;
 
-        public SystemStateMgr SystemState { get; private set; }
+        public SystemStateMgr State { get; private set; }
 
         internal KSharedMemory HidSharedMem  { get; private set; }
         internal KSharedMemory FontSharedMem { get; private set; }
@@ -30,18 +30,18 @@ namespace Ryujinx.HLE.OsHle
 
         internal KEvent VsyncEvent { get; private set; }
 
-        public Horizon(Switch Ns)
+        public Horizon(Switch Device)
         {
-            this.Ns = Ns;
+            this.Device = Device;
 
-            Scheduler = new KProcessScheduler(Ns.Log);
+            Scheduler = new KProcessScheduler(Device.Log);
 
             Processes = new ConcurrentDictionary<int, Process>();
 
-            SystemState = new SystemStateMgr();
+            State = new SystemStateMgr();
 
-            if (!Ns.Memory.Allocator.TryAllocate(HidSize,  out long HidPA) ||
-                !Ns.Memory.Allocator.TryAllocate(FontSize, out long FontPA))
+            if (!Device.Memory.Allocator.TryAllocate(HidSize,  out long HidPA) ||
+                !Device.Memory.Allocator.TryAllocate(FontSize, out long FontPA))
             {
                 throw new InvalidOperationException();
             }
@@ -49,7 +49,7 @@ namespace Ryujinx.HLE.OsHle
             HidSharedMem  = new KSharedMemory(HidPA, HidSize);
             FontSharedMem = new KSharedMemory(FontPA, FontSize);
 
-            Font = new SharedFontManager(Ns, FontSharedMem.PA);
+            Font = new SharedFontManager(Device, FontSharedMem.PA);
 
             VsyncEvent = new KEvent();
         }
@@ -58,7 +58,7 @@ namespace Ryujinx.HLE.OsHle
         {
             if (RomFsFile != null)
             {
-                Ns.VFs.LoadRomFs(RomFsFile);
+                Device.FileSystem.LoadRomFs(RomFsFile);
             }
 
             string NpdmFileName = Path.Combine(ExeFsDir, "main.npdm");
@@ -67,7 +67,7 @@ namespace Ryujinx.HLE.OsHle
 
             if (File.Exists(NpdmFileName))
             {
-                Ns.Log.PrintInfo(LogClass.Loader, $"Loading main.npdm...");
+                Device.Log.PrintInfo(LogClass.Loader, $"Loading main.npdm...");
 
                 using (FileStream Input = new FileStream(NpdmFileName, FileMode.Open))
                 {
@@ -76,7 +76,7 @@ namespace Ryujinx.HLE.OsHle
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.Loader, $"NPDM file not found, using default values!");
+                Device.Log.PrintWarning(LogClass.Loader, $"NPDM file not found, using default values!");
             }
 
             Process MainProcess = MakeProcess(MetaData);
@@ -90,7 +90,7 @@ namespace Ryujinx.HLE.OsHle
                         continue;
                     }
 
-                    Ns.Log.PrintInfo(LogClass.Loader, $"Loading {Path.GetFileNameWithoutExtension(File)}...");
+                    Device.Log.PrintInfo(LogClass.Loader, $"Loading {Path.GetFileNameWithoutExtension(File)}...");
 
                     using (FileStream Input = new FileStream(File, FileMode.Open))
                     {
@@ -124,18 +124,20 @@ namespace Ryujinx.HLE.OsHle
             bool IsNro = Path.GetExtension(FilePath).ToLower() == ".nro";
 
             string Name = Path.GetFileNameWithoutExtension(FilePath);
-            string SwitchFilePath = Ns.VFs.SystemPathToSwitchPath(FilePath);
+            string SwitchFilePath = Device.FileSystem.SystemPathToSwitchPath(FilePath);
 
             if (IsNro && (SwitchFilePath == null || !SwitchFilePath.StartsWith("sdmc:/")))
             {
                 string SwitchPath = $"sdmc:/switch/{Name}{Homebrew.TemporaryNroSuffix}";
-                string TempPath = Ns.VFs.SwitchPathToSystemPath(SwitchPath);
+                string TempPath = Device.FileSystem.SwitchPathToSystemPath(SwitchPath);
 
                 string SwitchDir = Path.GetDirectoryName(TempPath);
+
                 if (!Directory.Exists(SwitchDir))
                 {
                     Directory.CreateDirectory(SwitchDir);
                 }
+
                 File.Copy(FilePath, TempPath, true);
 
                 FilePath = TempPath;
@@ -169,7 +171,7 @@ namespace Ryujinx.HLE.OsHle
                     ProcessId++;
                 }
 
-                Process = new Process(Ns, Scheduler, ProcessId, MetaData);
+                Process = new Process(Device, Scheduler, ProcessId, MetaData);
 
                 Processes.TryAdd(ProcessId, Process);
             }
@@ -186,42 +188,24 @@ namespace Ryujinx.HLE.OsHle
 
         internal void ExitProcess(int ProcessId)
         {
-            if (Processes.TryGetValue(ProcessId, out Process Process) && Process.NeedsHbAbi)
-            {
-                string NextNro = Homebrew.ReadHbAbiNextLoadPath(Process.Memory, Process.HbAbiDataPosition);
-
-                Ns.Log.PrintInfo(LogClass.Loader, $"HbAbi NextLoadPath {NextNro}");
-
-                if (NextNro == string.Empty)
-                {
-                    NextNro = "sdmc:/hbmenu.nro";
-                }
-
-                NextNro = NextNro.Replace("sdmc:", string.Empty);
-
-                NextNro = Ns.VFs.GetFullPath(Ns.VFs.GetSdCardPath(), NextNro);
-
-                if (File.Exists(NextNro))
-                {
-                    LoadProgram(NextNro);
-                }
-            }
-
-            if (Processes.TryRemove(ProcessId, out Process))
+            if (Processes.TryRemove(ProcessId, out Process Process))
             {
-                Process.StopAllThreadsAsync();
                 Process.Dispose();
 
                 if (Processes.Count == 0)
                 {
-                    Ns.OnFinish(EventArgs.Empty);
+                    Unload();
+
+                    Device.Unload();
                 }
             }
         }
 
-        internal bool TryGetProcess(int ProcessId, out Process Process)
+        private void Unload()
         {
-            return Processes.TryGetValue(ProcessId, out Process);
+            VsyncEvent.Dispose();
+
+            Scheduler.Dispose();
         }
 
         public void Dispose()
@@ -235,13 +219,8 @@ namespace Ryujinx.HLE.OsHle
             {
                 foreach (Process Process in Processes.Values)
                 {
-                    Process.StopAllThreadsAsync();
                     Process.Dispose();
                 }
-
-                VsyncEvent.Dispose();
-
-                Scheduler.Dispose();
             }
         }
     }

+ 1 - 1
Ryujinx.HLE/OsHle/IdDictionary.cs → Ryujinx.HLE/HOS/IdDictionary.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     class IdDictionary
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcBuffDesc.cs → Ryujinx.HLE/HOS/Ipc/IpcBuffDesc.cs

@@ -1,6 +1,6 @@
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     struct IpcBuffDesc
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcHandleDesc.cs → Ryujinx.HLE/HOS/Ipc/IpcHandleDesc.cs

@@ -1,7 +1,7 @@
 using System;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     class IpcHandleDesc
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Ipc/IpcHandler.cs → Ryujinx.HLE/HOS/Ipc/IpcHandler.cs

@@ -1,9 +1,9 @@
 using ChocolArm64.Memory;
-using Ryujinx.HLE.OsHle.Handles;
+using Ryujinx.HLE.HOS.Kernel;
 using System;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     static class IpcHandler
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcMagic.cs → Ryujinx.HLE/HOS/Ipc/IpcMagic.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     abstract class IpcMagic
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcMessage.cs → Ryujinx.HLE/HOS/Ipc/IpcMessage.cs

@@ -1,7 +1,7 @@
 using System.Collections.Generic;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     class IpcMessage
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcMessageType.cs → Ryujinx.HLE/HOS/Ipc/IpcMessageType.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     enum IpcMessageType
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcPtrBuffDesc.cs → Ryujinx.HLE/HOS/Ipc/IpcPtrBuffDesc.cs

@@ -1,6 +1,6 @@
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     struct IpcPtrBuffDesc
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/IpcRecvListBuffDesc.cs → Ryujinx.HLE/HOS/Ipc/IpcRecvListBuffDesc.cs

@@ -1,6 +1,6 @@
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     struct IpcRecvListBuffDesc
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Ipc/ServiceProcessRequest.cs → Ryujinx.HLE/HOS/Ipc/ServiceProcessRequest.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Ipc
+namespace Ryujinx.HLE.HOS.Ipc
 {
     delegate long ServiceProcessRequest(ServiceCtx Context);
 }

+ 13 - 14
Ryujinx.HLE/OsHle/Kernel/AddressArbiter.cs → Ryujinx.HLE/HOS/Kernel/AddressArbiter.cs

@@ -1,10 +1,9 @@
 using ChocolArm64.Memory;
 using ChocolArm64.State;
-using Ryujinx.HLE.OsHle.Handles;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     static class AddressArbiter
     {
@@ -27,12 +26,12 @@ namespace Ryujinx.HLE.OsHle.Kernel
             return 0;
         }
 
-        public static ulong WaitForAddressIfLessThan(Process      Process, 
-                                                     AThreadState ThreadState, 
-                                                     AMemory      Memory, 
-                                                     long         Address, 
-                                                     int          Value, 
-                                                     ulong        Timeout, 
+        public static ulong WaitForAddressIfLessThan(Process      Process,
+                                                     AThreadState ThreadState,
+                                                     AMemory      Memory,
+                                                     long         Address,
+                                                     int          Value,
+                                                     ulong        Timeout,
                                                      bool         ShouldDecrement)
         {
             Memory.SetExclusive(ThreadState, Address);
@@ -75,11 +74,11 @@ namespace Ryujinx.HLE.OsHle.Kernel
             return WaitForAddress(Process, ThreadState, Address, Timeout);
         }
 
-        public static ulong WaitForAddressIfEqual(Process      Process, 
-                                                  AThreadState ThreadState, 
-                                                  AMemory      Memory, 
-                                                  long         Address, 
-                                                  int          Value, 
+        public static ulong WaitForAddressIfEqual(Process      Process,
+                                                  AThreadState ThreadState,
+                                                  AMemory      Memory,
+                                                  long         Address,
+                                                  int          Value,
                                                   ulong        Timeout)
         {
             if (Memory.ReadInt32(Address) != Value)

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/AddressSpaceType.cs → Ryujinx.HLE/HOS/Kernel/AddressSpaceType.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     enum AddressSpaceType
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KEvent.cs → Ryujinx.HLE/HOS/Kernel/KEvent.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KEvent : KSynchronizationObject { }
 }

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KMemoryBlock.cs → Ryujinx.HLE/HOS/Kernel/KMemoryBlock.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KMemoryBlock
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KMemoryInfo.cs → Ryujinx.HLE/HOS/Kernel/KMemoryInfo.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KMemoryInfo
     {

+ 3 - 4
Ryujinx.HLE/OsHle/Handles/KMemoryManager.cs → Ryujinx.HLE/HOS/Kernel/KMemoryManager.cs

@@ -1,12 +1,11 @@
 using ChocolArm64.Memory;
 using Ryujinx.HLE.Memory;
-using Ryujinx.HLE.OsHle.Kernel;
 using System;
 using System.Collections.Generic;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KMemoryManager
     {
@@ -43,7 +42,7 @@ namespace Ryujinx.HLE.OsHle.Handles
         public KMemoryManager(Process Process)
         {
             CpuMemory = Process.Memory;
-            Allocator = Process.Ns.Memory.Allocator;
+            Allocator = Process.Device.Memory.Allocator;
 
             long CodeRegionSize;
             long MapRegionSize;

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KProcessHandleTable.cs → Ryujinx.HLE/HOS/Kernel/KProcessHandleTable.cs

@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KProcessHandleTable
     {

+ 11 - 1
Ryujinx.HLE/OsHle/Handles/KProcessScheduler.cs → Ryujinx.HLE/HOS/Kernel/KProcessScheduler.cs

@@ -3,7 +3,7 @@ using System;
 using System.Collections.Concurrent;
 using System.Threading;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KProcessScheduler : IDisposable
     {
@@ -124,6 +124,16 @@ namespace Ryujinx.HLE.OsHle.Handles
             AllThreads[Thread].WaitSync.Set();
         }
 
+        public void ForceWakeUp(KThread Thread)
+        {
+            if (AllThreads.TryGetValue(Thread, out SchedulerThread SchedThread))
+            {
+                SchedThread.WaitSync.Set();
+                SchedThread.WaitActivity.Set();
+                SchedThread.WaitSched.Set();
+            }
+        }
+
         public void ChangeCore(KThread Thread, int IdealCore, int CoreMask)
         {
             lock (SchedLock)

+ 2 - 2
Ryujinx.HLE/OsHle/Handles/KSession.cs → Ryujinx.HLE/HOS/Kernel/KSession.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Services;
+using Ryujinx.HLE.HOS.Services;
 using System;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KSession : IDisposable
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KSharedMemory.cs → Ryujinx.HLE/HOS/Kernel/KSharedMemory.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KSharedMemory
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KSynchronizationObject.cs → Ryujinx.HLE/HOS/Kernel/KSynchronizationObject.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Threading;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KSynchronizationObject : IDisposable
     {

+ 5 - 3
Ryujinx.HLE/OsHle/Handles/KThread.cs → Ryujinx.HLE/HOS/Kernel/KThread.cs

@@ -1,7 +1,7 @@
 using ChocolArm64;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KThread : KSynchronizationObject
     {
@@ -33,18 +33,20 @@ namespace Ryujinx.HLE.OsHle.Handles
 
         public long LastPc { get; set; }
 
-        public int ThreadId => Thread.ThreadId;
+        public int ThreadId { get; private set; }
 
         public KThread(
             AThread Thread,
             Process Process,
             int     ProcessorId,
-            int     Priority)
+            int     Priority,
+            int     ThreadId)
         {
             this.Thread      = Thread;
             this.Process     = Process;
             this.ProcessorId = ProcessorId;
             this.IdealCore   = ProcessorId;
+            this.ThreadId    = ThreadId;
 
             MutexWaiters = new List<KThread>();
 

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KTlsPageManager.cs → Ryujinx.HLE/HOS/Kernel/KTlsPageManager.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KTlsPageManager
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/KTransferMemory.cs → Ryujinx.HLE/HOS/Kernel/KTransferMemory.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class KTransferMemory
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Kernel/KernelErr.cs → Ryujinx.HLE/HOS/Kernel/KernelErr.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     static class KernelErr
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/MemoryAttribute.cs → Ryujinx.HLE/HOS/Kernel/MemoryAttribute.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     [Flags]
     enum MemoryAttribute  : byte

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/MemoryPermission.cs → Ryujinx.HLE/HOS/Kernel/MemoryPermission.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     [Flags]
     enum MemoryPermission : byte

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/MemoryState.cs → Ryujinx.HLE/HOS/Kernel/MemoryState.cs

@@ -1,6 +1,6 @@
 using System;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS.Kernel
 {
     [Flags]
     enum MemoryState : uint

+ 1 - 1
Ryujinx.HLE/OsHle/Kernel/NsTimeConverter.cs → Ryujinx.HLE/HOS/Kernel/NsTimeConverter.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     static class NsTimeConverter
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/SchedulerThread.cs → Ryujinx.HLE/HOS/Kernel/SchedulerThread.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Threading;
 
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class SchedulerThread : IDisposable
     {

+ 7 - 8
Ryujinx.HLE/OsHle/Kernel/SvcHandler.cs → Ryujinx.HLE/HOS/Kernel/SvcHandler.cs

@@ -2,13 +2,12 @@ using ChocolArm64.Events;
 using ChocolArm64.Memory;
 using ChocolArm64.State;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Threading;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     partial class SvcHandler
     {
@@ -16,7 +15,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
         private Dictionary<int, SvcFunc> SvcFuncs;
 
-        private Switch  Ns;
+        private Switch  Device;
         private Process Process;
         private AMemory Memory;
 
@@ -27,7 +26,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
         private static Random Rng;
 
-        public SvcHandler(Switch Ns, Process Process)
+        public SvcHandler(Switch Device, Process Process)
         {
             SvcFuncs = new Dictionary<int, SvcFunc>()
             {
@@ -73,7 +72,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 { 0x34, SvcWaitForAddress                }
             };
 
-            this.Ns      = Ns;
+            this.Device  = Device;
             this.Process = Process;
             this.Memory  = Process.Memory;
 
@@ -93,19 +92,19 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (SvcFuncs.TryGetValue(e.Id, out SvcFunc Func))
             {
-                Ns.Log.PrintDebug(LogClass.KernelSvc, $"{Func.Method.Name} called.");
+                Device.Log.PrintDebug(LogClass.KernelSvc, $"{Func.Method.Name} called.");
 
                 Func(ThreadState);
 
                 Process.Scheduler.Reschedule(Process.GetThread(ThreadState.Tpidr));
 
-                Ns.Log.PrintDebug(LogClass.KernelSvc, $"{Func.Method.Name} ended.");
+                Device.Log.PrintDebug(LogClass.KernelSvc, $"{Func.Method.Name} ended.");
             }
             else
             {
                 Process.PrintStackTrace(ThreadState);
 
-                throw new NotImplementedException(e.Id.ToString("x4"));
+                throw new NotImplementedException($"0x{e.Id:x4}");
             }
         }
 

+ 48 - 49
Ryujinx.HLE/OsHle/Kernel/SvcMemory.cs → Ryujinx.HLE/HOS/Kernel/SvcMemory.cs

@@ -1,10 +1,9 @@
 using ChocolArm64.State;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     partial class SvcHandler
     {
@@ -14,7 +13,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((Size & 0x1fffff) != 0 || Size != (uint)Size)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Heap size 0x{Size:x16} is not aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Heap size 0x{Size:x16} is not aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -31,7 +30,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
         }
 
@@ -42,7 +41,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -51,7 +50,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -66,7 +65,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             if (Attributes != AttributeMask ||
                (Attributes | MemoryAttribute.Uncached) != MemoryAttribute.Uncached)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, "Invalid memory attributes!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, "Invalid memory attributes!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidMaskValue);
 
@@ -81,7 +80,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
             else
             {
@@ -99,7 +98,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Src | Dst))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, "Addresses are not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, "Addresses are not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -108,7 +107,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -117,7 +116,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Src + Size) <= (ulong)Src || (ulong)(Dst + Size) <= (ulong)Dst)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, "Addresses outside of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, "Addresses outside of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -126,7 +125,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Src, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Src address 0x{Src:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Src address 0x{Src:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -135,7 +134,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideNewMapRegion(Dst, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Dst address 0x{Dst:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Dst address 0x{Dst:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidMemRange);
 
@@ -146,7 +145,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;
@@ -160,7 +159,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Src | Dst))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, "Addresses are not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, "Addresses are not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -169,7 +168,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -178,7 +177,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Src + Size) <= (ulong)Src || (ulong)(Dst + Size) <= (ulong)Dst)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, "Addresses outside of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, "Addresses outside of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -187,7 +186,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Src, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Src address 0x{Src:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Src address 0x{Src:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -196,7 +195,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideNewMapRegion(Dst, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Dst address 0x{Dst:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Dst address 0x{Dst:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidMemRange);
 
@@ -207,7 +206,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;
@@ -241,7 +240,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -250,7 +249,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -259,7 +258,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Position + Size) <= (ulong)Position)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -270,7 +269,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((Permission | MemoryPermission.Write) != MemoryPermission.ReadAndWrite)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid permission {Permission}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid permission {Permission}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidPermission);
 
@@ -281,7 +280,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (SharedMemory == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid shared memory handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid shared memory handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -290,7 +289,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Position, Size) || InsideMapRegion(Position, Size) || InsideHeapRegion(Position, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -299,7 +298,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (SharedMemory.Size != Size)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} does not match shared memory size 0x{SharedMemory.Size:16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} does not match shared memory size 0x{SharedMemory.Size:16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -310,7 +309,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;
@@ -324,7 +323,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -333,7 +332,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -342,7 +341,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Position + Size) <= (ulong)Position)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -353,7 +352,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (SharedMemory == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid shared memory handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid shared memory handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -362,7 +361,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Position, Size) || InsideMapRegion(Position, Size) || InsideHeapRegion(Position, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} out of range!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} out of range!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -373,7 +372,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;
@@ -386,7 +385,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -395,7 +394,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -404,7 +403,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Position + Size) <= (ulong)Position)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -415,7 +414,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Permission > MemoryPermission.ReadAndWrite || Permission == MemoryPermission.Write)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid permission {Permission}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid permission {Permission}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidPermission);
 
@@ -439,7 +438,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -448,7 +447,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -457,7 +456,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Position + Size) <= (ulong)Position)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -466,7 +465,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Position, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address {Position:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address {Position:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -477,7 +476,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;
@@ -490,7 +489,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Position))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Address 0x{Position:x16} is not page aligned!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -499,7 +498,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!PageAligned(Size) || Size == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Size 0x{Size:x16} is not page aligned or is zero!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidSize);
 
@@ -508,7 +507,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((ulong)(Position + Size) <= (ulong)Position)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid region address 0x{Position:x16} / size 0x{Size:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -517,7 +516,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (!InsideAddrSpace(Position, Size))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address {Position:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address {Position:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
@@ -528,7 +527,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Result != 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Operation failed with error 0x{Result:x}!");
             }
 
             ThreadState.X0 = (ulong)Result;

+ 20 - 21
Ryujinx.HLE/OsHle/Kernel/SvcSystem.cs → Ryujinx.HLE/HOS/Kernel/SvcSystem.cs

@@ -1,16 +1,15 @@
 using ChocolArm64.Memory;
 using ChocolArm64.State;
+using Ryujinx.HLE.Exceptions;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Services;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Exceptions;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
-using Ryujinx.HLE.OsHle.Services;
 using System;
 using System.Threading;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     partial class SvcHandler
     {
@@ -20,7 +19,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
         private void SvcExitProcess(AThreadState ThreadState)
         {
-            Ns.Os.ExitProcess(ThreadState.ProcessId);
+            Device.System.ExitProcess(Process.ProcessId);
         }
 
         private void SvcClearEvent(AThreadState ThreadState)
@@ -40,7 +39,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Obj == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -75,7 +74,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid event handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid event handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -87,10 +86,10 @@ namespace Ryujinx.HLE.OsHle.Kernel
             int   HandlesCount =  (int)ThreadState.X2;
             ulong Timeout      =       ThreadState.X3;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "HandlesPtr = "   + HandlesPtr  .ToString("x16") + ", " +
-                "HandlesCount = " + HandlesCount.ToString("x8")  + ", " +
-                "Timeout = "      + Timeout     .ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "HandlesPtr = 0x"   + HandlesPtr  .ToString("x16") + ", " +
+                "HandlesCount = 0x" + HandlesCount.ToString("x8")  + ", " +
+                "Timeout = 0x"      + Timeout     .ToString("x16"));
 
             if ((uint)HandlesCount > 0x40)
             {
@@ -111,7 +110,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
                 if (SyncObj == null)
                 {
-                    Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid handle 0x{Handle:x8}!");
+                    Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid handle 0x{Handle:x8}!");
 
                     ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -175,7 +174,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Thread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{ThreadHandle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{ThreadHandle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -240,7 +239,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
                 IpcMessage Cmd = new IpcMessage(CmdData, CmdPtr);
 
-                long Result = IpcHandler.IpcCall(Ns, Process, Memory, Session, Cmd, CmdPtr);
+                long Result = IpcHandler.IpcCall(Device, Process, Memory, Session, Cmd, CmdPtr);
 
                 Thread.Yield();
 
@@ -250,7 +249,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid session handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid session handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -274,7 +273,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             string Str = AMemoryHelper.ReadAsciiString(Memory, Position, Size);
 
-            Ns.Log.PrintWarning(LogClass.KernelSvc, Str);
+            Device.Log.PrintWarning(LogClass.KernelSvc, Str);
 
             ThreadState.X0 = 0;
         }
@@ -321,11 +320,11 @@ namespace Ryujinx.HLE.OsHle.Kernel
                     break;
 
                 case 6:
-                    ThreadState.X1 = (ulong)Process.Ns.Memory.Allocator.TotalAvailableSize;
+                    ThreadState.X1 = (ulong)Process.Device.Memory.Allocator.TotalAvailableSize;
                     break;
 
                 case 7:
-                    ThreadState.X1 = (ulong)Process.Ns.Memory.Allocator.TotalUsedSize;
+                    ThreadState.X1 = (ulong)Process.Device.Memory.Allocator.TotalUsedSize;
                     break;
 
                 case 8:
@@ -365,7 +364,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 default:
                     Process.PrintStackTrace(ThreadState);
 
-                    throw new NotImplementedException($"SvcGetInfo: {InfoType} {Handle:x8} {InfoId}");
+                    throw new NotImplementedException($"SvcGetInfo: {InfoType} 0x{Handle:x8} {InfoId}");
             }
 
             ThreadState.X0 = 0;

+ 25 - 26
Ryujinx.HLE/OsHle/Kernel/SvcThread.cs → Ryujinx.HLE/HOS/Kernel/SvcThread.cs

@@ -1,11 +1,10 @@
 using ChocolArm64.State;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
 using System.Threading;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     partial class SvcHandler
     {
@@ -19,7 +18,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if ((uint)Priority > 0x3f)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid priority 0x{Priority:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid priority 0x{Priority:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidPriority);
 
@@ -33,7 +32,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else if ((uint)ProcessorId > 3)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core id 0x{ProcessorId:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core id 0x{ProcessorId:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidCoreId);
 
@@ -66,7 +65,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -83,7 +82,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
         {
             ulong TimeoutNs = ThreadState.X0;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc, "Timeout = " + TimeoutNs.ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc, "Timeout = 0x" + TimeoutNs.ToString("x16"));
 
             KThread CurrThread = Process.GetThread(ThreadState.Tpidr);
 
@@ -114,7 +113,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -125,9 +124,9 @@ namespace Ryujinx.HLE.OsHle.Kernel
             int Handle   = (int)ThreadState.X0;
             int Priority = (int)ThreadState.X1;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "Handle = "   + Handle  .ToString("x8") + ", " +
-                "Priority = " + Priority.ToString("x8"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "Handle = 0x"   + Handle  .ToString("x8") + ", " +
+                "Priority = 0x" + Priority.ToString("x8"));
 
             KThread Thread = GetThread(ThreadState.Tpidr, Handle);
 
@@ -139,7 +138,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -149,7 +148,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
         {
             int Handle = (int)ThreadState.X2;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc, "Handle = " + Handle.ToString("x8"));
+            Device.Log.PrintDebug(LogClass.KernelSvc, "Handle = 0x" + Handle.ToString("x8"));
 
             KThread Thread = GetThread(ThreadState.Tpidr, Handle);
 
@@ -161,7 +160,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -173,10 +172,10 @@ namespace Ryujinx.HLE.OsHle.Kernel
             int  IdealCore =  (int)ThreadState.X1;
             long CoreMask  = (long)ThreadState.X2;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "Handle = "    + Handle   .ToString("x8") + ", " +
-                "IdealCore = " + IdealCore.ToString("x8") + ", " +
-                "CoreMask = "  + CoreMask .ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "Handle = 0x"    + Handle   .ToString("x8") + ", " +
+                "IdealCore = 0x" + IdealCore.ToString("x8") + ", " +
+                "CoreMask = 0x"  + CoreMask .ToString("x16"));
 
             KThread Thread = GetThread(ThreadState.Tpidr, Handle);
 
@@ -193,7 +192,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 {
                     if ((IdealCore | 2) != -1)
                     {
-                        Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core id 0x{IdealCore:x8}!");
+                        Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core id 0x{IdealCore:x8}!");
 
                         ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidCoreId);
 
@@ -202,7 +201,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 }
                 else if ((CoreMask & (1 << IdealCore)) == 0)
                 {
-                    Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core mask 0x{CoreMask:x8}!");
+                    Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core mask 0x{CoreMask:x8}!");
 
                     ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidMaskValue);
 
@@ -212,7 +211,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Thread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -224,7 +223,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             //-3 is used as "don't update", the old IdealCore value is kept.
             if (IdealCore == -3 && (CoreMask & (1 << Thread.IdealCore)) == 0)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core mask 0x{CoreMask:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid core mask 0x{CoreMask:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidMaskValue);
 
@@ -254,7 +253,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -275,7 +274,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             }
             else
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
             }
@@ -290,7 +289,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Thread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{Handle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -299,7 +298,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Process.GetThread(ThreadState.Tpidr) == Thread)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Thread handle 0x{Handle:x8} is current thread!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Thread handle 0x{Handle:x8} is current thread!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidThread);
 

+ 45 - 46
Ryujinx.HLE/OsHle/Kernel/SvcThreadSync.cs → Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs

@@ -1,11 +1,10 @@
 using ChocolArm64.State;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
 using System;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Kernel
+namespace Ryujinx.HLE.HOS.Kernel
 {
     partial class SvcHandler
     {
@@ -17,23 +16,23 @@ namespace Ryujinx.HLE.OsHle.Kernel
             long MutexAddress      = (long)ThreadState.X1;
             int  WaitThreadHandle  =  (int)ThreadState.X2;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "OwnerThreadHandle = " + OwnerThreadHandle.ToString("x8")  + ", " +
-                "MutexAddress = "      + MutexAddress     .ToString("x16") + ", " +
-                "WaitThreadHandle = "  + WaitThreadHandle .ToString("x8"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "OwnerThreadHandle = 0x" + OwnerThreadHandle.ToString("x8")  + ", " +
+                "MutexAddress = 0x"      + MutexAddress     .ToString("x16") + ", " +
+                "WaitThreadHandle = 0x"  + WaitThreadHandle .ToString("x8"));
 
             if (IsPointingInsideKernel(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
                 return;
             }
 
-            if (IsWordAddressUnaligned(MutexAddress))
+            if (IsAddressNotWordAligned(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -44,7 +43,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (OwnerThread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid owner thread handle 0x{OwnerThreadHandle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid owner thread handle 0x{OwnerThreadHandle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -55,7 +54,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (WaitThread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid requesting thread handle 0x{WaitThreadHandle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid requesting thread handle 0x{WaitThreadHandle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -73,20 +72,20 @@ namespace Ryujinx.HLE.OsHle.Kernel
         {
             long MutexAddress = (long)ThreadState.X0;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc, "MutexAddress = " + MutexAddress.ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc, "MutexAddress = 0x" + MutexAddress.ToString("x16"));
 
             if (IsPointingInsideKernel(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
                 return;
             }
 
-            if (IsWordAddressUnaligned(MutexAddress))
+            if (IsAddressNotWordAligned(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -105,24 +104,24 @@ namespace Ryujinx.HLE.OsHle.Kernel
             int   ThreadHandle   =  (int)ThreadState.X2;
             ulong Timeout        =       ThreadState.X3;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "MutexAddress = "   + MutexAddress  .ToString("x16") + ", " +
-                "CondVarAddress = " + CondVarAddress.ToString("x16") + ", " +
-                "ThreadHandle = "   + ThreadHandle  .ToString("x8")  + ", " +
-                "Timeout = "        + Timeout       .ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "MutexAddress = 0x"   + MutexAddress  .ToString("x16") + ", " +
+                "CondVarAddress = 0x" + CondVarAddress.ToString("x16") + ", " +
+                "ThreadHandle = 0x"   + ThreadHandle  .ToString("x8")  + ", " +
+                "Timeout = 0x"        + Timeout       .ToString("x16"));
 
             if (IsPointingInsideKernel(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
                 return;
             }
 
-            if (IsWordAddressUnaligned(MutexAddress))
+            if (IsAddressNotWordAligned(MutexAddress))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned mutex address 0x{MutexAddress:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -133,7 +132,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (Thread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{ThreadHandle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{ThreadHandle:x8}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle);
 
@@ -157,9 +156,9 @@ namespace Ryujinx.HLE.OsHle.Kernel
             long CondVarAddress = (long)ThreadState.X0;
             int  Count          =  (int)ThreadState.X1;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "CondVarAddress = " + CondVarAddress.ToString("x16") + ", " +
-                "Count = "          + Count         .ToString("x8"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "CondVarAddress = 0x" + CondVarAddress.ToString("x16") + ", " +
+                "Count = 0x"          + Count         .ToString("x8"));
 
             KThread CurrThread = Process.GetThread(ThreadState.Tpidr);
 
@@ -179,7 +178,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             {
                 int MutexValue = Memory.ReadInt32(MutexAddress);
 
-                Ns.Log.PrintDebug(LogClass.KernelSvc, "MutexValue = " + MutexValue.ToString("x8"));
+                Device.Log.PrintDebug(LogClass.KernelSvc, "MutexValue = 0x" + MutexValue.ToString("x8"));
 
                 if (MutexValue != (OwnerThreadHandle | MutexHasListenersMask))
                 {
@@ -192,7 +191,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 InsertWaitingMutexThreadUnsafe(OwnerThreadHandle, WaitThread);
             }
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc, "Entering wait state...");
+            Device.Log.PrintDebug(LogClass.KernelSvc, "Entering wait state...");
 
             Process.Scheduler.EnterWait(CurrThread);
         }
@@ -204,24 +203,24 @@ namespace Ryujinx.HLE.OsHle.Kernel
             int             Value   = (int)ThreadState.X2;
             ulong           Timeout = ThreadState.X3;
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc,
-                "Address = "         + Address.ToString("x16") + ", " +
-                "ArbitrationType = " + Type   .ToString()      + ", " +
-                "Value = "           + Value  .ToString("x8")  + ", " +
-                "Timeout = "         + Timeout.ToString("x16"));
+            Device.Log.PrintDebug(LogClass.KernelSvc,
+                "Address = 0x"         + Address.ToString("x16") + ", " +
+                "ArbitrationType = 0x" + Type   .ToString()      + ", " +
+                "Value = 0x"           + Value  .ToString("x8")  + ", " +
+                "Timeout = 0x"         + Timeout.ToString("x16"));
 
             if (IsPointingInsideKernel(Address))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address 0x{Address:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid address 0x{Address:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm);
 
                 return;
             }
 
-            if (IsWordAddressUnaligned(Address))
+            if (IsAddressNotWordAligned(Address))
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned address 0x{Address:x16}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Unaligned address 0x{Address:x16}!");
 
                 ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidAddress);
 
@@ -282,13 +281,13 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
                     Process.Scheduler.WakeUp(OwnerThread);
 
-                    Ns.Log.PrintDebug(LogClass.KernelSvc, "Gave mutex to thread id " + OwnerThread.ThreadId + "!");
+                    Device.Log.PrintDebug(LogClass.KernelSvc, "Gave mutex to thread id " + OwnerThread.ThreadId + "!");
                 }
                 else
                 {
                     Memory.WriteInt32ToSharedAddr(MutexAddress, 0);
 
-                    Ns.Log.PrintDebug(LogClass.KernelSvc, "No threads waiting mutex!");
+                    Device.Log.PrintDebug(LogClass.KernelSvc, "No threads waiting mutex!");
                 }
             }
         }
@@ -313,7 +312,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                 Process.ThreadArbiterList.Add(WaitThread);
             }
 
-            Ns.Log.PrintDebug(LogClass.KernelSvc, "Entering wait state...");
+            Device.Log.PrintDebug(LogClass.KernelSvc, "Entering wait state...");
 
             if (Timeout != ulong.MaxValue)
             {
@@ -333,7 +332,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
                         Process.ThreadArbiterList.Remove(WaitThread);
 
-                        Ns.Log.PrintDebug(LogClass.KernelSvc, "Timed out...");
+                        Device.Log.PrintDebug(LogClass.KernelSvc, "Timed out...");
 
                         return false;
                     }
@@ -361,7 +360,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
                     if (WaitThread == null)
                     {
-                        Ns.Log.PrintDebug(LogClass.KernelSvc, "No more threads to wake up!");
+                        Device.Log.PrintDebug(LogClass.KernelSvc, "No more threads to wake up!");
 
                         break;
                     }
@@ -393,7 +392,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
                         MutexValue = Memory.ReadInt32(MutexAddress);
                     }
 
-                    Ns.Log.PrintDebug(LogClass.KernelSvc, "MutexValue = " + MutexValue.ToString("x8"));
+                    Device.Log.PrintDebug(LogClass.KernelSvc, "MutexValue = 0x" + MutexValue.ToString("x8"));
 
                     if (MutexValue == 0)
                     {
@@ -437,7 +436,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
 
             if (OwnerThread == null)
             {
-                Ns.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{OwnerThreadHandle:x8}!");
+                Device.Log.PrintWarning(LogClass.KernelSvc, $"Invalid thread handle 0x{OwnerThreadHandle:x8}!");
 
                 return;
             }
@@ -516,7 +515,7 @@ namespace Ryujinx.HLE.OsHle.Kernel
             return ((ulong)Address + 0x1000000000) < 0xffffff000;
         }
 
-        private bool IsWordAddressUnaligned(long Address)
+        private bool IsAddressNotWordAligned(long Address)
         {
             return (Address & 3) != 0;
         }

+ 1 - 1
Ryujinx.HLE/OsHle/Handles/ThreadQueue.cs → Ryujinx.HLE/HOS/Kernel/ThreadQueue.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Handles
+namespace Ryujinx.HLE.HOS.Kernel
 {
     class ThreadQueue
     {

+ 59 - 78
Ryujinx.HLE/OsHle/Process.cs → Ryujinx.HLE/HOS/Process.cs

@@ -2,30 +2,29 @@ using ChocolArm64;
 using ChocolArm64.Events;
 using ChocolArm64.Memory;
 using ChocolArm64.State;
+using Ryujinx.HLE.Exceptions;
+using Ryujinx.HLE.HOS.Diagnostics;
+using Ryujinx.HLE.HOS.Kernel;
+using Ryujinx.HLE.HOS.Services.Nv;
+using Ryujinx.HLE.HOS.SystemState;
 using Ryujinx.HLE.Loaders;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.HLE.Loaders.Npdm;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Diagnostics;
-using Ryujinx.HLE.OsHle.Exceptions;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Kernel;
-using Ryujinx.HLE.OsHle.Services.Nv;
-using Ryujinx.HLE.OsHle.SystemState;
-using Ryujinx.HLE.OsHle.Utilities;
+using Ryujinx.HLE.Utilities;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.IO;
 using System.Text;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     class Process : IDisposable
     {
         private const int TickFreq = 19_200_000;
 
-        public Switch Ns { get; private set; }
+        public Switch Device { get; private set; }
 
         public bool NeedsHbAbi { get; private set; }
 
@@ -57,8 +56,6 @@ namespace Ryujinx.HLE.OsHle
 
         private ConcurrentDictionary<long, KThread> Threads;
 
-        private KThread MainThread;
-
         private List<Executable> Executables;
 
         private Dictionary<long, string> SymbolTable;
@@ -69,14 +66,14 @@ namespace Ryujinx.HLE.OsHle
 
         private bool Disposed;
 
-        public Process(Switch Ns, KProcessScheduler Scheduler, int ProcessId, Npdm MetaData)
+        public Process(Switch Device, KProcessScheduler Scheduler, int ProcessId, Npdm MetaData)
         {
-            this.Ns        = Ns;
+            this.Device    = Device;
             this.Scheduler = Scheduler;
             this.MetaData  = MetaData;
             this.ProcessId = ProcessId;
 
-            Memory = new AMemory(Ns.Memory.RamPointer);
+            Memory = new AMemory(Device.Memory.RamPointer);
 
             MemoryManager = new KMemoryManager(this);
 
@@ -90,7 +87,7 @@ namespace Ryujinx.HLE.OsHle
 
             AppletState = new AppletStateMgr();
 
-            SvcHandler = new SvcHandler(Ns, this);
+            SvcHandler = new SvcHandler(Device, this);
 
             Threads = new ConcurrentDictionary<long, KThread>();
 
@@ -106,7 +103,7 @@ namespace Ryujinx.HLE.OsHle
                 throw new ObjectDisposedException(nameof(Process));
             }
 
-            Ns.Log.PrintInfo(LogClass.Loader, $"Image base at 0x{ImageBase:x16}.");
+            Device.Log.PrintInfo(LogClass.Loader, $"Image base at 0x{ImageBase:x16}.");
 
             Executable Executable = new Executable(Program, MemoryManager, Memory, ImageBase);
 
@@ -156,7 +153,7 @@ namespace Ryujinx.HLE.OsHle
                 return false;
             }
 
-            MainThread = HandleTable.GetData<KThread>(Handle);
+            KThread MainThread = HandleTable.GetData<KThread>(Handle);
 
             if (NeedsHbAbi)
             {
@@ -170,7 +167,7 @@ namespace Ryujinx.HLE.OsHle
                     MemoryState.MappedMemory,
                     MemoryPermission.ReadAndWrite);
 
-                string SwitchPath = Ns.VFs.SystemPathToSwitchPath(Executables[0].FilePath);
+                string SwitchPath = Device.FileSystem.SystemPathToSwitchPath(Executables[0].FilePath);
 
                 Homebrew.WriteHbAbiData(Memory, HbAbiDataPosition, Handle, SwitchPath);
 
@@ -183,24 +180,6 @@ namespace Ryujinx.HLE.OsHle
             return true;
         }
 
-        public void StopAllThreadsAsync()
-        {
-            if (Disposed)
-            {
-                throw new ObjectDisposedException(nameof(Process));
-            }
-
-            if (MainThread != null)
-            {
-                MainThread.Thread.StopExecution();
-            }
-
-            foreach (KThread Thread in Threads.Values)
-            {
-                Thread.Thread.StopExecution();
-            }
-        }
-
         public int MakeThread(
             long EntryPoint,
             long StackTop,
@@ -215,18 +194,16 @@ namespace Ryujinx.HLE.OsHle
 
             AThread CpuThread = new AThread(GetTranslator(), Memory, EntryPoint);
 
-            KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority);
+            long Tpidr = GetFreeTls();
 
-            Thread.LastPc = EntryPoint;
+            int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
 
-            int Handle = HandleTable.OpenHandle(Thread);
+            KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority, ThreadId);
 
-            long Tpidr = GetFreeTls();
+            Thread.LastPc = EntryPoint;
 
-            int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
+            int Handle = HandleTable.OpenHandle(Thread);
 
-            CpuThread.ThreadState.ProcessId = ProcessId;
-            CpuThread.ThreadState.ThreadId  = ThreadId;
             CpuThread.ThreadState.CntfrqEl0 = TickFreq;
             CpuThread.ThreadState.Tpidr     = Tpidr;
 
@@ -330,7 +307,7 @@ namespace Ryujinx.HLE.OsHle
                 }
             }
 
-            Ns.Log.PrintDebug(LogClass.Cpu, $"Executing at 0x{e.Position:x16} {e.SubName} {NsoName}");
+            Device.Log.PrintDebug(LogClass.Cpu, $"Executing at 0x{e.Position:x16} {e.SubName} {NsoName}");
         }
 
         public void PrintStackTrace(AThreadState ThreadState)
@@ -355,7 +332,7 @@ namespace Ryujinx.HLE.OsHle
                 Trace.AppendLine(" " + SubName + " (" + GetNsoNameAndAddress(Position) + ")");
             }
 
-            Ns.Log.PrintInfo(LogClass.Cpu, Trace.ToString());
+            Device.Log.PrintInfo(LogClass.Cpu, Trace.ToString());
         }
 
         private string GetNsoNameAndAddress(long Position)
@@ -390,12 +367,7 @@ namespace Ryujinx.HLE.OsHle
 
             if (Threads.Count == 0)
             {
-                if (ShouldDispose)
-                {
-                    Dispose();
-                }
-
-                Ns.Os.ExitProcess(ProcessId);
+                Device.System.ExitProcess(ProcessId);
             }
         }
 
@@ -409,6 +381,35 @@ namespace Ryujinx.HLE.OsHle
             return Thread;
         }
 
+        private void Unload()
+        {
+            if (Disposed || Threads.Count > 0)
+            {
+                return;
+            }
+
+            Disposed = true;
+
+            foreach (object Obj in HandleTable.Clear())
+            {
+                if (Obj is KSession Session)
+                {
+                    Session.Dispose();
+                }
+            }
+
+            INvDrvServices.UnloadProcess(this);
+
+            AppletState.Dispose();
+
+            if (NeedsHbAbi && Executables.Count > 0 && Executables[0].FilePath.EndsWith(Homebrew.TemporaryNroSuffix))
+            {
+                File.Delete(Executables[0].FilePath);
+            }
+
+            Device.Log.PrintInfo(LogClass.Loader, $"Process {ProcessId} exiting...");
+        }
+
         public void Dispose()
         {
             Dispose(true);
@@ -416,41 +417,21 @@ namespace Ryujinx.HLE.OsHle
 
         protected virtual void Dispose(bool Disposing)
         {
-            if (Disposing && !Disposed)
+            if (Disposing)
             {
-                //If there is still some thread running, disposing the objects is not
-                //safe as the thread may try to access those resources. Instead, we set
-                //the flag to have the Process disposed when all threads finishes.
-                //Note: This may not happen if the guest code gets stuck on a infinite loop.
                 if (Threads.Count > 0)
                 {
-                    ShouldDispose = true;
-
-                    Ns.Log.PrintInfo(LogClass.Loader, $"Process {ProcessId} waiting all threads terminate...");
-
-                    return;
-                }
-
-                Disposed = true;
-
-                foreach (object Obj in HandleTable.Clear())
-                {
-                    if (Obj is KSession Session)
+                    foreach (KThread Thread in Threads.Values)
                     {
-                        Session.Dispose();
+                        Thread.Thread.StopExecution();
+
+                        Scheduler.ForceWakeUp(Thread);
                     }
                 }
-
-                if (NeedsHbAbi && Executables.Count > 0 && Executables[0].FilePath.EndsWith(Homebrew.TemporaryNroSuffix))
+                else
                 {
-                    File.Delete(Executables[0].FilePath);
+                    Unload();
                 }
-
-                INvDrvServices.UnloadProcess(this);
-
-                AppletState.Dispose();
-
-                Ns.Log.PrintInfo(LogClass.Loader, $"Process {ProcessId} exiting...");
             }
         }
     }

+ 6 - 6
Ryujinx.HLE/OsHle/ServiceCtx.cs → Ryujinx.HLE/HOS/ServiceCtx.cs

@@ -1,13 +1,13 @@
 using ChocolArm64.Memory;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle
+namespace Ryujinx.HLE.HOS
 {
     class ServiceCtx
     {
-        public Switch       Ns           { get; private set; }
+        public Switch       Device       { get; private set; }
         public Process      Process      { get; private set; }
         public AMemory      Memory       { get; private set; }
         public KSession     Session      { get; private set; }
@@ -17,7 +17,7 @@ namespace Ryujinx.HLE.OsHle
         public BinaryWriter ResponseData { get; private set; }
 
         public ServiceCtx(
-            Switch       Ns,
+            Switch       Device,
             Process      Process,
             AMemory      Memory,
             KSession     Session,
@@ -26,7 +26,7 @@ namespace Ryujinx.HLE.OsHle
             BinaryReader RequestData,
             BinaryWriter ResponseData)
         {
-            this.Ns           = Ns;
+            this.Device       = Device;
             this.Process      = Process;
             this.Memory       = Memory;
             this.Session      = Session;

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Acc/AccErr.cs → Ryujinx.HLE/HOS/Services/Acc/AccErr.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Acc
+namespace Ryujinx.HLE.HOS.Services.Acc
 {
     static class AccErr
     {

+ 12 - 13
Ryujinx.HLE/OsHle/Services/Acc/IAccountServiceForApplication.cs → Ryujinx.HLE/HOS/Services/Acc/IAccountServiceForApplication.cs

@@ -1,12 +1,11 @@
-using ChocolArm64.Memory;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.SystemState;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
-using Ryujinx.HLE.OsHle.SystemState;
 using System.Collections.Generic;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Services.Acc
+namespace Ryujinx.HLE.HOS.Services.Acc
 {
     class IAccountServiceForApplication : IpcService
     {
@@ -31,7 +30,7 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
 
         public long GetUserCount(ServiceCtx Context)
         {
-            Context.ResponseData.Write(Context.Ns.Os.SystemState.GetUserCount());
+            Context.ResponseData.Write(Context.Device.System.State.GetUserCount());
 
             return 0;
         }
@@ -42,19 +41,19 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
                 Context.RequestData.ReadInt64(),
                 Context.RequestData.ReadInt64());
 
-            Context.ResponseData.Write(Context.Ns.Os.SystemState.TryGetUser(Uuid, out _) ? 1 : 0);
+            Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _) ? 1 : 0);
 
             return 0;
         }
 
         public long ListAllUsers(ServiceCtx Context)
         {
-            return WriteUserList(Context, Context.Ns.Os.SystemState.GetAllUsers());
+            return WriteUserList(Context, Context.Device.System.State.GetAllUsers());
         }
 
         public long ListOpenUsers(ServiceCtx Context)
         {
-            return WriteUserList(Context, Context.Ns.Os.SystemState.GetOpenUsers());
+            return WriteUserList(Context, Context.Device.System.State.GetOpenUsers());
         }
 
         private long WriteUserList(ServiceCtx Context, IEnumerable<UserProfile> Profiles)
@@ -84,7 +83,7 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
 
         public long GetLastOpenedUser(ServiceCtx Context)
         {
-            UserProfile LastOpened = Context.Ns.Os.SystemState.LastOpenUser;
+            UserProfile LastOpened = Context.Device.System.State.LastOpenUser;
 
             LastOpened.Uuid.Write(Context.ResponseData);
 
@@ -97,9 +96,9 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
                 Context.RequestData.ReadInt64(),
                 Context.RequestData.ReadInt64());
 
-            if (!Context.Ns.Os.SystemState.TryGetUser(Uuid, out UserProfile Profile))
+            if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
             {
-                Context.Ns.Log.PrintWarning(LogClass.ServiceAcc, $"User 0x{Uuid} not found!");
+                Context.Device.Log.PrintWarning(LogClass.ServiceAcc, $"User 0x{Uuid} not found!");
 
                 return MakeError(ErrorModule.Account, AccErr.UserNotFound);
             }
@@ -111,7 +110,7 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
 
         public long InitializeApplicationInfo(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
 
             return 0;
         }

+ 4 - 4
Ryujinx.HLE/OsHle/Services/Acc/IManagerForApplication.cs → Ryujinx.HLE/HOS/Services/Acc/IManagerForApplication.cs

@@ -1,8 +1,8 @@
+using Ryujinx.HLE.HOS.Ipc;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Acc
+namespace Ryujinx.HLE.HOS.Services.Acc
 {
     class IManagerForApplication : IpcService
     {
@@ -21,14 +21,14 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
 
         public long CheckAvailability(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
 
             return 0;
         }
 
         public long GetAccountId(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
 
             Context.ResponseData.Write(0xcafeL);
 

+ 5 - 5
Ryujinx.HLE/OsHle/Services/Acc/IProfile.cs → Ryujinx.HLE/HOS/Services/Acc/IProfile.cs

@@ -1,12 +1,12 @@
 using ChocolArm64.Memory;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.SystemState;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
-using Ryujinx.HLE.OsHle.SystemState;
-using Ryujinx.HLE.OsHle.Utilities;
+using Ryujinx.HLE.Utilities;
 using System.Collections.Generic;
 using System.Text;
 
-namespace Ryujinx.HLE.OsHle.Services.Acc
+namespace Ryujinx.HLE.HOS.Services.Acc
 {
     class IProfile : IpcService
     {
@@ -29,7 +29,7 @@ namespace Ryujinx.HLE.OsHle.Services.Acc
 
         public long Get(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAcc, "Stubbed.");
 
             long Position = Context.Request.ReceiveBuff[0].Position;
 

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Am/AmErr.cs → Ryujinx.HLE/HOS/Services/Am/AmErr.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     static class AmErr
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Am/FocusState.cs → Ryujinx.HLE/HOS/Services/Am/FocusState.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     enum FocusState
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IAllSystemAppletProxiesService.cs → Ryujinx.HLE/HOS/Services/Am/IAllSystemAppletProxiesService.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IAllSystemAppletProxiesService : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IApplicationCreator.cs → Ryujinx.HLE/HOS/Services/Am/IApplicationCreator.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IApplicationCreator : IpcService
     {

+ 8 - 8
Ryujinx.HLE/OsHle/Services/Am/IApplicationFunctions.cs → Ryujinx.HLE/HOS/Services/Am/IApplicationFunctions.cs

@@ -1,8 +1,8 @@
+using Ryujinx.HLE.HOS.Ipc;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IApplicationFunctions : IpcService
     {
@@ -39,7 +39,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
             long UIdLow  = Context.RequestData.ReadInt64();
             long UIdHigh = Context.RequestData.ReadInt64();
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             Context.ResponseData.Write(0L);
 
@@ -48,7 +48,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long GetDesiredLanguage(ServiceCtx Context)
         {
-            Context.ResponseData.Write(Context.Ns.Os.SystemState.DesiredLanguageCode);
+            Context.ResponseData.Write(Context.Device.System.State.DesiredLanguageCode);
 
             return 0;
         }
@@ -59,7 +59,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
             string Result = GetFormattedErrorCode(ErrorCode);
 
-            Context.Ns.Log.PrintInfo(LogClass.ServiceAm, $"Result = 0x{ErrorCode:x8} ({Result}).");
+            Context.Device.Log.PrintInfo(LogClass.ServiceAm, $"Result = 0x{ErrorCode:x8} ({Result}).");
 
             return 0;
         }
@@ -90,7 +90,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long GetPseudoDeviceId(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             Context.ResponseData.Write(0L);
             Context.ResponseData.Write(0L);
@@ -100,7 +100,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long InitializeGamePlayRecording(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -109,7 +109,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             int State = Context.RequestData.ReadInt32();
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxy.cs → Ryujinx.HLE/HOS/Services/Am/IApplicationProxy.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IApplicationProxy : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IApplicationProxyService.cs → Ryujinx.HLE/HOS/Services/Am/IApplicationProxyService.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IApplicationProxyService : IpcService
     {

+ 7 - 7
Ryujinx.HLE/OsHle/Services/Am/IAudioController.cs → Ryujinx.HLE/HOS/Services/Am/IAudioController.cs

@@ -1,8 +1,8 @@
+using Ryujinx.HLE.HOS.Ipc;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IAudioController : IpcService
     {
@@ -27,7 +27,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
             float AppletVolume        = Context.RequestData.ReadSingle();
             float LibraryAppletVolume = Context.RequestData.ReadSingle();
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -36,7 +36,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             Context.ResponseData.Write(1f);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -45,7 +45,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             Context.ResponseData.Write(1f);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -55,7 +55,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
             float Unknown0 = Context.RequestData.ReadSingle();
             long  Unknown1 = Context.RequestData.ReadInt64();
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -64,7 +64,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             float Unknown0 = Context.RequestData.ReadSingle();
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 8 - 8
Ryujinx.HLE/OsHle/Services/Am/ICommonStateGetter.cs → Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs

@@ -1,11 +1,11 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-using static Ryujinx.HLE.OsHle.ErrorCode;
+using static Ryujinx.HLE.HOS.ErrorCode;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class ICommonStateGetter : IpcService
     {
@@ -57,7 +57,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long GetOperationMode(ServiceCtx Context)
         {
-            OperationMode Mode = Context.Ns.Os.SystemState.DockedMode
+            OperationMode Mode = Context.Device.System.State.DockedMode
                 ? OperationMode.Docked
                 : OperationMode.Handheld;
 
@@ -68,7 +68,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long GetPerformanceMode(ServiceCtx Context)
         {
-            Apm.PerformanceMode Mode = Context.Ns.Os.SystemState.DockedMode
+            Apm.PerformanceMode Mode = Context.Device.System.State.DockedMode
                 ? Apm.PerformanceMode.Docked
                 : Apm.PerformanceMode.Handheld;
 
@@ -81,7 +81,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             Context.ResponseData.Write((byte)0); //Unknown value.
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -107,7 +107,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
             Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IDebugFunctions.cs → Ryujinx.HLE/HOS/Services/Am/IDebugFunctions.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IDebugFunctions : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IDisplayController.cs → Ryujinx.HLE/HOS/Services/Am/IDisplayController.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IDisplayController : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IGlobalStateController.cs → Ryujinx.HLE/HOS/Services/Am/IGlobalStateController.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IGlobalStateController : IpcService
     {

+ 5 - 5
Ryujinx.HLE/OsHle/Services/Am/IHomeMenuFunctions.cs → Ryujinx.HLE/HOS/Services/Am/IHomeMenuFunctions.cs

@@ -1,9 +1,9 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IHomeMenuFunctions : IpcService
     {
@@ -27,7 +27,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long RequestToGetForeground(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -38,7 +38,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
             Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 8 - 8
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletAccessor.cs → Ryujinx.HLE/HOS/Services/Am/ILibraryAppletAccessor.cs

@@ -1,9 +1,9 @@
-using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
+using Ryujinx.HLE.Logging;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class ILibraryAppletAccessor : IpcService
     {
@@ -35,28 +35,28 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
             Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
 
         public long Start(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
 
         public long GetResult(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
 
         public long PushInData(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/ILibraryAppletCreator.cs → Ryujinx.HLE/HOS/Services/Am/ILibraryAppletCreator.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class ILibraryAppletCreator : IpcService
     {

+ 19 - 19
Ryujinx.HLE/OsHle/Services/Am/ISelfController.cs → Ryujinx.HLE/HOS/Services/Am/ISelfController.cs

@@ -1,9 +1,9 @@
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class ISelfController : IpcService
     {
@@ -36,22 +36,22 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long Exit(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
-            
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+
             return 0;
         }
 
         public long LockExit(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
-            
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+
             return 0;
         }
 
         public long UnlockExit(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
-            
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+
             return 0;
         }
 
@@ -63,7 +63,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
             Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -72,7 +72,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -81,7 +81,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -90,7 +90,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -101,7 +101,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
             bool Flag2 = Context.RequestData.ReadByte() != 0 ? true : false;
             bool Flag3 = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -110,7 +110,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -119,7 +119,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -127,8 +127,8 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         public long SetScreenShotImageOrientation(ServiceCtx Context)
         {
             int Orientation = Context.RequestData.ReadInt32();
-            
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }
@@ -137,7 +137,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
         {
             bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IStorage.cs → Ryujinx.HLE/HOS/Services/Am/IStorage.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IStorage : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/IStorageAccessor.cs → Ryujinx.HLE/HOS/Services/Am/IStorageAccessor.cs

@@ -1,8 +1,8 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IStorageAccessor : IpcService
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Am/ISystemAppletProxy.cs → Ryujinx.HLE/HOS/Services/Am/ISystemAppletProxy.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class ISystemAppletProxy : IpcService
     {

+ 4 - 4
Ryujinx.HLE/OsHle/Services/Am/IWindowController.cs → Ryujinx.HLE/HOS/Services/Am/IWindowController.cs

@@ -1,8 +1,8 @@
+using Ryujinx.HLE.HOS.Ipc;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class IWindowController : IpcService
     {
@@ -21,7 +21,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long GetAppletResourceUserId(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             Context.ResponseData.Write(0L);
 
@@ -30,7 +30,7 @@ namespace Ryujinx.HLE.OsHle.Services.Am
 
         public long AcquireForegroundRights(ServiceCtx Context)
         {
-            Context.Ns.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceAm, "Stubbed.");
 
             return 0;
         }

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Am/MessageInfo.cs → Ryujinx.HLE/HOS/Services/Am/MessageInfo.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     enum MessageInfo
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Am/OperationMode.cs → Ryujinx.HLE/HOS/Services/Am/OperationMode.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     enum OperationMode
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Am/StorageHelper.cs → Ryujinx.HLE/HOS/Services/Am/StorageHelper.cs

@@ -1,6 +1,6 @@
 using System.IO;
 
-namespace Ryujinx.HLE.OsHle.Services.Am
+namespace Ryujinx.HLE.HOS.Services.Am
 {
     class StorageHelper
     {

+ 2 - 2
Ryujinx.HLE/OsHle/Services/Apm/IManager.cs → Ryujinx.HLE/HOS/Services/Apm/IManager.cs

@@ -1,7 +1,7 @@
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Apm
+namespace Ryujinx.HLE.HOS.Services.Apm
 {
     class IManager : IpcService
     {

+ 3 - 3
Ryujinx.HLE/OsHle/Services/Apm/ISession.cs → Ryujinx.HLE/HOS/Services/Apm/ISession.cs

@@ -1,8 +1,8 @@
+using Ryujinx.HLE.HOS.Ipc;
 using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.OsHle.Ipc;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Apm
+namespace Ryujinx.HLE.HOS.Services.Apm
 {
     class ISession : IpcService
     {
@@ -33,7 +33,7 @@ namespace Ryujinx.HLE.OsHle.Services.Apm
 
             Context.ResponseData.Write((uint)PerformanceConfiguration.PerformanceConfiguration1);
 
-            Context.Ns.Log.PrintStub(LogClass.ServiceApm, "Stubbed.");
+            Context.Device.Log.PrintStub(LogClass.ServiceApm, "Stubbed.");
 
             return 0;
         }

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Apm/PerformanceConfiguration.cs → Ryujinx.HLE/HOS/Services/Apm/PerformanceConfiguration.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Apm
+namespace Ryujinx.HLE.HOS.Services.Apm
 {
     enum PerformanceConfiguration : uint
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Apm/PerformanceMode.cs → Ryujinx.HLE/HOS/Services/Apm/PerformanceMode.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Apm
+namespace Ryujinx.HLE.HOS.Services.Apm
 {
     enum PerformanceMode
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Aud/AudErr.cs → Ryujinx.HLE/HOS/Services/Aud/AudErr.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Aud
+namespace Ryujinx.HLE.HOS.Services.Aud
 {
     static class AudErr
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Aud/AudioOut/AudioOutData.cs → Ryujinx.HLE/HOS/Services/Aud/AudioOut/AudioOutData.cs

@@ -1,6 +1,6 @@
 using System.Runtime.InteropServices;
 
-namespace Ryujinx.HLE.OsHle.Services.Aud.AudioOut
+namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
 {
     [StructLayout(LayoutKind.Sequential)]
     struct AudioOutData

+ 3 - 3
Ryujinx.HLE/OsHle/Services/Aud/AudioOut/IAudioOut.cs → Ryujinx.HLE/HOS/Services/Aud/AudioOut/IAudioOut.cs

@@ -1,11 +1,11 @@
 using ChocolArm64.Memory;
 using Ryujinx.Audio;
-using Ryujinx.HLE.OsHle.Handles;
-using Ryujinx.HLE.OsHle.Ipc;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
 using System;
 using System.Collections.Generic;
 
-namespace Ryujinx.HLE.OsHle.Services.Aud.AudioOut
+namespace Ryujinx.HLE.HOS.Services.Aud.AudioOut
 {
     class IAudioOut : IpcService, IDisposable
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Aud/AudioRenderer/AudioConsts.cs → Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/AudioConsts.cs

@@ -1,4 +1,4 @@
-namespace Ryujinx.HLE.OsHle.Services.Aud.AudioRenderer
+namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
 {
     static class AudioConsts
     {

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Aud/AudioRenderer/BehaviorIn.cs → Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/BehaviorIn.cs

@@ -1,6 +1,6 @@
 using System.Runtime.InteropServices;
 
-namespace Ryujinx.HLE.OsHle.Services.Aud.AudioRenderer
+namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
 {
     [StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
     struct BehaviorIn

+ 1 - 1
Ryujinx.HLE/OsHle/Services/Aud/AudioRenderer/BiquadFilter.cs → Ryujinx.HLE/HOS/Services/Aud/AudioRenderer/BiquadFilter.cs

@@ -1,6 +1,6 @@
 using System.Runtime.InteropServices;
 
-namespace Ryujinx.HLE.OsHle.Services.Aud.AudioRenderer
+namespace Ryujinx.HLE.HOS.Services.Aud.AudioRenderer
 {
     [StructLayout(LayoutKind.Sequential, Size = 0xc, Pack = 1)]
     struct BiquadFilter

Некоторые файлы не были показаны из-за большого количества измененных файлов