Re: iA32 Paging




Thanks very much for that, I understand it perfectly now :)


"Jack Klein" <jackklein@xxxxxxxxxxx> wrote in message
news:b0b2a1dknh5j8lspctu5agdl0mfjprgn8s@xxxxxxxxxx
> On Fri, 3 Jun 2005 17:20:00 +0000 (UTC), "Richard Harris"
> <spamtrap@xxxxxxxxxx> wrote in comp.lang.asm.x86:
>
>> Hi,
>> I am trying to implement paging on IA32 processors.
>> Here is what I think I know:
>>
>> A Virtual Address is split up into 3 parts
>>
>> 10 bits | 10 bits | 12 bits
>> Page Dir Page Frame Offset
>
> If you are going to draw ASCII diagrams, make sure you use a fixed
> point font, otherwise they might not line up on the reader's screen.
>
>> The high ten bits are used to index into the page directory 0-1023
>> and the next ten bits index into the page frame 0-1023 and the offset
>> just gives the offset into the page.
>>
>> My problem is with the page directory and page frame data entries.
>> Each entry is 32 bits and the high 20 bits are the base address for both
>> and the low 12 bits are used for parameters like is present etc.
>>
>> Why do these entries have 20 bits ie ( 20 + 20 bits = 40 bits ). Surely
>> you
>> only need 10 bits for each entry to give you the 10 + 10 + 12 bits for
>> the
>> physical address ?
>>
>> How do I set the physical address in place in the page directory and page
>> frame data entries?
>>
>> Any help on understanding this would be most helpfull
>>
>> Thanks people!
>
> None of the bits in the 20-bit address field in the page directory
> entry has anything to do with the physical address.
>
> It works like this:
>
> 10 bits | 10 bits | 12 bits
> Page Dir Offset | Page Table Offset | Offset
>
> The top 10 bits in the linear address select one of 1,024 entries in
> the page directory table. The high 20 bits of physical address of the
> page directory are in the CR3 register.
>
> The 20 bit address in the page directory entry is the physical address
> of a page table. Each page table starts on an address that is evenly
> divisible by 4096. The 10 bit Page Table Offset from the linear
> address selects one of the 1,024 entries in the page table.
>
> The 20 bit address in the page table entry form the top 20 bits of the
> physical address. Combined with the 12 bit offset in the linear
> address, they make the full 32 bit address of a byte within the 4,096
> byte page.
>
> So the page directory table has 1,024 entries, each of which can point
> to a page table. Each page table has 1,024 entries, each of which
> points to a page. Each page has 4,096 bytes.
>
> So if you use all possible page directory and page table entries, you
> have 1,204 x 1,024 pages of 4,096 bytes each, which is exactly the
> size of the full 32-bit, 4 gig linear address space.
>
> --
> Jack Klein
> Home: http://JK-Technology.Com
> FAQs for
> comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
> comp.lang.c++ http://www.parashift.com/c++-faq-lite/
> alt.comp.lang.learn.c-c++
> http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
>


.



Relevant Pages

  • Re: iA32 Paging
    ... > Page Dir Page Frame Offset ... > My problem is with the page directory and page frame data entries. ... entry has anything to do with the physical address. ... The 10 bit Page Table Offset from the linear ...
    (comp.lang.asm.x86)
  • Re: What is the fastest way to determine if folder has subfolders or not!?
    ... | This sort of stuff does work very nicely, and is a good way of storing ... in binary tree search on 6000 entries would take 12 steps. ... for faster getting of free units, and if there is none free, using last unit offset + 1)... ... I sew VMWare has sdk for their disk format maybe beter idea would be to use their disk driver and sdk for such job. ...
    (microsoft.public.vb.winapi)
  • Re: Mounting PTP camera (reading MPO files)
    ... The diagrams in the spec look pretty useful. ... offset to next IFD ... MP ENtry 1 ... Then the offset to the next IFD actually is the image from the block to ...
    (uk.comp.sys.mac)
  • Re: [PATCH 5/9] swap_info: SWAP_HAS_CACHE cleanups
    ... -static inline bool swap_has_cache ... unsigned long offset; ... increase reference count of swap entry by 1. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH 0/5] Add second memory region for crash kernel
    ... I don't buy the argument that there is a direct connection between ... the amount of memory you have and how much memory it takes to dump it. ... We actually have a 64-bit entry point even in bzImage; it is at offset ...
    (Linux-Kernel)