Page 1 of 1

question about paging

Posted: Wed Dec 05, 2007 10:12 am
by digo_rp
I have a multitasking kernel ring3 protection vm86 using software taskswitching. now I´m trying to implement each task to have it own page directory. util now ok!

but to load a flat binary image to a memory that is linked into 0x400000 I had to map that 0x400000 into physical addres that binary image is loaded, ok? good.

but now is my big question...

do I have to map the kernel memory into page directory for all tasks ?

if I do that works! ?

I just need to change CR3 on irq00 when before popa/pop ds... .. .. right ?

or I do need to change cr3 into all irq00-15 isr0-31 hander ?

I´m trying to read intel manual 3 but is big..

Posted: Wed Dec 05, 2007 10:33 am
by AJ
Hi,

Some of what you ask is a matter of design preference, but yes, I would generally map the kernel region in to all memory spaces. If you do this, you will not need to reload CR3 on each interrupt / system call. And yes - simply change CR3 before you pop the registers of the incoming task.

This can also assist you with a method of not needing to change ESP0 in your TSS - the stack can be mapped in to the same location in each page directory (pointing to different physical RAM).

Just one issue - I personally advise against flat binaries. I know they initially make relocation slightly easier, but you will find a format such as ELF/COFF much better in the long run (accurate BSS size etc...).

Cheers,
Adam

Posted: Thu Dec 06, 2007 2:32 pm
by mystran
I personally would still suggest flat binaries multi-tasked first (and preferably even allocating virtual memory dynamically) before messing with stuff like ELF which has like 10 thousand new things that can go bogus. :)

Yes, in the long run ELF is a good idea, but it's impossible to write software such as a kernel without doing one thing at a time. :)