question about paging

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

question about paging

Post 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..
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post 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. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
Post Reply