mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-21 06:02:02 +00:00
86fd0643c2
* Implement support for page sizes > 4KB * Check and work around more alignment issues * Was not meant to change this * Use MemoryBlock.GetPageSize() value for signal handler code * Do not take the path for private allocations if host supports 4KB pages * Add Flags attribute on MemoryMapFlags * Fix dirty region size with 16kb pages Would accidentally report a size that was too high (generally 16k instead of 4k, uploading 4x as much data) Co-authored-by: riperiperi <rhy3756547@hotmail.com>
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using System;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel.Memory
|
|
{
|
|
class SharedMemoryStorage
|
|
{
|
|
private readonly KernelContext _context;
|
|
private readonly KPageList _pageList;
|
|
private readonly ulong _size;
|
|
|
|
public SharedMemoryStorage(KernelContext context, KPageList pageList)
|
|
{
|
|
_context = context;
|
|
_pageList = pageList;
|
|
_size = pageList.GetPagesCount() * KPageTableBase.PageSize;
|
|
|
|
foreach (KPageNode pageNode in pageList)
|
|
{
|
|
ulong address = pageNode.Address - DramMemoryMap.DramBase;
|
|
ulong size = pageNode.PagesCount * KPageTableBase.PageSize;
|
|
context.CommitMemory(address, size);
|
|
}
|
|
}
|
|
|
|
public void ZeroFill()
|
|
{
|
|
for (ulong offset = 0; offset < _size; offset += sizeof(ulong))
|
|
{
|
|
GetRef<ulong>(offset) = 0;
|
|
}
|
|
}
|
|
|
|
public ref T GetRef<T>(ulong offset) where T : unmanaged
|
|
{
|
|
if (_pageList.Nodes.Count == 1)
|
|
{
|
|
ulong address = _pageList.Nodes.First.Value.Address - DramMemoryMap.DramBase;
|
|
return ref _context.Memory.GetRef<T>(address + offset);
|
|
}
|
|
|
|
throw new NotImplementedException("Non-contiguous shared memory is not yet supported.");
|
|
}
|
|
|
|
public KPageList GetPageList()
|
|
{
|
|
return _pageList;
|
|
}
|
|
}
|
|
}
|