You basically have to map your page tables somewhere in your page tables so that you can access them from virtual addresses.
You want to map them in your kernel address range, so somewhere at or above 0xC0000000. You will want to do this before you remove the identity mapping of the first 4MB.
The general workflow to enable memory management
-
- Member
- Posts: 106
- Joined: Sat Feb 08, 2020 11:11 am
- Libera.chat IRC: sunnysideup
Re: The general workflow to enable memory management
Or can I just keep the identity map? It seems simpler right?
Any disadvantage of keeping an identity map?
Any disadvantage of keeping an identity map?
Re: The general workflow to enable memory management
Yeah, because you're pretty basically ignoring the whole point of paging.sunnysideup wrote:Or can I just keep the identity map? It seems simpler right?
Any disadvantage of keeping an identity map?
Also if your kernel is loaded at 1 MB then you won't be able to load your programs at lower addresses, such as zero.
Also don't just map 4 MB and call it a day.
You should map just enough, according to the size of your kernel. Or you will run into random errors once your code expands beyond 4 MB. Just something to keep in mind for the future.
For sure you can have certain sections identity mapped but the whole kernel, better not.
Didn't read the whole topic, just giving some general heads up.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
-
- Member
- Posts: 106
- Joined: Sat Feb 08, 2020 11:11 am
- Libera.chat IRC: sunnysideup
Re: The general workflow to enable memory management
Thanks for the heads up!
However, I'm not identity mapping the kernel exactly... I'm identity mapping 0 - 4M, and mapping the kernel at 0xC0000000.... There's some overlap, sure, Eg. 0x100000 and 0xC0000000 are the same thing...
I was wondering this identity mapping should be temporary or permanent
Edit: I was doing a bit of reading, and it looks like 0-4M identity map could be a bad idea in the long run as user mode programs usually 'want' to run at virtual address 0.
Also, I'm guessing that the permanent higher half kernel map (where the kernel is permanently mapped at 0xC0000000 (or 2Gb)) is really useful for system calls, where the ISR will have linear address in the kernel space. Is this right?
However, I'm not identity mapping the kernel exactly... I'm identity mapping 0 - 4M, and mapping the kernel at 0xC0000000.... There's some overlap, sure, Eg. 0x100000 and 0xC0000000 are the same thing...
I was wondering this identity mapping should be temporary or permanent
Edit: I was doing a bit of reading, and it looks like 0-4M identity map could be a bad idea in the long run as user mode programs usually 'want' to run at virtual address 0.
Also, I'm guessing that the permanent higher half kernel map (where the kernel is permanently mapped at 0xC0000000 (or 2Gb)) is really useful for system calls, where the ISR will have linear address in the kernel space. Is this right?