V86 and data descriptors...

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
Peter_Vigren

V86 and data descriptors...

Post by Peter_Vigren »

To fully support V86 must I then have alot of descriptors to cover for the use of segment registers? Cause in real mode you have alot of segments and you employ them to be able to access certain parts of memory... Anyone understanding what I'm saying here? I haven't really figured out how I should explain this... as you see in this attempt... Well, well...
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:V86 and data descriptors...

Post by Pype.Clicker »

okay, let's break that myth immediately: you don't need a descriptor per segment when you're in v86 mode. The segment registers within v86 mode are simply interpreted as they were in real mode.

In fact, almost everything happens as in real mode except:
- you may perform paging (from the kernel) in your address space (thus ensure you do the *right* paging for memory-mapped I/O ;)
- any attempt to access priviledged instructions (hlt, lgdt, mov cr0 ...) will raise a GPF exception handled by the protected kernel
- any attempt to touch the interrupt flag (IRQ request, cli, sti, iret ..., int xx) will raise a GPF, unless you programmed the processor to defer interrupt management (avl. from pentium PRO : Virtual Interrupts extension in CR4)
Peter_Vigren

Re:V86 and data descriptors...

Post by Peter_Vigren »

Pype.Clicker wrote: okay, let's break that myth immediately: you don't need a descriptor per segment when you're in v86 mode. The segment registers within v86 mode are simply interpreted as they were in real mode.

In fact, almost everything happens as in real mode except:
- you may perform paging (from the kernel) in your address space (thus ensure you do the *right* paging for memory-mapped I/O ;)
- any attempt to access priviledged instructions (hlt, lgdt, mov cr0 ...) will raise a GPF exception handled by the protected kernel
- any attempt to touch the interrupt flag (IRQ request, cli, sti, iret ..., int xx) will raise a GPF, unless you programmed the processor to defer interrupt management (avl. from pentium PRO : Virtual Interrupts extension in CR4)
Then I only need a code descriptor and a data descriptor? Nice then...
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:V86 and data descriptors...

Post by Pype.Clicker »

you just need descriptors for the kernel supervisor (protected DPL0 code). But you'll need quite complex interrupt handlers for GPF ... and you'll also need complex code to setup and enter virtual tasks ...
Peter_Vigren

Re:V86 and data descriptors...

Post by Peter_Vigren »

Pype.Clicker wrote: you just need descriptors for the kernel supervisor (protected DPL0 code). But you'll need quite complex interrupt handlers for GPF ... and you'll also need complex code to setup and enter virtual tasks ...
I thought that you entered a V86-task as a normal one... What's different?
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:V86 and data descriptors...

Post by Pype.Clicker »

well, as far as i remember (but i'm only basing on TRAN start32 tutorials & code), you cannot just jump/call a V86 task. Instead, you have to fake an interrupt return to that task, thus :
- setting up a TSS with all the required values in the registers and the VM bit set in flags (hum. not quite sure of that one, but it can't hurt)
- set the value of a trash-TSS selector with LTR. This one will hold the garbage state of the pmode starter task.
- set the "BACK" link of the trash-TSS to the value of the v86-TSS...
- create a fake 'virtual mode interrupted' frame on the stack (including values of ds,es,fs,gs,cs as 16 bits real-mode segments) and ip (as a 16 bits offset) and flags (including the VM bit set .. now i'm 100% sure you need that one ...)
- IRETD
Peter_Vigren

Re:V86 and data descriptors...

Post by Peter_Vigren »

Pype.Clicker wrote: well, as far as i remember (but i'm only basing on TRAN start32 tutorials & code), you cannot just jump/call a V86 task. Instead, you have to fake an interrupt return to that task, thus :
- setting up a TSS with all the required values in the registers and the VM bit set in flags (hum. not quite sure of that one, but it can't hurt)
- set the value of a trash-TSS selector with LTR. This one will hold the garbage state of the pmode starter task.
- set the "BACK" link of the trash-TSS to the value of the v86-TSS...
- create a fake 'virtual mode interrupted' frame on the stack (including values of ds,es,fs,gs,cs as 16 bits real-mode segments) and ip (as a 16 bits offset) and flags (including the VM bit set .. now i'm 100% sure you need that one ...)
- IRETD
The VM-flag is, as you wrote, required to be set. However, in the Intel documentation, I don't see anything that say that you cannot jump into a V86-task... Hm... I don't understand really what you mean in the step before IRETD... the things about the stack and the registers...
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:V86 and data descriptors...

Post by Pype.Clicker »

That's something i found from Tran's start32 (or pmode, can't remember very well) tutorial. You simulate the return to the virtual mode as if the virtual mode had been interrupted previously by some exception ...

in essence, this is roughly similar from writing
push xyz
push abc
retf

when what you want to do is jmp xyz:abc ;)
Post Reply