My Kernel is loaded at 0x1000 in memory because I know I should not touch memory between 0x0000 and 0x1000. But I was wandering if it was safe not to map the first memory page (0x0000) when enabling paging?
I would then get a page fault if I try to access / modify memory below 0x1000.
Thanks for your answer, regards.
Memory from 0x0000 to 0x1000, safe not to map ?
-
- Member
- Posts: 5586
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Memory from 0x0000 to 0x1000, safe not to map ?
You don't need to map memory you're not going to use.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Thanks for the reply, that means that the kernel will never have to use memory below 0x1000 ?
In this case I agree I don't need to map it
In this case I agree I don't need to map it
- bellezzasolo
- Member
- Posts: 110
- Joined: Sun Feb 20, 2011 2:01 pm
Re: Memory from 0x0000 to 0x1000, safe not to map ?
My kernel maps low memory at times (despite being 32/64 bit). Obviously, there's the VGA error. But 0x0-0x1000 comes into use too.LIC wrote:My Kernel is loaded at 0x1000 in memory because I know I should not touch memory between 0x0000 and 0x1000. But I was wandering if it was safe not to map the first memory page (0x0000) when enabling paging?
I would then get a page fault if I try to access / modify memory below 0x1000.
Thanks for your answer, regards.
The last bit of code I wrote hit 0x40E. That's usually the location of the EBDA (stored in the BDA). That's part of my code searching for the ACPI RSDP.
Heck, I've used the IVT before. If you drop into real mode to change graphics mode, you need the IVT.
So yeah, you may want to touch that memory at some point.
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
https://github.com/ChaiSoft/ChaiOS
Re: Memory from 0x0000 to 0x1000, safe not to map ?
Are you talking about physical or virtual addresses?
You may well need to access physical addresses at the bottom end of memory (i.e. for the MMIO in the 640KB-1MB region, maybe the (E)BDA or real-mode IVT), but there's no particular reason why that has to be mapped into the low virtual addresses (well, unless you're using V86 for something).
Personally, my OS identity maps the first 1MB at boot, except for the very first page, to provide easy trapping of NULL pointer dereferences. For access to the IVT (used by my VBE code which runs the BIOS in an x86 emulator), the first physical page is mapped (upon request) to some other unused address.
You may well need to access physical addresses at the bottom end of memory (i.e. for the MMIO in the 640KB-1MB region, maybe the (E)BDA or real-mode IVT), but there's no particular reason why that has to be mapped into the low virtual addresses (well, unless you're using V86 for something).
Personally, my OS identity maps the first 1MB at boot, except for the very first page, to provide easy trapping of NULL pointer dereferences. For access to the IVT (used by my VBE code which runs the BIOS in an x86 emulator), the first physical page is mapped (upon request) to some other unused address.
Re: Memory from 0x0000 to 0x1000, safe not to map ?
okay, thanks for your replies.
I think I am going to do it mallard's way to detect NULL pointer error and I'll map bottom memory to another address I if I need to.
I am talking about physical memory.Are you talking about physical or virtual addresses?
I think I am going to do it mallard's way to detect NULL pointer error and I'll map bottom memory to another address I if I need to.