R/Ryujinx.HLE/MemoryConfiguration.cs
Ac_K 5d08e9b495
hos: Cleanup the project (#2634)
* hos: Cleanup the project

Since a lot of changes has been done on the HOS project, there are some leftover here and there, or class just used in one service, things at wrong places, and more.
This PR fixes that, additionnally to that, I've realigned some vars because I though it make the code more readable.

* Address gdkchan feedback

* addresses Thog feedback

* Revert ElfSymbol
2021-09-15 01:24:49 +02:00

62 lines
No EOL
2.9 KiB
C#

using Ryujinx.HLE.HOS.Kernel.Common;
using System;
namespace Ryujinx.HLE
{
public enum MemoryConfiguration
{
MemoryConfiguration4GB = 0,
MemoryConfiguration4GBAppletDev = 1,
MemoryConfiguration4GBSystemDev = 2,
MemoryConfiguration6GB = 3,
MemoryConfiguration6GBAppletDev = 4,
MemoryConfiguration8GB = 5
}
static class MemoryConfigurationExtensions
{
private const ulong Gb = 1024 * 1024 * 1024;
public static MemoryArrange ToKernelMemoryArrange(this MemoryConfiguration configuration)
{
return configuration switch
{
MemoryConfiguration.MemoryConfiguration4GB => MemoryArrange.MemoryArrange4GB,
MemoryConfiguration.MemoryConfiguration4GBAppletDev => MemoryArrange.MemoryArrange4GBAppletDev,
MemoryConfiguration.MemoryConfiguration4GBSystemDev => MemoryArrange.MemoryArrange4GBSystemDev,
MemoryConfiguration.MemoryConfiguration6GB => MemoryArrange.MemoryArrange6GB,
MemoryConfiguration.MemoryConfiguration6GBAppletDev => MemoryArrange.MemoryArrange6GBAppletDev,
MemoryConfiguration.MemoryConfiguration8GB => MemoryArrange.MemoryArrange8GB,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
};
}
public static MemorySize ToKernelMemorySize(this MemoryConfiguration configuration)
{
return configuration switch
{
MemoryConfiguration.MemoryConfiguration4GB or
MemoryConfiguration.MemoryConfiguration4GBAppletDev or
MemoryConfiguration.MemoryConfiguration4GBSystemDev => MemorySize.MemorySize4GB,
MemoryConfiguration.MemoryConfiguration6GB or
MemoryConfiguration.MemoryConfiguration6GBAppletDev => MemorySize.MemorySize6GB,
MemoryConfiguration.MemoryConfiguration8GB => MemorySize.MemorySize8GB,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
};
}
public static ulong ToDramSize(this MemoryConfiguration configuration)
{
return configuration switch
{
MemoryConfiguration.MemoryConfiguration4GB or
MemoryConfiguration.MemoryConfiguration4GBAppletDev or
MemoryConfiguration.MemoryConfiguration4GBSystemDev => 4 * Gb,
MemoryConfiguration.MemoryConfiguration6GB or
MemoryConfiguration.MemoryConfiguration6GBAppletDev => 6 * Gb,
MemoryConfiguration.MemoryConfiguration8GB => 8 * Gb,
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
};
}
}
}