Page 1 of 1

mapping and page tables?

Posted: Sun Jan 05, 2003 8:32 pm
by nullify
Ok, I have a function map_page( ) which maps in a page of memory. Let's hypothetically say that map_page( ) is trying to map in a page that does not have the proper page table present. Should the function automatically create the page table, or return an error code?

Re:mapping and page tables?

Posted: Mon Jan 06, 2003 1:41 am
by Pype.Clicker
what about map_page(PGMAP_AUTO) ?

if the PGMAP_AUTO flag is set, then needed entries are automatically allocated (including page table, etc.) and otherwise an error is returned ;-)

So that you can use the very same function for memory allocation (if you're filling a large virtual array, PGMAP_AUTO is set ... if you're responding to a #page fault from user mode, PGMAP_AUTO is likely to be cleared).

Re:mapping and page tables?

Posted: Mon Jan 06, 2003 2:44 am
by Tim
What reason could there be for not allocating the page table if none exists? If there is no page table there, then the address is not mapped.

Re:mapping and page tables?

Posted: Mon Jan 06, 2003 4:10 am
by DarylD
I agree with Tim, if you don't create a page table entry then it *wont* work.

My code just checks for the existence of a PTE when it crosses a PT boundary and creates if necessary.

Re:mapping and page tables?

Posted: Mon Jan 06, 2003 6:47 am
by Pype.Clicker
oh, i was assuming that maybe the user may have requested an allocation for a memory address he shouldn't request and maybe we shouldn't allocate in that case ...

Re:mapping and page tables?

Posted: Mon Jan 06, 2003 3:01 pm
by nullify
Yeah, I initially was going to just have it automatically allocate everything, but then I thought it should prevent the user from allocating from areas that shouldn't be allocated, like Pype.Clicker mentioned. Figured I'd ask to see what's the best system of doing things. :-)

I like Pype.Clicker's idea with a PGMAP_AUTO type of flag to toggle the functionality, that's probably what I'll do.

Thanks for the help everyone.