mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-26 15:25:46 +00:00
00579927e4
* Initial implementation of KProcess * Some improvements to the memory manager, implement back guest stack trace printing * Better GetInfo implementation, improve checking in some places with information from process capabilities * Allow the cpu to read/write from the correct memory locations for accesses crossing a page boundary * Change long -> ulong for address/size on memory related methods to avoid unnecessary casts * Attempt at implementing ldr:ro with new KProcess * Allow BSS with size 0 on ldr:ro * Add checking for memory block slab heap usage, return errors if full, exit gracefully * Use KMemoryBlockSize const from KMemoryManager * Allow all methods to read from non-contiguous locations * Fix for TransactParcelAuto * Address PR feedback, additionally fix some small issues related to the KIP loader and implement SVCs GetProcessId, GetProcessList, GetSystemInfo, CreatePort and ManageNamedPort * Fix wrong check for source pages count from page list on MapPhysicalMemory * Fix some issues with UnloadNro on ldr:ro
80 lines
No EOL
2.1 KiB
C#
80 lines
No EOL
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();
|
|
}
|
|
}
|
|
} |