Vmode

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.
xyjamepa

Vmode

Post 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
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re:Vmode

Post 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
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
earlz

Re:Vmode

Post by earlz »

do you mean Video mode or Virtual mode?
xyjamepa

Re:Vmode

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re:Vmode

Post 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).
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
xyjamepa

Re:Vmode

Post 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.
earlz

Re:Vmode

Post 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)
GLneo

Re:Vmode

Post by GLneo »

first ? first: do you have a task scheduler?
xyjamepa

Re:Vmode

Post 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
xyjamepa

Re:Vmode

Post 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
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:Vmode

Post 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).
xyjamepa

Re:Vmode

Post by xyjamepa »

okay guys i implemented a simple multitasking
and it works fine.
what is the next step?
thanx
deadmutex

Re:Vmode

Post by deadmutex »

You can try looking at this site. Maybe it will help you. http://osdev.berlios.de/v86.html
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:Vmode

Post 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.
xyjamepa

Re:Vmode

Post 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.
Post Reply