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