1:1 ident mapping

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
Whatever5k

1:1 ident mapping

Post by Whatever5k »

Tim Robinson told me you shouldn't use 1:1 mapping (virtual 0 = physical 0) because you couldn't use V86 mode. Is that right? Because I think it saves lot of problems and I saw many OS's which also uses 1:1 mapping (AFAIK Linux also does that for kernel address space)...
What do you think, is it bad to use 1:1 mapping?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:1:1 ident mapping

Post by Pype.Clicker »

i don't think it's bad (i do it) unless you want to have several VM86 tasks running together. Then you'll have to break that 1:1 correspondance.

Note that you still can use safely 1:1 from above 1MB only :)
drizzt

Re:1:1 ident mapping

Post by drizzt »

If you use 1:1 mapping, your V86 code must be placed below 1MB, because V86 code is limited by 16bit addressing... So you CAN use v86 mode... you have only this constraint.
Moreover, for the same reason, you cannot run more than one task at once unless you prevent memory overlap between every v86 tasks... Paging not with a 1:1 mapping allows to you to put every v86 tasks wherever you want in the virtual address space... and this allows to you to have many v86 tasks running at the same time...

oops pype you're arrived before me... ;)
Whatever5k

Re:1:1 ident mapping

Post by Whatever5k »

i don't think it's bad (i do it) unless you want to have several VM86 tasks running together.
What is this VM86, actually? Will I need it? And can I use multitasking without VM86?
Note that you still can use safely 1:1 from above 1MB only
Well, that's true - but then you have a problem with your printf() function since the video memory (below 1 MB) won't get mapped...
drizzt

Re:1:1 ident mapping

Post by drizzt »

VM86 means "Virtual 8086 mode". This is the best way to execute real mode programs when you are in protected mode... in this mode you can take the protected mode facilities and real mode hardware assistance (BIOS INTs), because in virtual 8086 mode an 8086 program runs as a separate protected mode task...

...but I think there are some sources that can explain better than me this argument. If you want to have an idea about this argument you can read the Tim Robinson's tutorial (the best tutorial I've found!!!). You can find this here:

http://www.cyberscriptorium.com/osjourn ... le&file=10

Or if you want a more detailed hardware references about V86 mode read the Pentium manuals from the Intel web site (Volume 3, Chapter 16 - 8086 Emulation).

-Update-
Here is the link:
ftp://download.intel.com/design/Pentium4/manuals/
drizzt

Re:1:1 ident mapping

Post by drizzt »

Well, that's true - but then you have a problem with your printf() function since the video memory (below 1 MB) won't get mapped...
Why?! If you map the first 1MB you also map the video memory buffer:

0xB0000 == 704.896bytes
...
0xC0000 == 786.432bytes
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:1:1 ident mapping

Post by Pype.Clicker »

What you can safely do (and what is, imho, the best option) is to map the first 4MB in 1:1, but only use 1MB..(4MB-1) for your kernel. So in case you need to access the BIOS, etc. you still can, and as there will be no logical addresses from the kernel using the 0..1MB virtual addresses area, you can come with VM86 tasks whenever you want.

That way, the Bios, etc. is still mapped and you can use it for VRAM access. frames from (0x1000:0 to 0x9000:ffff) can be reused later for another something else if you wish so (but then it wouldn't be 1:1 anymore).
Whatever5k

Re:1:1 ident mapping

Post by Whatever5k »

Pype:
What you can safely do (and what is, imho, the best option) is to map the first 4MB in 1:1, but only use 1MB..(4MB-1) for your kernel. So in case you need to access the BIOS, etc. you still can, and as there will be no logical addresses from the kernel using the 0..1MB virtual addresses area, you can come with VM86 tasks whenever you want.
Let's see if I got you right...:
You want to map the first 4 MB, but only 1MB - 4MB should be used by the kernel...this way you have still mapped video memory. If you want to have V86Mode, you have to remap the first MB, right?
But then, we couldn't use video memory anymore...

drizzt:
Why?! If you map the first 1MB you also map the video memory buffer:
Pype was talking about mapping from above 1MB...
drizzt

Re:1:1 ident mapping

Post by drizzt »

Pype was talking about mapping from above 1MB...
oops.. I hadn't read well... sorry ::)
... but I don't see the problem...

why don't you map the memory buffer from 0xB0000 to 0xC0000 as present, user level, read-write?!
Then you can map the BIOS IVT & CMOS area as user, read-only, present.

Doing so both your kernel and your v86 tasks can access to the video mem.

I think the problem come only if your kernel is placed below 1MB...
Whatever5k

Re:1:1 ident mapping

Post by Whatever5k »

Ok, this might work...anyway, my kernel is loaded by GRUB, it is therefore placed at 1MB...everything fine :)
drizzt

Re:1:1 ident mapping

Post by drizzt »

...you can always load a second stage loader that loads the kernel and copies it beyond 1MB ;)
Whatever5k

Re:1:1 ident mapping

Post by Whatever5k »

Uh? Why should I do that? GRUB already does that!
Post Reply