mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 20:39:01 +00:00
31 lines
No EOL
938 B
C#
31 lines
No EOL
938 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Cosmos.Kernel.Boot.Glue;
|
|
|
|
namespace Cosmos.Kernel.Boot {
|
|
public static class MemoryManager {
|
|
private static uint mStartAddress;
|
|
private static uint mCurrentAddress;
|
|
private static uint mLength;
|
|
public static void Initialize(uint aStartAddress, uint aLength) {
|
|
mStartAddress = aStartAddress;
|
|
mCurrentAddress = aStartAddress;
|
|
mLength = aLength;
|
|
DebugUtil.SendMM_Init(aStartAddress, aLength);
|
|
}
|
|
|
|
[GlueMethod(MethodType = GlueMethodTypeEnum.Heap_MemAlloc)]
|
|
public static uint MemAlloc(uint aLength) {
|
|
DebugUtil.SendMM_Alloc(mCurrentAddress, aLength);
|
|
uint xResult = mCurrentAddress;
|
|
mCurrentAddress += aLength;
|
|
if (mCurrentAddress >= (mStartAddress + mLength)) {
|
|
DebugUtil.SendError("MM", "Reached maximum memory");
|
|
}
|
|
return xResult;
|
|
}
|
|
}
|
|
} |