I'm starting my own OS and I don't how to start the Memory Manager, i got a little bit confused with GDT but I did it and it worked. I don't know how to allocate more memory or how to recognize that a block of memory is free or is being used. Can some body help me or just give me tip ??? xD
Sorry for my poor English ( if I wrote something wrong )
Memory Manager
mmh, man. i think you should do simple bootloader first, then turn on fat12 or else filesystem bootloader(for floppy). then you could write a simple api with print functions and other, and i think then MM would be useful. Anyway, you should do a bitmap or a bytemap, cause they're very simple. i used bytemap(1 byte hold an information about 4096 bytes of memory), so in the end of my kernel, i reserve as much bytes as my machine has memory. My old pc has 64mb of ram, so it's like 16384 bytes to hold the information about each block. Now do whatever you want, you can say that 7th bit of each bytemap block is ALLOCATED/FREE indicator so when you allocate memory, mmm, lets say 16kb, you need 4 free blocks in one line( 1,2,3,4 or 30,31,32,33) so scan your bytemap and if you find, return a pointer and handler to it. In my own memory manager handler indicates the number of the first bytemap byte. You can use more bits instead of 8, like 16 or 32 if you like. It's enough 8 bits to me, cause i just use one bit to indicate that memory is used or free. When you want to flush the memory, i think you don't need to flush it with 0s or something, just NULL the indicators in the bytemap blocks. It all left to you, you can do whatever you want to. It's only my oppinion and i described method which i used in my own MM(in summer i didn't have an internet so i had to figure out this little fucker myself). Sorry for my english too, cause i'm not very good at this language, i prefer reading than writing
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
There is something on memory management it you click the Wiki at the top of this page. Also, there are two memory management tutorials at:
http://www.osdever.net/tutorials.php?cat=0&sort=1
In the early stages of booting, however, it is (mostly) just a case of keeping track of where you put things, because there are no other programs running to mess things up. You can't use anywhere below 0x600, or from about 0x90000 up to the top of the first megabyte. You can use int 15h, ax=0xE820 to locate areas of memory you shouldn't use even during the early stages of booting.
http://www.osdever.net/tutorials.php?cat=0&sort=1
In the early stages of booting, however, it is (mostly) just a case of keeping track of where you put things, because there are no other programs running to mess things up. You can't use anywhere below 0x600, or from about 0x90000 up to the top of the first megabyte. You can use int 15h, ax=0xE820 to locate areas of memory you shouldn't use even during the early stages of booting.
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk