Page 1 of 1

vesa identity paging 1:1

Posted: Sun Feb 20, 2011 6:26 am
by lama
hello and welcome to my another lame post.
many months ago i have setuped basic vesa environment (my system's default video mode is 80x25 textmode). I'm using 1:1 paging, where virtual address means the same physical address, my page directory starts at 0x100000 (1M) and so far i needed only one page table (that's 4Megs). But now i need to access the vesa linear buffer at non-existent memory 0xc0000000 - so i need map these pages too. I'm tired to turn off paging every time a switch to vesa. And with paging off, system ofcourse behaves dodgy, so i need to have it on all the time. i'm very confused by now :D 0xc0000000 is about 3Gigs, so that would be page table no. 768 i guess. if my page directory starts at 1M, then location of that table (no. 768) must be 0x100C00 (each entry has 32bits). And now what, my first page table at 1M has address 0x101000 where all that pages up to 4Megs are mapped. So what address should the 768. page table have? 0xc00*0x1000+0x100000? evidently nope, i throwing nonsences here.. damm, can anyone please tell me how to map these pages to 1:1?
thanks a lot

Re: vesa identity paging 1:1

Posted: Sun Feb 20, 2011 8:41 am
by Chandra
lama wrote:hello and welcome to my another lame post.
many months ago i have setuped basic vesa environment (my system's default video mode is 80x25 textmode). I'm using 1:1 paging, where virtual address means the same physical address, my page directory starts at 0x100000 (1M) and so far i needed only one page table (that's 4Megs). But now i need to access the vesa linear buffer at non-existent memory 0xc0000000 - so i need map these pages too. I'm tired to turn off paging every time a switch to vesa. And with paging off, system ofcourse behaves dodgy, so i need to have it on all the time. i'm very confused by now :D 0xc0000000 is about 3Gigs, so that would be page table no. 768 i guess. if my page directory starts at 1M, then location of that table (no. 768) must be 0x100C00 (each entry has 32bits). And now what, my first page table at 1M has address 0x101000 where all that pages up to 4Megs are mapped. So what address should the 768. page table have? 0xc00*0x1000+0x100000? evidently nope, i throwing nonsences here.. damm, can anyone please tell me how to map these pages to 1:1?
thanks a lot
Simple. Create a new page table to map the linear frame buffer. You need 4kb pages here.Map the 4Mb of frame buffer memory with this page table.Then pass the address of this page table to entry no 768 in the page directory. Simple as that, if I understood your question correctly.

Re: vesa identity paging 1:1

Posted: Sun Feb 20, 2011 5:43 pm
by Brendan
Hi,
lama wrote:So what address should the 768. page table have? 0xc00*0x1000+0x100000? evidently nope, i throwing nonsences here.. damm, can anyone please tell me how to map these pages to 1:1?
If you're only ever going to map things 1:1, then don't bother using paging.

If you plan to take advantage of paging sooner or later (for example, to have separate virtual address spaces for different applications/processes), then you will need to decide which areas of the virtual address space will be used for what. For example, you might have a large area intended for "user space" and another big area intended for "kernel space". Then you might split "kernel space" into smaller areas - for example, one area for kernel code and data and one area for memory mapped devices (e.g. video cards, etc).

For example, given that you've already identity mapped the first 4 MiB, then maybe kernel space is from 0x00000000 to 0x3FFFFFFF and user space is from 0x40000000 to 0xFFFFFFFF; and kernel space should be split into an identity mapped area from 0x00000000 to 0x1FFFFFFF and another area from 0x20000000 to 0x3FFFFFFF for mapping things like video display memory.

Of course for most OSs, kernel space is at the highest part of the virtual address space. For example, user space from 0x00000000 to 0xBFFFFFFF, with kernel space from 0xC0000000 to 0xFFFFFFFF. This makes things look nice and clean for processes, and means you can change the size of user space easily. It also means that nothing is mapped 1:1. However, in this case you might still temporarily do a 1:1 mapping during boot (before you've setup paging properly) to make the transition easier, and discard that 1:1 mapping after paging is setup properly.


Cheers,

Brendan

Re: vesa identity paging 1:1

Posted: Wed Feb 23, 2011 4:17 pm
by lama
thanks guys, it's working now. it took me a little while to get it completly working, but it's done now. and yes brendan - you are absolutly right :) i actualy don't need paging (1:1 for the entire memory seems to be completly useless :D ), i have only setuped it for error checking - whenever some application, driver or whatever access memory that it should not, i will know about it right away and i can shutdown it / or allocate more memory and so on.
thanks again, this thread can be locked now.