AMemoryAlloc.cs 673 B

1234567891011121314151617181920212223242526272829303132333435
  1. using ChocolArm64.Exceptions;
  2. namespace ChocolArm64.Memory
  3. {
  4. public class AMemoryAlloc
  5. {
  6. private long PhysPos;
  7. public long Alloc(long Size)
  8. {
  9. long Position = PhysPos;
  10. Size = AMemoryHelper.PageRoundUp(Size);
  11. PhysPos += Size;
  12. if (PhysPos > AMemoryMgr.RamSize || PhysPos < 0)
  13. {
  14. throw new VmmOutOfMemoryException(Size);
  15. }
  16. return Position;
  17. }
  18. public void Free(long Position)
  19. {
  20. //TODO
  21. }
  22. public long GetFreeMem()
  23. {
  24. return AMemoryMgr.RamSize - PhysPos;
  25. }
  26. }
  27. }