Page 1 of 2
Real Mode Emulator
Posted: Sun Jul 20, 2008 8:38 am
by thepowersgang
Over the last few days I have been working on a piece of code that emulates a real mode environment in protected mode.
I have not completed it yet but I can call at least on BIOS interrupt (Int 0x10, AH=0xF) without running into errors.
I would like an opinion of it from you guys.
http://aw-home.dyndns.org/wiki/index.ph ... e_Emulator - Entry on my site (self hosted so may not be up)
Attached is the source of the emulator itself without the testing kernel, I plan to post a full kernel on my website.
[EDIT 2014-03-13]
The above code is so old, it's legally allowed to drink (not really)
If you're interested in something recent, look at
http://git.mutabah.net/rme2.git
Re: Real Mode Emulator
Posted: Mon Jul 21, 2008 4:36 pm
by iammisc
why not just use virtual 8086 mode?
Re: Real Mode Emulator
Posted: Mon Jul 21, 2008 4:58 pm
by Zenith
@OP - Looks great, has support for the opcode prefixes and segment selectors. If I have time I'll try and incorporate this into my OS. Are you making the source Public Domain?
iammisc: There are a lot of reasons people won't use VM86 mode. Long mode disables access to VM86 (which is why I'm interested), for one.
Re: Real Mode Emulator
Posted: Mon Jul 21, 2008 10:40 pm
by MagicalTux
Nice piece of code, however right now there's no copyright information, meaning the code has "All rights reserved" and shouldn't be used anywhere without the author's approval.
Still, I guess it would be interesting for a few things...
If it gets on public domain, I would definitly integrate it in my OS (which means I may fix things in it, and send fixes to the author
)
EDIT: found code license there :
http://aw-home.dyndns.org/wiki/index.ph ... ects:About
All code on this website is free to be used for reference and can be used in a non-commercial project given that proper recognition is given to the original author (myself), thePowersGang or John Hodge.
Re: Real Mode Emulator
Posted: Tue Jul 22, 2008 6:38 am
by thepowersgang
You are all allowed to use the code for your projects although if it goes commercial (Windows/Apple Commercial not linux) I would like some proper recognition.
As for features only some prefixes are supported. Loops are implemented (REP/LOOP) but segment overrides are not. Eventually I will implement them but I am lacking in time now as the school holidays have just finished and I'm in my last year so work is quite solid.
I would like if you find a bug/unimplemented opcode if you could post it on the talk page on my Wiki (you should be able to post anonymously.
Re: Real Mode Emulator
Posted: Tue Jul 22, 2008 9:18 am
by inflater
Well, you're making a good progress thepowersgang, but I don't see a reason of emulating real mode. If somebody wants it, he'll just drop off protected mode for a while... yes I know it would be slow, but emulation isn't fast either...
Anyways I don't know about long mode OS'es if they can drop to rmode momentarily, maybe your code'll help in that case
Re: Real Mode Emulator
Posted: Tue Jul 22, 2008 6:48 pm
by thepowersgang
I made it because I was having problems with dropping from PMode and I couldn't use vm86 without multitasking, and also because I wanted a challenge.
Re: Real Mode Emulator
Posted: Wed Jul 23, 2008 1:52 am
by JamesM
I agree, a real mode emulator is the way our project wants to go for accessing BIOS functions (i.e. VESA) from long mode. (Maybe even from 32-bit pmode...)
Nice job! I haven't haven't had the time to test it yet though. One of our project's devs has expressed an interest in making one of these for our project, however if that falls through I'd definately have a look at using this (with the correct copyright information attached, of course!).
Cheers,
James
Re: Real Mode Emulator
Posted: Thu Jul 24, 2008 8:26 am
by thepowersgang
I've just added support for segment overrides (it's a bit of a hack but should be sufficent).
Real Mode Emulator Page
Version is 0.4.2
Re: Real Mode Emulator
Posted: Thu Jul 24, 2008 8:38 am
by AJ
Nice project - I may be someone else thinking of using it.
I would just be interested to know the following (not trying to play devil's advocate here); if I am thinking of adding support for virtualisation to my OS anyway, does your emulator have any specific benefits? I guess the obvious one is that if running on an older CPU with no virtualisation, you can use your version as a fall-back, but are there any other advantages?
Cheers,
Adam
Re: Real Mode Emulator
Posted: Thu Jul 24, 2008 9:08 pm
by thepowersgang
The largest reason for this is to replace vm8086 when it's not available, but it could be used to provide kernel level emulation services when running on a non x86 platform.
*idea* Kernel level emulation layer for differing platforms (e.g. PPC, ARM, etc) - Any ideas?
Re: Real Mode Emulator
Posted: Fri Jul 25, 2008 4:22 am
by jal
inflater wrote:I don't see a reason of emulating real mode. If somebody wants it, he'll just drop off protected mode for a while... yes I know it would be slow, but emulation isn't fast either...
It's not about real mode being slow, but inheritedly insecure. You really want your OS put in the hands of BIOS routines (that, for al we know, may even switch to pmode themselves)? In fact, there has been at least one implementation by Linux coders to do the same, so they could use the BIOS to do mode switching on modern cards (ATI, nVidia) on PPC machines. So yes, the OP is reinventing the wheel, but hey, aren't we all here?
JAL
Re: Real Mode Emulator
Posted: Fri Jul 25, 2008 4:24 am
by jal
AJ wrote:if I am thinking of adding support for virtualisation to my OS anyway, does your emulator have any specific benefits? I guess the obvious one is that if running on an older CPU with no virtualisation, you can use your version as a fall-back, but are there any other advantages?
Portability: for running your OS on a different system (with a non-x86 CPU and a PCI gfx card).
JAL
Re: Real Mode Emulator
Posted: Fri Jul 25, 2008 5:22 am
by AJ
OIC - good points!
Cheers,
Adam
Re: Real Mode Emulator
Posted: Fri Jul 25, 2008 6:00 am
by thepowersgang
Plus you can't preempt real mode, an emulator can be.
Could anyone do some testing of the code for me? I'm a bit lacking in time at the moment but I will try to fix as many bugs as possible.