aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Memory/AMemoryAlloc.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Memory/AMemoryAlloc.cs')
-rw-r--r--ChocolArm64/Memory/AMemoryAlloc.cs35
1 files changed, 35 insertions, 0 deletions
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