1:1 ident mapping
1:1 ident mapping
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?
What do you think, is it bad to use 1:1 mapping?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:1:1 ident mapping
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
Note that you still can use safely 1:1 from above 1MB only
Re:1:1 ident mapping
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...
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...
Re:1:1 ident mapping
What is this VM86, actually? Will I need it? And can I use multitasking without VM86?i don't think it's bad (i do it) unless you want to have several VM86 tasks running together.
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...Note that you still can use safely 1:1 from above 1MB only
Re:1:1 ident mapping
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/
...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/
Re:1:1 ident mapping
Why?! If you map the first 1MB you also map the video memory buffer: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...
0xB0000 == 704.896bytes
...
0xC0000 == 786.432bytes
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:1:1 ident mapping
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).
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).
Re:1:1 ident mapping
Pype:
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:
Let's see if I got you right...: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.
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:
Pype was talking about mapping from above 1MB...Why?! If you map the first 1MB you also map the video memory buffer:
Re:1:1 ident mapping
oops.. I hadn't read well... sorry ::)Pype was talking about mapping from above 1MB...
... 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...
Re:1:1 ident mapping
Ok, this might work...anyway, my kernel is loaded by GRUB, it is therefore placed at 1MB...everything fine
Re:1:1 ident mapping
...you can always load a second stage loader that loads the kernel and copies it beyond 1MB