OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Jun 24, 2022 4:30 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Any other reason to have V86?
PostPosted: Thu Jan 03, 2008 12:14 pm 
Offline

Joined: Fri Jul 27, 2007 1:35 pm
Posts: 20
Location: Virginia, USA
My understanding of V86 mode is allow for 16-bit code execution, such as when you want to allow access to the BIOS. Other than that is there any reason why you would want to support this mode?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 12:39 pm 
Offline
Member
Member
User avatar

Joined: Tue Aug 08, 2006 7:43 am
Posts: 271
Location: Sydney, Australia
It's only purpose is to run 16-bit code, so there are no reasons beyond that.

_________________
The cake is a lie | rackbits.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 1:28 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:53 pm
Posts: 49
Location: Los Angeles, CA
Its the easiest way imo to switch to different video modes later on. But you could also do that right away during bootup as well.

_________________
http://ominos.sourceforge.net - my kernel
#ominos @ irc.freenode.net
http://dtors.ath.cx - my blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 2:06 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 03, 2007 6:03 am
Posts: 536
Location: Cambridge, UK
yeah i think most people use it for video mode and/or DOS compatability

_________________
~ Lukem95 [ Cake ]
Release: 0.08b
Image


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 03, 2008 2:42 pm 
Offline
Member
Member
User avatar

Joined: Mon Apr 09, 2007 10:50 am
Posts: 49
Location: UK, Hants
Do you know of any resources worth check out on the subject? I assume that a lot of this would be done is assembler?

_________________
Reflect Desktop Operating System - ' You only remember the name of the OS when it crashes '


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 5:38 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 03, 2007 6:03 am
Posts: 536
Location: Cambridge, UK
i'm close to the point where i will be implementing this...

there is a huge section in the third intel manual (systems programming) on how to set it up etc, but you must have tasks working first (AFAIK)

_________________
~ Lukem95 [ Cake ]
Release: 0.08b
Image


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 6:03 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2642
Location: Devon, UK
Once you have multitasking set up, there really isn't much more to do - simply set the VM bit in EFLAGS for the new task and you're away. All you have to do then is handle GPF exceptions gracefully as per the wiki atricle: [wiki]Virtual Monitor[/wiki]. If you can enable VME in CR4, you may find that you don't even need much of a virtual mode monitor.

Cheers,
Adam

[/wiki]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 6:28 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
I think it's also useful for running virtual machines on the previous generation of processors that didn't have the virtual machine extensions.

_________________
"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 ]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 9:34 am 
Offline
Member
Member

Joined: Sat Nov 18, 2006 9:11 am
Posts: 571
No, there is no use for it unless you want to support legacy r-mode code for some reason. I can change my video resolution just fine while running without a v86, i just disable ints, drop to r-mode, do interrupt, come back to p-mode and re-enable ints... sure it might be a tad slower, but how often/fast do you really need to call it, and how large is it to implement v86 with properly handling vs. my < 64 byte function call? And, it doesn't even have to be implemented in the kernel, so when i get 'real' drivers for video, it won't even happen anymore, and the kernel doesn't care one way or another. With the v86, you implement it, waste a ton of space, then if you ever make it to the point of implementing a real driver, you haev legacy code in your kernel for no reason (or as a fall-back), but I would rather the legacy code in my fall-back/generic driver than my kernel. I dont' see why so many people are adament on using v86.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 10:52 am 
Offline
Member
Member
User avatar

Joined: Wed Nov 17, 2004 12:00 am
Posts: 202
Location: Germany
Ready4Dis wrote:
i just disable ints, drop to r-mode, do interrupt, come back to p-mode and re-enable ints...

That is not so easy for a kernel that is above 1MB (which is every kernel loaded by grub). Besides that the coded needed for v86 is not as big as you pointed out (if you use vme).

_________________
lightOS


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 4:24 pm 
Offline
Member
Member

Joined: Sat Nov 18, 2006 9:11 am
Posts: 571
bluecode wrote:
Ready4Dis wrote:
i just disable ints, drop to r-mode, do interrupt, come back to p-mode and re-enable ints...

That is not so easy for a kernel that is above 1MB (which is every kernel loaded by grub). Besides that the coded needed for v86 is not as big as you pointed out (if you use vme).


I dunno, I use my own bootloader, and my function is about 40bytes, requires no multitasking support, or anything else in the kernel. I load my kernel to a memory location down low, then memory map it to 0xF0000000. What is GRUB saving the lower 1mb for? Also, it doesn't have to be the kernel, like I said, my vesa driver does the dropping to real-mode, so as long as your kernel can allocate memory below 1mb, i don't see the problem :). I know it's not that huge, but then your video driver needs to spawn a thread, and do special case IPC to tell that thread what to do (set screen mode + resolution, or whatever you need). Mine doesn't require any special code in my kernel (besides having a 16-bit entry setup so i can drop back into 16-bit pmode before going rmode). I just don't see the point in doing the work to get v86 working just to set a video mode, all that extra code in your kernel. I know it's not that huge of a difference, i just don't see a point in doing it personally.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 5:01 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
Ready4Dis wrote:
I dunno, I use my own bootloader, and my function is about 40bytes, requires no multitasking support, or anything else in the kernel. I load my kernel to a memory location down low, then memory map it to 0xF0000000. What is GRUB saving the lower 1mb for? Also, it doesn't have to be the kernel, like I said, my vesa driver does the dropping to real-mode, so as long as your kernel can allocate memory below 1mb, i don't see the problem :). I know it's not that huge, but then your video driver needs to spawn a thread, and do special case IPC to tell that thread what to do (set screen mode + resolution, or whatever you need). Mine doesn't require any special code in my kernel (besides having a 16-bit entry setup so i can drop back into 16-bit pmode before going rmode). I just don't see the point in doing the work to get v86 working just to set a video mode, all that extra code in your kernel. I know it's not that huge of a difference, i just don't see a point in doing it personally.


can you post yuor code? I'm very interested to it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 5:03 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 17, 2006 12:00 am
Posts: 500
Location: Napoli, Italy
In fact, I need to call BIOS routines very few times. So I can go to real mode and return to protected mode to do this.

I will use BIOS only for changing video mode...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 10:58 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Ready4Dis wrote:
i just disable ints, drop to r-mode, do interrupt, come back to p-mode and re-enable ints...


In general, interrupts should only be disabled for a few instructions. Switching video modes takes ages and you'll have extremely high interrupt latency because interrupts are disabled for far too long. This can cause some major problems for some devices - packets lost for high speed ethernet, missed timer IRQs, missed keypresses causing the keyboard to lock up, etc.

In addition, AFAIK nothing guarantees that the video ROM won't enable interrupts, causing IRQs to be delivered while the CPU is in real mode. There's nothing you can do to prevent this from causing your devices to fail, your OS to crash, etc that doesn't make things worse (e.g. you could mask the IRQs to prevent crashes, etc but then you'd miss IRQs completely instead of postponing them). Most video cards probably don't enable interrupts, but unless you test every video card ever made you can't know that all video cards don't enable interrupts.

Of course there are other problems, like being unable to use this method to support multiple video cards. For virtual80x86 you can map each video card's ROM at 0x000C0000 in different virtual address spaces (and build a fake BDA, IVT, etc for them).

It's a bit like using paint to make your naked body look like it's fully clothed - it works while you're lucky (but let's hope it doesn't rain, and don't ask which pocket the car keys are in)... ;)


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 05, 2008 2:18 pm 
Offline
Member
Member
User avatar

Joined: Fri Jan 27, 2006 12:00 am
Posts: 1444
I would say, going to and from realmode for mode changing is as safe as any other method.
I use this method and have never had or had any reports of problems.
If you set the OS in a state, that it would be in, if you where going to realmode or Pmode to stay, then you should have no problems.

This has some good info
http://www.tenberry.com/dpmi/02.html#0101


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group