blob: 167e0aa90d6dd497249c5f2e4873979801af1f8f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
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.Memory.Commit(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;
}
}
}
|