I'm about to re-implement my memory manager (ATM it's just using a running integer that has the top of the heap in it).
My kernel is not going to use paging. So it should be simple to implement a memory manager, I think.
I'm thinking of implementing the same style of memory manager as shown in http://www.koders.com/c/fid2F3F21877FD9 ... C4A26.aspx
Is this a good system, or is there a better, more efficient way of doing this?
Memory Management: Will this work?
I'm glad you have your memory manager working but I thought maybe this will help you if you want to code your own memory manager. I am coding in NASM and thus I have to keep track of every memory location that I use. For now I am using MEGABYTE(0) to MEGABYTE(16) for my kernel and MEGABYTE(16) to MEGABYTE(24) for my physical memory manager's free space and I have defined constant values like this:
And I always refer to these instead of using variable memory locations and so if I need to change the location of these values I will just change the way they are declared.
Code: Select all
; ——————————————————————————————————————————————————
MEM_MAP_KERNEL_DOMAINSTART EQU MEGABYTE(0)
MEM_MAP_KERNEL_DOMAINLENGTH EQU MEGABYTE(8)
MEM_MAP_KERNEL_DOMAINEND EQU MEM_MAP_KERNEL_DOMAINSTART + MEM_MAP_KERNEL_DOMAINLENGTH - 1
MEM_MAP_KERNEL_ENTRY EQU MEGABYTE(1)
; ——————————————————————————————————————————————————
MEM_MAP_PDES_DOMAINSTART EQU MEM_MAP_KERNEL_DOMAINEND + 1
MEM_MAP_PDES_DOMAINLENGTH EQU KILOBYTE(4)
MEM_MAP_PDES_DOMAINEND EQU MEM_MAP_PDES_DOMAINSTART + MEM_MAP_PDES_DOMAINLENGTH - 1
MEM_MAP_PDES_ENTRY EQU MEM_MAP_PDES_DOMAINSTART
; ——————————————————————————————————————————————————
MEM_MAP_PTES_DOMAINSTART EQU MEM_MAP_PDES_DOMAINEND + 1
MEM_MAP_PTES_DOMAINLENGTH EQU MEGABYTE(4)
MEM_MAP_PTES_DOMAINEND EQU MEM_MAP_PTES_DOMAINSTART + MEM_MAP_PTES_DOMAINLENGTH - 1
MEM_MAP_PTES_ENTRY EQU MEM_MAP_PTES_DOMAINSTART
; ——————————————————————————————————————————————————
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.