Using a bitmap for paging
Building the stack before enabling paging is a bit tricky because this makes allocating the pages for the stack more difficult.bughunter wrote:I think you're overloading him with stuff. First you start with a Physical Memory Manager.
(...)
The PMM itself has _nothing_ to do with page directories or page tables itself.
You just initialize your PMM and then you create a page directory to map the kernel and page stack pages into memory, then you enable paging.
I think the PMM must be closely tied with the paging code.
Also, I think that it's best to have allocpage() and freepage() in the architecture specific code for this same reason. If the address where you are going to write the page address on the stack doesn't exist, then the best thing to do is allocate that page to the stack instead of pushing it. And this operation is architecture specific (and different architectures have paging structures of different depth and workings).
Better thinking, there are other approaches to achieve the same result. For example, if we have an allocate_to_paging_structures() architecture-specific function, that would allocate the page to whatever level of page tables needs it...
The last time I wrote paging code I had no intention to make it portable...
JJ
That's totally your point of view. For me, it doesn't make finding a free page for the stack any harder at all. It just really depends on how efficient your code is and in what way you build your stack. I could easily port my code to make it build the stack without having paging enabled.JJeronimo wrote:Building the stack before enabling paging is a bit tricky because this makes allocating the pages for the stack more difficult.bughunter wrote:I think you're overloading him with stuff. First you start with a Physical Memory Manager.
(...)
The PMM itself has _nothing_ to do with page directories or page tables itself.
You just initialize your PMM and then you create a page directory to map the kernel and page stack pages into memory, then you enable paging.
Besides, my PMM doesn't do _anything_ with page directories or page tables! In my bootstrap program I just map some pages (which is not part of the PMM code at all!) and then continue finding a free space for the stack to use and then building the stack.