Granted, many aspects of OS-dev can easily spin one's head, but this
one has taken me far beyond the spinning point.
May I inquire of you to clear my head by explaining 3 points of this:
1) Why would one do this.. what will it accomplish?
2) What other benifits might one reap?
3) What dis-advantages { other than this confusion } might one run up
against?
My thanks in advance,
Christopher.
P.S. In reply to your answer, I am likely to ask about alternatives
to this method, as well as discuss the efficiences of each.
Thanks once again.
> In some tutorials on OS development, I came acrossed a few that
> discussed ever-so-lightly about using the last entry of a Page Directory
> to map back to the physical address of the Directory itself.
> 1) Why would one do this.. what will it accomplish?
It will give you a 4MB region of linear space that is an array of all
PTEs. This happens because the page directory contains addresses of page
tables; when the pdir is used as a ptab then the ptab pointers become page
frame pointers, thus each present page table becomes a page in the linear
space. This will also give you a page in linear space that is the page
directory. Think about it from the perspective of the MMU - follow the
pointers in the tables like it would, and I think it'll clear up your
confusion.
> 2) What other benifits might one reap?
Easy access to the PTEs and PDEs, without having to have access to the
physical memory directly. You can also map in other address spaces' page
directories as page tables, allowing you to manipulate another processes'
address space.
> 3) What dis-advantages { other than this confusion } might one run up
> against?
Not many, really. The only thing to watch out for is that not-present page
tables will give not-present pages in the 4MB region.
Hope this helps
--
Chris Fallin
Email : ch...@cfallin.org
speck OS: http://speck.cfallin.org/
Automatic mapping of PTE tables to some virtual addresses.
> 3) What dis-advantages { other than this confusion } might one run
up
> against?
I see no of them. All OSes known to me use this - though not necessary
the last PTE, maybe, say, PTE #768.
Max
Thank you both for your input.
Yes, I can see why the self-mapping would not *have* to be the last
entry, as moving the self-mapping to another point in the Dir would
move the PDE as PTE, to just another place in the Virt. Address
space... correct??
Are there currently any other alternatives to this method??
Thanks again,
Christopher.
Yes, by using 2 page directories per process.
Allocate 2 page directories per process and map them
somewhere in the kernel virtual memory area.
The 'real' page directory is used by the processor and
contains the flags and the physical addresses of the page
tables.
The 'virtual' page directory is used to find the location
of the page tables in the kernel's virtual memory area.
Whenever a page table is allocated map it into the
kernel virtual memory area.
Set the entry in the 'real' page directory to its physical
address. Set the entry in the 'virtual' page directory to
the virtual address it was mapped into the kernel virtual
memory area.
The page tables and directories of all processes will
be visible within the kernel area of memory.
Do a search of Google Groups for "virtual page directory"
"real page directory", or "KernelPage". I've explained it
in a previous post in more detail.
Marv