2021-04-04 12:06:59 +00:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE
|
|
|
|
{
|
|
|
|
public enum MemoryConfiguration
|
|
|
|
{
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration4GB = 0,
|
2021-04-04 12:06:59 +00:00
|
|
|
MemoryConfiguration4GBAppletDev = 1,
|
|
|
|
MemoryConfiguration4GBSystemDev = 2,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration6GB = 3,
|
2021-04-04 12:06:59 +00:00
|
|
|
MemoryConfiguration6GBAppletDev = 4,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration8GB = 5
|
2021-04-04 12:06:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static class MemoryConfigurationExtensions
|
|
|
|
{
|
|
|
|
private const ulong Gb = 1024 * 1024 * 1024;
|
|
|
|
|
|
|
|
public static MemoryArrange ToKernelMemoryArrange(this MemoryConfiguration configuration)
|
|
|
|
{
|
|
|
|
return configuration switch
|
|
|
|
{
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration4GB => MemoryArrange.MemoryArrange4GB,
|
2021-04-04 12:06:59 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration4GBAppletDev => MemoryArrange.MemoryArrange4GBAppletDev,
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GBSystemDev => MemoryArrange.MemoryArrange4GBSystemDev,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration6GB => MemoryArrange.MemoryArrange6GB,
|
2021-04-04 12:06:59 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration6GBAppletDev => MemoryArrange.MemoryArrange6GBAppletDev,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration8GB => MemoryArrange.MemoryArrange8GB,
|
2021-04-04 12:06:59 +00:00
|
|
|
_ => 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,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration8GB => MemorySize.MemorySize8GB,
|
2021-04-04 12:06:59 +00:00
|
|
|
_ => 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,
|
2021-09-14 23:24:49 +00:00
|
|
|
MemoryConfiguration.MemoryConfiguration8GB => 8 * Gb,
|
2021-04-04 12:06:59 +00:00
|
|
|
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|