OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 4:23 am 
Offline
Member
Member

Joined: Mon Jun 04, 2018 8:10 am
Posts: 44
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.


Top
 Profile  
 
 Post subject: Re: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 4:33 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5137
You don't need to map memory you're not going to use.


Top
 Profile  
 
 Post subject: Re: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 4:51 am 
Offline
Member
Member

Joined: Mon Jun 04, 2018 8:10 am
Posts: 44
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 :)


Top
 Profile  
 
 Post subject: Re: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 7:12 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 20, 2011 2:01 pm
Posts: 110
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.

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.
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


Top
 Profile  
 
 Post subject: Re: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 10:12 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Memory from 0x0000 to 0x1000, safe not to map ?
PostPosted: Fri Mar 08, 2019 2:17 pm 
Offline
Member
Member

Joined: Mon Jun 04, 2018 8:10 am
Posts: 44
okay, thanks for your replies.

Quote:
Are you talking about physical or virtual addresses?


I am talking about physical memory.

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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], MichaelPetch and 178 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group