Memory Management

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Memory Management

Post by pcmattman »

OK, I've found a serious problem in my kernel, and have been debating whether or not to bring it here. In the end, I decided I may as well ask for help because I'm getting nowhere.

Now I'm implementing FAT32, I'm needing to allocate large amounts of memory (ie. 8192 bytes and above). If I preallocate these buffers, I have no problem at all. However, I dislike preallocating such buffers as they are extremely un-portable.

The problem is, my memory manager at the moment is really quite useless. I just need something that doesn't worry about paging but partitions and allocates space from the end of the kernel's BSS section (btw, how do I find this out?) and then to the top of physical RAM.

Any ideas, links, tutorials or code? This problem has been chasing me for a couple of months now, I've just chosen to doge it. Hint to those who are dodging problems - don't.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

add a location entry in your linker script after the end of bss like so:

Code: Select all

end_of_bss = .;
in your c code have something like :

Code: Select all

extern char end_of_bss;
void * membase = (void *)&end_of_bss;
the membase pointer should point to the last byte used by the bss segment.
Author of COBOS
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Thanks for that, I was wondering why it didn't work earlier (I didn't realize it didn't actually have a value!).
Post Reply