Page 1 of 1

V86 and data descriptors...

Posted: Tue Jul 30, 2002 5:28 pm
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...

Re:V86 and data descriptors...

Posted: Wed Jul 31, 2002 2:20 am
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)

Re:V86 and data descriptors...

Posted: Wed Jul 31, 2002 1:21 pm
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...

Re:V86 and data descriptors...

Posted: Thu Aug 01, 2002 1:56 pm
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 ...

Re:V86 and data descriptors...

Posted: Thu Aug 01, 2002 8:13 pm
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?

Re:V86 and data descriptors...

Posted: Fri Aug 02, 2002 5:08 am
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

Re:V86 and data descriptors...

Posted: Sun Aug 04, 2002 1:42 am
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...

Re:V86 and data descriptors...

Posted: Tue Aug 13, 2002 8:43 am
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 ;)