mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2025-06-29 23:10:47 -07:00
Move solution and projects to src
This commit is contained in:
78
src/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs
Normal file
78
src/Ryujinx.HLE/HOS/Kernel/Common/KSystemControl.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using Ryujinx.HLE.HOS.Kernel.Memory;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Common
|
||||
{
|
||||
static class KSystemControl
|
||||
{
|
||||
private const ulong KiB = 1024;
|
||||
private const ulong MiB = 1024 * KiB;
|
||||
private const ulong GiB = 1024 * MiB;
|
||||
|
||||
private const ulong PageSize = 4 * KiB;
|
||||
|
||||
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.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}\".")
|
||||
};
|
||||
}
|
||||
|
||||
public static ulong GetAppletPoolSize(MemoryArrange arrange)
|
||||
{
|
||||
return arrange switch
|
||||
{
|
||||
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}\".")
|
||||
};
|
||||
}
|
||||
|
||||
public static ulong GetMinimumNonSecureSystemPoolSize()
|
||||
{
|
||||
return RequiredNonSecureSystemPoolSize;
|
||||
}
|
||||
|
||||
public static ulong GetDramEndAddress(MemorySize size)
|
||||
{
|
||||
return DramMemoryMap.DramBase + GetDramSize(size);
|
||||
}
|
||||
|
||||
public static ulong GenerateRandom()
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ulong GetDramSize(MemorySize size)
|
||||
{
|
||||
return size switch
|
||||
{
|
||||
MemorySize.MemorySize4GiB => 4 * GiB,
|
||||
MemorySize.MemorySize6GiB => 6 * GiB,
|
||||
MemorySize.MemorySize8GiB => 8 * GiB,
|
||||
_ => throw new ArgumentException($"Invalid memory size \"{size}\".")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user