diff options
author | gdkchan <gab.dark.100@gmail.com> | 2021-04-04 09:06:59 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 14:06:59 +0200 |
commit | 874540bb5c1c5737bc9b0bfdc96fe1cf12ff164d (patch) | |
tree | 68582881e7f4965d7e0938020a9f5dd1773f070a /Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs | |
parent | 3bc107d491745a0d1f18e48d8c6c0f74565ae633 (diff) |
Allow DRAM size to be increased from 4GB to 6GB (#2174)
* Allow DRAM size to be increased from 4GB to 6GB
* Add option on the UI
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs')
-rw-r--r-- | Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs b/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs new file mode 100644 index 00000000..630baacf --- /dev/null +++ b/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs @@ -0,0 +1,72 @@ +using Ryujinx.HLE.HOS.Kernel.Memory; +using System; + +namespace Ryujinx.HLE.HOS.Kernel.Common +{ + static class KSystemControl + { + private const ulong Kb = 1024; + private const ulong Mb = 1024 * Kb; + private const ulong Gb = 1024 * Mb; + + private const ulong PageSize = 4 * Kb; + + private const ulong RequiredNonSecureSystemPoolSizeVi = 0x2238 * PageSize; + private const ulong RequiredNonSecureSystemPoolSizeNvservices = 0x710 * PageSize; + private const ulong RequiredNonSecureSystemPoolSizeOther = 0x80 * PageSize; + + private const ulong RequiredNonSecureSystemPoolSize = + RequiredNonSecureSystemPoolSizeVi + + RequiredNonSecureSystemPoolSizeNvservices + + RequiredNonSecureSystemPoolSizeOther; + + public static ulong GetApplicationPoolSize(MemoryArrange arrange) + { + return arrange switch + { + MemoryArrange.MemoryArrange4GB or + MemoryArrange.MemoryArrange4GBSystemDev or + MemoryArrange.MemoryArrange6GBAppletDev => 3285 * Mb, + MemoryArrange.MemoryArrange4GBAppletDev => 2048 * Mb, + MemoryArrange.MemoryArrange6GB or + MemoryArrange.MemoryArrange8GB => 4916 * Mb, + _ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\".") + }; + } + + public static ulong GetAppletPoolSize(MemoryArrange arrange) + { + return arrange switch + { + MemoryArrange.MemoryArrange4GB => 507 * Mb, + MemoryArrange.MemoryArrange4GBAppletDev => 1554 * Mb, + MemoryArrange.MemoryArrange4GBSystemDev => 448 * Mb, + MemoryArrange.MemoryArrange6GB => 562 * Mb, + MemoryArrange.MemoryArrange6GBAppletDev or + MemoryArrange.MemoryArrange8GB => 2193 * Mb, + _ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\".") + }; + } + + public static ulong GetMinimumNonSecureSystemPoolSize() + { + return RequiredNonSecureSystemPoolSize; + } + + public static ulong GetDramEndAddress(MemorySize size) + { + return DramMemoryMap.DramBase + GetDramSize(size); + } + + public static ulong GetDramSize(MemorySize size) + { + return size switch + { + MemorySize.MemorySize4GB => 4 * Gb, + MemorySize.MemorySize6GB => 6 * Gb, + MemorySize.MemorySize8GB => 8 * Gb, + _ => throw new ArgumentException($"Invalid memory size \"{size}\".") + }; + } + } +}
\ No newline at end of file |