2021-04-04 05:06:59 -07:00
|
|
|
using Ryujinx.HLE.HOS.Kernel.Common;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE
|
|
|
|
{
|
|
|
|
public enum MemoryConfiguration
|
|
|
|
{
|
2022-11-16 14:27:42 -08:00
|
|
|
MemoryConfiguration4GiB = 0,
|
|
|
|
MemoryConfiguration4GiBAppletDev = 1,
|
|
|
|
MemoryConfiguration4GiBSystemDev = 2,
|
|
|
|
MemoryConfiguration6GiB = 3,
|
|
|
|
MemoryConfiguration6GiBAppletDev = 4,
|
|
|
|
MemoryConfiguration8GiB = 5
|
2021-04-04 05:06:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static class MemoryConfigurationExtensions
|
|
|
|
{
|
2022-11-16 14:27:42 -08:00
|
|
|
private const ulong GiB = 1024 * 1024 * 1024;
|
2021-04-04 05:06:59 -07:00
|
|
|
|
|
|
|
public static MemoryArrange ToKernelMemoryArrange(this MemoryConfiguration configuration)
|
|
|
|
{
|
|
|
|
return configuration switch
|
|
|
|
{
|
2022-11-16 14:27:42 -08:00
|
|
|
MemoryConfiguration.MemoryConfiguration4GiB => MemoryArrange.MemoryArrange4GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBAppletDev => MemoryArrange.MemoryArrange4GiBAppletDev,
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => MemoryArrange.MemoryArrange4GiBSystemDev,
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiB => MemoryArrange.MemoryArrange6GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemoryArrange.MemoryArrange6GiBAppletDev,
|
|
|
|
MemoryConfiguration.MemoryConfiguration8GiB => MemoryArrange.MemoryArrange8GiB,
|
2021-04-04 05:06:59 -07:00
|
|
|
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static MemorySize ToKernelMemorySize(this MemoryConfiguration configuration)
|
|
|
|
{
|
|
|
|
return configuration switch
|
|
|
|
{
|
2022-11-16 14:27:42 -08:00
|
|
|
MemoryConfiguration.MemoryConfiguration4GiB or
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => MemorySize.MemorySize4GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiB or
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemorySize.MemorySize6GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration8GiB => MemorySize.MemorySize8GiB,
|
2021-04-04 05:06:59 -07:00
|
|
|
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ulong ToDramSize(this MemoryConfiguration configuration)
|
|
|
|
{
|
|
|
|
return configuration switch
|
|
|
|
{
|
2022-11-16 14:27:42 -08:00
|
|
|
MemoryConfiguration.MemoryConfiguration4GiB or
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
|
|
|
|
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => 4 * GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiB or
|
|
|
|
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => 6 * GiB,
|
|
|
|
MemoryConfiguration.MemoryConfiguration8GiB => 8 * GiB,
|
2021-04-04 05:06:59 -07:00
|
|
|
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|