Page 1 of 2

Vmode

Posted: Sat Sep 02, 2006 7:05 am
by xyjamepa
Hi
i want to switch to the vmode in my os
how can i do that?
I saw tha FAQ but didn't help me...
my os is 32bit pmode.
thanx

Re:Vmode

Posted: Sat Sep 02, 2006 10:05 am
by Combuster
Straight from the intel manual:
16.2.1. Enabling Virtual-8086 Mode
The processor runs in virtual-8086 mode when the VM (virtual machine) flag in the EFLAGS register is set. This flag can only be set when the processor switches to a new protected-mode task or resumes virtual-8086 mode via an IRET instruction.
In your problems context:
- set VM in a task's eflags and jump to that task
- set the VM bit in an interrupt structure before doing IRET

Re:Vmode

Posted: Sat Sep 02, 2006 10:44 am
by earlz
do you mean Video mode or Virtual mode?

Re:Vmode

Posted: Sun Sep 03, 2006 2:13 am
by xyjamepa
No i mean virtual 8086 mode because i want to use BIOS functions but would you please put some simple code
i already read Tim Robinson's tutorial and i need more
explain like step by step.
and one more question can i use al BIOS function
without any exception?

Re:Vmode

Posted: Sun Sep 03, 2006 3:49 am
by Combuster
It helps by asking WHAT you do not understand about virtual 8086 mode. I suppose you didnt try to make a v8086 compatible stack and then iret from it?
As for that, you wont be getting away without reading intel's big book of patterns (volume 3, chapter 16) which close to dictates you what to do...

As for bios, you should be able to run all those functions within v8086 mode, but that depends on how you handle the corner cases - setting iopl to ring 3 would probably the easiest but also the most instable (i.e. win 95 style).

Re:Vmode

Posted: Sun Sep 03, 2006 5:25 am
by xyjamepa
lets see...
I don't understand the meaning of virtual mode!
i just know that you can use bios INT inside the pmode.
and that what i need from vmode.
I think if i have to switch to vmode i need to
implement multitasking,am i right?
is that the first step...
thanx.

Re:Vmode

Posted: Sun Sep 03, 2006 9:25 am
by earlz
hmmm
have you even setup a TSS or even things like gdt and idt

I have an idea though incase you want them without all that stuff(though you'll eventually have to do that..)
how about going through bios code, like the bochs bios code or qemu and then just converting the code to 32bit(which isn't hard most of the time)

Re:Vmode

Posted: Sun Sep 03, 2006 11:18 am
by GLneo
first ? first: do you have a task scheduler?

Re:Vmode

Posted: Sun Sep 03, 2006 12:08 pm
by xyjamepa
sure i setup a gdt , idt and IRQ.
so i need a task scheduler,any link about it.
or useful explain.
and what is the next step?
thanx

Re:Vmode

Posted: Mon Sep 04, 2006 1:30 am
by xyjamepa
guys...
i looked for a task scheduler with google and the FAQ
but that didn't help me so i'm looking for you feedback.
thanx

Re:Vmode

Posted: Mon Sep 04, 2006 6:12 am
by Pype.Clicker
all i can offer atm. is the in the VBE2 driver for clicker. It features code coming from the OSlib that does VM86 nitty-gritty. You'll find there code that does context change (e.g. messing with the Task Register of the CPU), but that is a very specific kind of context change. You don't actually need to have a full-blown task scheduler implemented for VM86.

at worst, if you have a scheduler already, all you need is to make sure that the thread structure correctly reflect the fact your thread now execute in a new TSS (think of TSS as a container for executing threads, not as units of executions per-se).

Re:Vmode

Posted: Mon Sep 04, 2006 8:47 am
by xyjamepa
okay guys i implemented a simple multitasking
and it works fine.
what is the next step?
thanx

Re:Vmode

Posted: Mon Sep 04, 2006 9:34 pm
by deadmutex
You can try looking at this site. Maybe it will help you. http://osdev.berlios.de/v86.html

Re:Vmode

Posted: Tue Sep 05, 2006 1:59 am
by Pype.Clicker
abuashraf wrote: what is the next step?
i'd say your next step will be to fill one TSS with V86-compatible register values (e.g. the VM bit set in EFLAGS), to manage to have an illegal instruction (e.g. HLT) somewhere below 1MB and to make the V86 task start executing there.

That should give you a GPF with cross-ring stack and CS:IP:FLAGS values that will be the proof you've been in VM86 mode... Then it will depend on what you actually plan to do in VM.

Re:Vmode

Posted: Wed Sep 06, 2006 8:45 am
by xyjamepa
hi...
i can switch only between two tasks,
is that enough to switch to the virtual mode?
if it isn't what do you advice me?
and if it's fine,
what should i do next to switch to virtual mode?
thanx.