2018-03-12 05:04:52 +01:00
|
|
|
using ChocolArm64.Memory;
|
2018-02-17 22:36:08 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-06-11 02:46:42 +02:00
|
|
|
namespace Ryujinx.HLE.OsHle.Handles
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
|
|
|
class HSharedMem
|
|
|
|
{
|
2018-03-12 05:04:52 +01:00
|
|
|
private List<(AMemory, long)> Positions;
|
2018-02-17 22:36:08 +01:00
|
|
|
|
|
|
|
public EventHandler<EventArgs> MemoryMapped;
|
|
|
|
public EventHandler<EventArgs> MemoryUnmapped;
|
2018-02-05 00:08:20 +01:00
|
|
|
|
2018-02-28 00:45:07 +01:00
|
|
|
public HSharedMem()
|
2018-02-05 00:08:20 +01:00
|
|
|
{
|
2018-03-12 05:04:52 +01:00
|
|
|
Positions = new List<(AMemory, long)>();
|
2018-02-17 22:36:08 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public void AddVirtualPosition(AMemory Memory, long Position)
|
2018-02-17 22:36:08 +01:00
|
|
|
{
|
|
|
|
lock (Positions)
|
|
|
|
{
|
2018-03-12 05:04:52 +01:00
|
|
|
Positions.Add((Memory, Position));
|
2018-02-17 22:36:08 +01:00
|
|
|
|
2018-02-20 11:54:00 +01:00
|
|
|
MemoryMapped?.Invoke(this, EventArgs.Empty);
|
2018-02-17 22:36:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public void RemoveVirtualPosition(AMemory Memory, long Position)
|
2018-02-17 22:36:08 +01:00
|
|
|
{
|
|
|
|
lock (Positions)
|
|
|
|
{
|
2018-03-12 05:04:52 +01:00
|
|
|
Positions.Remove((Memory, Position));
|
2018-02-17 22:36:08 +01:00
|
|
|
|
2018-02-20 11:54:00 +01:00
|
|
|
MemoryUnmapped?.Invoke(this, EventArgs.Empty);
|
2018-02-17 22:36:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 05:04:52 +01:00
|
|
|
public (AMemory, long)[] GetVirtualPositions()
|
2018-02-17 22:36:08 +01:00
|
|
|
{
|
2018-03-05 06:09:52 +01:00
|
|
|
return Positions.ToArray();
|
2018-02-05 00:08:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|