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.
Ive spent the last few days working on my memory manager, and although I have paging enabled and everything booted fine. Im still a bit confused about a few things, mainly with regards to higherhalf kernel.
With GRUB (if you want to set up paging right from the start)
GRUB will load your kernel at the desired physical target address, but it will leave segments in the GDT with a 0 base and it will not enable paging.
With GRUB (if you don't want to set up paging right from the start)
Even with GRUB it's still possible to use TimRobinson's GDT trick: just set up a "fake" GDT then jump to your C code and enable paging. See HigherHalfWithGdt
Is that correct about when u setup paging? I mean the higherhalfwithgdt tutorial seems to enable paging from the beginning? I dont want to enable paging from the beginning. As i understand it, if i dont enable paging from the beginning i can install interrupt handlers and the like prior to enabling paging, and so i can handle errors such as protection errors with my own functions?
At the moment I have my kernel working using the higherhalfwithgdt but i dont want to enable paging till later down my kernel initialisation.
Ive got it working now so i dont need to enable paging from the onset by tweaking about with the segment bases. Last time i tried this, i forgot to convert the address of video memory from physical to virtual since it was now somewhere just below the 3gb mark.
However now i seem to have a problem whereby when i reach the end of my kernel [ for ( ;; ) ]. bochsstops and displays:
ok, quick question regarding my physical memory manger,
now that i have segments with a base of 0x40000000 and kernel is in the higher half. The addresses of the pages that i allocate using my stack will be higher half addresses right? eg. 0xc0101000
And these are logical addresses that are converted to linear addresses using the segment base, correct? And with paging not yet enabled the linear addresses equal the physical address ?
If these are correct, I cant understand why with the higherhalf tutorial in the init_paging function, there is any need to convert the virtual address of the pagedir/table into physical addresses, wont the processor take care of this due to the segment base address?
If either a logical address or linear address were provided for cr3, that implies that the new page directory you want to switch to must already exist in the linear address space. Often this is not the case when performing task switching (you just store the physical address of each process' page dir). Thus, the cpu expects physical addresses.