FusT wrote:
Quote:
How would I put it in a page frame if I can only allocated page frames after the stack/bitmap has been initialized?
What I do is get a pointer to the kernel's end (actually, the top of the kernel's stack) and put my PMM's bitmap right after that address.
When the bitmap has been initialized I mark everything from kernel start to kernel stack top + the size of the bitmap as used.
Quote:
When I return a page frame, I am just returning a memory address, correct?
If you mean "return a pointer to a memory address" then yes.
Quote:
which means that it would be a struct or what?
A page frame is basically a 4Kib piece of aligned address space, what you use to represent it is up to you.
I search through the bitmap for a large enough "hole" but you could also use a linked list, stack, array of structs or whatever you like best.
Please be cautious and add 512 bytes to your kernel end. I've seen people (including me) having problems with kernel_end because there was data right after it, if you want to avoid overwriting your kernel data/code do this first.
You can put your bitmap right after kernel_end + 512 bytes of padding, make sure to map your entire bitmap or else you will see triple faults.
Make sure every bit that your bitmap physically uses is reserved inside your PMM, you do not want to overwrite your bitmap.
As suggested, you should mark everything from kernel_start to kernel_end + 512 bytes of padding + "size_of"(bitmap) as used.
4 KB aligned = addresses that are 4096 bytes apart, such as 0x1000 0x2000 0x3000 0x4000 and your will recognize page aligned address by the last 3 digits being zero.
It can but doesn't need to be a pointer, it can be just a number that could later become anything. You can just return uint32_ts and uint64_ts respectively. (easier to cast in C++, that is how I do it)
I am really curious about your struct + array technique. How do you handle different area counts? One computer can have 3 free chunks and the other can have 333 free chunks. What about that? Dynamic allocation I guess, no?
I would suggest you waiting for @LtG to reply. He has some some experience and knowledge about stack based implementations, so you can ask him more about that. There was an ongoing memory discussion recently, feel free to check it out, it can give you some ideas.