Update units of memory from decimal to binary prefixes (#3716)
`MB` and `GB` can either be interpreted as having base-10 units, or base-2. `MiB` and `GiB` removes this discrepancy so that units of memory are always interpreted using base-2 units.
This commit is contained in:
parent
d751da84f9
commit
d536cc8ae6
37 changed files with 165 additions and 165 deletions
|
@ -5,11 +5,11 @@ 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 KiB = 1024;
|
||||
private const ulong MiB = 1024 * KiB;
|
||||
private const ulong GiB = 1024 * MiB;
|
||||
|
||||
private const ulong PageSize = 4 * Kb;
|
||||
private const ulong PageSize = 4 * KiB;
|
||||
|
||||
private const ulong RequiredNonSecureSystemPoolSizeVi = 0x2238 * PageSize;
|
||||
private const ulong RequiredNonSecureSystemPoolSizeNvservices = 0x710 * PageSize;
|
||||
|
@ -24,12 +24,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
return arrange switch
|
||||
{
|
||||
MemoryArrange.MemoryArrange4GB or
|
||||
MemoryArrange.MemoryArrange4GBSystemDev or
|
||||
MemoryArrange.MemoryArrange6GBAppletDev => 3285 * Mb,
|
||||
MemoryArrange.MemoryArrange4GBAppletDev => 2048 * Mb,
|
||||
MemoryArrange.MemoryArrange6GB or
|
||||
MemoryArrange.MemoryArrange8GB => 4916 * Mb,
|
||||
MemoryArrange.MemoryArrange4GiB or
|
||||
MemoryArrange.MemoryArrange4GiBSystemDev or
|
||||
MemoryArrange.MemoryArrange6GiBAppletDev => 3285 * MiB,
|
||||
MemoryArrange.MemoryArrange4GiBAppletDev => 2048 * MiB,
|
||||
MemoryArrange.MemoryArrange6GiB or
|
||||
MemoryArrange.MemoryArrange8GiB => 4916 * MiB,
|
||||
_ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\".")
|
||||
};
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
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,
|
||||
MemoryArrange.MemoryArrange4GiB => 507 * MiB,
|
||||
MemoryArrange.MemoryArrange4GiBAppletDev => 1554 * MiB,
|
||||
MemoryArrange.MemoryArrange4GiBSystemDev => 448 * MiB,
|
||||
MemoryArrange.MemoryArrange6GiB => 562 * MiB,
|
||||
MemoryArrange.MemoryArrange6GiBAppletDev or
|
||||
MemoryArrange.MemoryArrange8GiB => 2193 * MiB,
|
||||
_ => throw new ArgumentException($"Invalid memory arrange \"{arrange}\".")
|
||||
};
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
return size switch
|
||||
{
|
||||
MemorySize.MemorySize4GB => 4 * Gb,
|
||||
MemorySize.MemorySize6GB => 6 * Gb,
|
||||
MemorySize.MemorySize8GB => 8 * Gb,
|
||||
MemorySize.MemorySize4GiB => 4 * GiB,
|
||||
MemorySize.MemorySize6GiB => 6 * GiB,
|
||||
MemorySize.MemorySize8GiB => 8 * GiB,
|
||||
_ => throw new ArgumentException($"Invalid memory size \"{size}\".")
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
enum MemoryArrange : byte
|
||||
{
|
||||
MemoryArrange4GB,
|
||||
MemoryArrange4GBAppletDev,
|
||||
MemoryArrange4GBSystemDev,
|
||||
MemoryArrange6GB,
|
||||
MemoryArrange6GBAppletDev,
|
||||
MemoryArrange8GB
|
||||
MemoryArrange4GiB,
|
||||
MemoryArrange4GiBAppletDev,
|
||||
MemoryArrange4GiBSystemDev,
|
||||
MemoryArrange6GiB,
|
||||
MemoryArrange6GiBAppletDev,
|
||||
MemoryArrange8GiB
|
||||
}
|
||||
}
|
|
@ -2,8 +2,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
|
|||
{
|
||||
enum MemorySize : byte
|
||||
{
|
||||
MemorySize4GB = 0,
|
||||
MemorySize6GB = 1,
|
||||
MemorySize8GB = 2
|
||||
MemorySize4GiB = 0,
|
||||
MemorySize6GiB = 1,
|
||||
MemorySize8GiB = 2
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||
|
||||
private static readonly uint[] _pageSizes = new uint[] { SmallPageSize, BigPageSize };
|
||||
|
||||
private const ulong SmallRegionLimit = 0x400000000UL; // 16 GB
|
||||
private const ulong SmallRegionLimit = 0x400000000UL; // 16 GiB
|
||||
private const ulong DefaultUserSize = 1UL << 37;
|
||||
|
||||
private struct VmRegion
|
||||
|
|
|
@ -67,17 +67,17 @@ namespace Ryujinx.HLE.HOS.Services.Spl
|
|||
configValue = 0;
|
||||
break;
|
||||
case ConfigItem.DramId:
|
||||
if (memorySize == MemorySize.MemorySize8GB)
|
||||
if (memorySize == MemorySize.MemorySize8GiB)
|
||||
{
|
||||
configValue = (ulong)DramId.IowaSamsung8GB;
|
||||
configValue = (ulong)DramId.IowaSamsung8GiB;
|
||||
}
|
||||
else if (memorySize == MemorySize.MemorySize6GB)
|
||||
else if (memorySize == MemorySize.MemorySize6GiB)
|
||||
{
|
||||
configValue = (ulong)DramId.IcosaSamsung6GB;
|
||||
configValue = (ulong)DramId.IcosaSamsung6GiB;
|
||||
}
|
||||
else
|
||||
{
|
||||
configValue = (ulong)DramId.IcosaSamsung4GB;
|
||||
configValue = (ulong)DramId.IcosaSamsung4GiB;
|
||||
}
|
||||
break;
|
||||
case ConfigItem.SecurityEngineInterruptNumber:
|
||||
|
|
|
@ -2,34 +2,34 @@
|
|||
{
|
||||
enum DramId
|
||||
{
|
||||
IcosaSamsung4GB,
|
||||
IcosaHynix4GB,
|
||||
IcosaMicron4GB,
|
||||
IowaHynix1y4GB,
|
||||
IcosaSamsung6GB,
|
||||
HoagHynix1y4GB,
|
||||
AulaHynix1y4GB,
|
||||
IowaX1X2Samsung4GB,
|
||||
IowaSansung4GB,
|
||||
IowaSamsung8GB,
|
||||
IowaHynix4GB,
|
||||
IowaMicron4GB,
|
||||
HoagSamsung4GB,
|
||||
HoagSamsung8GB,
|
||||
HoagHynix4GB,
|
||||
HoagMicron4GB,
|
||||
IowaSamsung4GBY,
|
||||
IowaSamsung1y4GBX,
|
||||
IowaSamsung1y8GBX,
|
||||
HoagSamsung1y4GBX,
|
||||
IowaSamsung1y4GBY,
|
||||
IowaSamsung1y8GBY,
|
||||
AulaSamsung1y4GB,
|
||||
HoagSamsung1y8GBX,
|
||||
AulaSamsung1y4GBX,
|
||||
IowaMicron1y4GB,
|
||||
HoagMicron1y4GB,
|
||||
AulaMicron1y4GB,
|
||||
AulaSamsung1y8GBX
|
||||
IcosaSamsung4GiB,
|
||||
IcosaHynix4GiB,
|
||||
IcosaMicron4GiB,
|
||||
IowaHynix1y4GiB,
|
||||
IcosaSamsung6GiB,
|
||||
HoagHynix1y4GiB,
|
||||
AulaHynix1y4GiB,
|
||||
IowaX1X2Samsung4GiB,
|
||||
IowaSansung4GiB,
|
||||
IowaSamsung8GiB,
|
||||
IowaHynix4GiB,
|
||||
IowaMicron4GiB,
|
||||
HoagSamsung4GiB,
|
||||
HoagSamsung8GiB,
|
||||
HoagHynix4GiB,
|
||||
HoagMicron4GiB,
|
||||
IowaSamsung4GiBY,
|
||||
IowaSamsung1y4GiBX,
|
||||
IowaSamsung1y8GiBX,
|
||||
HoagSamsung1y4GiBX,
|
||||
IowaSamsung1y4GiBY,
|
||||
IowaSamsung1y8GiBY,
|
||||
AulaSamsung1y4GiB,
|
||||
HoagSamsung1y8GiBX,
|
||||
AulaSamsung1y4GiBX,
|
||||
IowaMicron1y4GiB,
|
||||
HoagMicron1y4GiB,
|
||||
AulaMicron1y4GiB,
|
||||
AulaSamsung1y8GiBX
|
||||
}
|
||||
}
|
|
@ -5,28 +5,28 @@ namespace Ryujinx.HLE
|
|||
{
|
||||
public enum MemoryConfiguration
|
||||
{
|
||||
MemoryConfiguration4GB = 0,
|
||||
MemoryConfiguration4GBAppletDev = 1,
|
||||
MemoryConfiguration4GBSystemDev = 2,
|
||||
MemoryConfiguration6GB = 3,
|
||||
MemoryConfiguration6GBAppletDev = 4,
|
||||
MemoryConfiguration8GB = 5
|
||||
MemoryConfiguration4GiB = 0,
|
||||
MemoryConfiguration4GiBAppletDev = 1,
|
||||
MemoryConfiguration4GiBSystemDev = 2,
|
||||
MemoryConfiguration6GiB = 3,
|
||||
MemoryConfiguration6GiBAppletDev = 4,
|
||||
MemoryConfiguration8GiB = 5
|
||||
}
|
||||
|
||||
static class MemoryConfigurationExtensions
|
||||
{
|
||||
private const ulong Gb = 1024 * 1024 * 1024;
|
||||
private const ulong GiB = 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,
|
||||
MemoryConfiguration.MemoryConfiguration4GiB => MemoryArrange.MemoryArrange4GiB,
|
||||
MemoryConfiguration.MemoryConfiguration4GiBAppletDev => MemoryArrange.MemoryArrange4GiBAppletDev,
|
||||
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => MemoryArrange.MemoryArrange4GiBSystemDev,
|
||||
MemoryConfiguration.MemoryConfiguration6GiB => MemoryArrange.MemoryArrange6GiB,
|
||||
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemoryArrange.MemoryArrange6GiBAppletDev,
|
||||
MemoryConfiguration.MemoryConfiguration8GiB => MemoryArrange.MemoryArrange8GiB,
|
||||
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
||||
};
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ namespace Ryujinx.HLE
|
|||
{
|
||||
return configuration switch
|
||||
{
|
||||
MemoryConfiguration.MemoryConfiguration4GB or
|
||||
MemoryConfiguration.MemoryConfiguration4GBAppletDev or
|
||||
MemoryConfiguration.MemoryConfiguration4GBSystemDev => MemorySize.MemorySize4GB,
|
||||
MemoryConfiguration.MemoryConfiguration6GB or
|
||||
MemoryConfiguration.MemoryConfiguration6GBAppletDev => MemorySize.MemorySize6GB,
|
||||
MemoryConfiguration.MemoryConfiguration8GB => MemorySize.MemorySize8GB,
|
||||
MemoryConfiguration.MemoryConfiguration4GiB or
|
||||
MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
|
||||
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => MemorySize.MemorySize4GiB,
|
||||
MemoryConfiguration.MemoryConfiguration6GiB or
|
||||
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => MemorySize.MemorySize6GiB,
|
||||
MemoryConfiguration.MemoryConfiguration8GiB => MemorySize.MemorySize8GiB,
|
||||
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
||||
};
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ namespace Ryujinx.HLE
|
|||
{
|
||||
return configuration switch
|
||||
{
|
||||
MemoryConfiguration.MemoryConfiguration4GB or
|
||||
MemoryConfiguration.MemoryConfiguration4GBAppletDev or
|
||||
MemoryConfiguration.MemoryConfiguration4GBSystemDev => 4 * Gb,
|
||||
MemoryConfiguration.MemoryConfiguration6GB or
|
||||
MemoryConfiguration.MemoryConfiguration6GBAppletDev => 6 * Gb,
|
||||
MemoryConfiguration.MemoryConfiguration8GB => 8 * Gb,
|
||||
MemoryConfiguration.MemoryConfiguration4GiB or
|
||||
MemoryConfiguration.MemoryConfiguration4GiBAppletDev or
|
||||
MemoryConfiguration.MemoryConfiguration4GiBSystemDev => 4 * GiB,
|
||||
MemoryConfiguration.MemoryConfiguration6GiB or
|
||||
MemoryConfiguration.MemoryConfiguration6GiBAppletDev => 6 * GiB,
|
||||
MemoryConfiguration.MemoryConfiguration8GiB => 8 * GiB,
|
||||
_ => throw new AggregateException($"Invalid memory configuration \"{configuration}\".")
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue