From 62b827f474f0aa2152dd339fcc7cf31084e16a0b Mon Sep 17 00:00:00 2001 From: emmauss Date: Tue, 20 Feb 2018 22:09:23 +0200 Subject: Split main project into core,graphics and chocolarm4 subproject (#29) --- ChocolArm64/Memory/AMemoryAlloc.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ChocolArm64/Memory/AMemoryAlloc.cs (limited to 'ChocolArm64/Memory/AMemoryAlloc.cs') diff --git a/ChocolArm64/Memory/AMemoryAlloc.cs b/ChocolArm64/Memory/AMemoryAlloc.cs new file mode 100644 index 00000000..b11e7793 --- /dev/null +++ b/ChocolArm64/Memory/AMemoryAlloc.cs @@ -0,0 +1,35 @@ +using ChocolArm64.Exceptions; + +namespace ChocolArm64.Memory +{ + public class AMemoryAlloc + { + private long PhysPos; + + public long Alloc(long Size) + { + long Position = PhysPos; + + Size = AMemoryHelper.PageRoundUp(Size); + + PhysPos += Size; + + if (PhysPos > AMemoryMgr.RamSize || PhysPos < 0) + { + throw new VmmOutOfMemoryException(Size); + } + + return Position; + } + + public void Free(long Position) + { + //TODO + } + + public long GetFreeMem() + { + return AMemoryMgr.RamSize - PhysPos; + } + } +} \ No newline at end of file -- cgit v1.2.3