Real Mode Emulator

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Real Mode Emulator

Post 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
Attachments
realModeEmu_0.2.zip
Real Mode Emulator - Incomplete Version (Some opcodes have problems or are unimplemented)
(7.34 KiB) Downloaded 331 times
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Re: Real Mode Emulator

Post by iammisc »

why not just use virtual 8086 mode?
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: Real Mode Emulator

Post 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.
"Sufficiently advanced stupidity is indistinguishable from malice."
MagicalTux
Posts: 22
Joined: Mon Dec 04, 2006 5:34 pm

Re: Real Mode Emulator

Post 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.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Real Mode Emulator

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Re: Real Mode Emulator

Post 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 :)
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Real Mode Emulator

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Real Mode Emulator

Post 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
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Real Mode Emulator

Post 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
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Real Mode Emulator

Post 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
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Real Mode Emulator

Post 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?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Real Mode Emulator

Post 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
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Real Mode Emulator

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Real Mode Emulator

Post by AJ »

OIC - good points!

Cheers,
Adam
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Real Mode Emulator

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Post Reply