mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-25 07:32:54 +00:00
fb1d9493a3
* Rename enum fields * Naming conventions * Remove unneeded ".this" * Remove unneeded semicolons * Remove unused Usings * Don't use var * Remove unneeded enum underlying types * Explicitly label class visibility * Remove unneeded @ prefixes * Remove unneeded commas * Remove unneeded if expressions * Method doesn't use unsafe code * Remove unneeded casts * Initialized objects don't need an empty constructor * Remove settings from DotSettings * Revert "Explicitly label class visibility" This reverts commit ad5eb5787cc5b27a4631cd46ef5f551c4ae95e51. * Small changes * Revert external enum renaming * Changes from feedback * Apply previous refactorings to the merged code
80 lines
2.1 KiB
C#
80 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
{
|
|
class KPageList : IEnumerable<KPageNode>
|
|
{
|
|
public LinkedList<KPageNode> Nodes { get; private set; }
|
|
|
|
public KPageList()
|
|
{
|
|
Nodes = new LinkedList<KPageNode>();
|
|
}
|
|
|
|
public KernelResult AddRange(ulong address, ulong pagesCount)
|
|
{
|
|
if (pagesCount != 0)
|
|
{
|
|
if (Nodes.Last != null)
|
|
{
|
|
KPageNode lastNode = Nodes.Last.Value;
|
|
|
|
if (lastNode.Address + lastNode.PagesCount * KMemoryManager.PageSize == address)
|
|
{
|
|
address = lastNode.Address;
|
|
pagesCount += lastNode.PagesCount;
|
|
|
|
Nodes.RemoveLast();
|
|
}
|
|
}
|
|
|
|
Nodes.AddLast(new KPageNode(address, pagesCount));
|
|
}
|
|
|
|
return KernelResult.Success;
|
|
}
|
|
|
|
public ulong GetPagesCount()
|
|
{
|
|
ulong sum = 0;
|
|
|
|
foreach (KPageNode node in Nodes)
|
|
{
|
|
sum += node.PagesCount;
|
|
}
|
|
|
|
return sum;
|
|
}
|
|
|
|
public bool IsEqual(KPageList other)
|
|
{
|
|
LinkedListNode<KPageNode> thisNode = Nodes.First;
|
|
LinkedListNode<KPageNode> otherNode = other.Nodes.First;
|
|
|
|
while (thisNode != null && otherNode != null)
|
|
{
|
|
if (thisNode.Value.Address != otherNode.Value.Address ||
|
|
thisNode.Value.PagesCount != otherNode.Value.PagesCount)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
thisNode = thisNode.Next;
|
|
otherNode = otherNode.Next;
|
|
}
|
|
|
|
return thisNode == null && otherNode == null;
|
|
}
|
|
|
|
public IEnumerator<KPageNode> GetEnumerator()
|
|
{
|
|
return Nodes.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
} |