/* * mem-phys.c * * Created on: Aug 27, 2011 * Author: Tiberiu */ #include uint32* FrameMap; uint32 TotalFrames; uint32 TotalMemory; uint32 UsedFrames; inline void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset) { *address = (index >> 5); *offset = index & 0x1f; } inline uint32 ConvertFrameToIndex (uint32 address, uint32 offset) { return (address<<5) | offset; } void MemPhSetFrame (uint32 frame, uint8 value) { uint32 addr, off; ConvertIndexToFrame(frame, &addr, &off); if (value) { if ((FrameMap[addr] & (1<> 5; addr++) if (FrameMap[addr] != 0xffffffff) { for (pos = 0; (FrameMap[addr] & (1<> 2; TotalMemory = SystemMemoryKb; FrameMap = (uint32*) kmalloc(sizeof(uint32) * (1 + (TotalFrames>>5))); memset(FrameMap, 0, sizeof(uint32) * (1 + (TotalFrames>>5))); Log("Mem", "%#Started physical memory manager ok!, found %ukb\n", ColorLightGreen, SystemMemoryKb); } void MemPhReserveFrames (uint32 address, uint32 length) { address >>= 12; length = (length>>12) + ((length & 0xfff) > 0); uint32 end = address + length; for (; address < end ; address++) MemPhSetFrame(address, 1); }