Real Mode Emulator v2

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:

Re: Real Mode Emulator v2

Post by thepowersgang »

I just spotted your problem

Code: Select all

memset(LowCache, 0, RME_BLOCK_SIZE + 1);
... now, that is not in the actual version, what is in the git repo is.

Code: Select all

memcpy(LowCache, 0, RME_BLOCK_SIZE);
What I do here is make a copy of the first block of memory to somewhere that isn't NULL.
meanwhile, your version sets the first block (including the IVT) to zero, hence calling an interrupt causes the emulator to try to emulate at 0000:0000, which you set to zero.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Real Mode Emulator v2

Post by Creature »

I knew it was a stupid mistake! What I did was (by quickly taking over and rewriting) assume that the memcpy was simply copying 0 to to something (to set it to 0), but in fact it's doing something entirely different.

You'll be happy to know that the switching works now, although it takes around 7 to 10 seconds to perform one video switch, whereas my real mode switcher takes less than one second, but I guess it's part of the emulation and might even be sped up in the future (through various optimizations). I've also tried switching back to text mode but I can't quite seem to get that working. I set AX to 0x02 to switch back (and it does), but it never seems to return. Is there anything specific I need to keep in mind once I made a call to an interrupt?

EDIT: With -O3, the emulator is considerably faster (one switch takes around 3 seconds, which is a lot more acceptable).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
astrocrep
Member
Member
Posts: 127
Joined: Sat Apr 21, 2007 7:21 pm

Re: Real Mode Emulator v2

Post by astrocrep »

It's been a while, but I believe textmode is 0x3...

This project looks very interesting!

--
Edit: ehh crud... sorry for bumping a old thread...

But since I'm here, any updates on this project?

Thanks,
Rich
Mouse Pad - Coming in the distant future...
Kernel: Indigo Kernel - v0.0.1

Thanks to JamesM and BrokenThorn for there tutorials!
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 v2

Post by thepowersgang »

Not a lot, I've been working on other things for now, but there has been some bugfixes to it.

However, once I get my 64-bit kernel up, it's going to get a lot of stress testing. (A lack of VM8086 mode means I will have to use this for what it was designed).
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Real Mode Emulator v2

Post by Creature »

astrocrep wrote:It's been a while, but I believe textmode is 0x3...

This project looks very interesting!

--
Edit: ehh crud... sorry for bumping a old thread...

But since I'm here, any updates on this project?

Thanks,
Rich
I tried it again afterwards with 0x03 as well and for some reason, I could switch to 0x13, 0x12 and such but never back to text mode. It did the actual switch, but execution never continued (I guess it got stuck somewhere). I also tried it in 64-bit some time ago, I got a page-fault (page not mapped) somewhere way too high where I wasn't even placing anything (apparently the emulator was trying to access it for some reason). That was quite some time ago, though, and I don't have the code here anymore (it was more of a test).

I still think it's a good way of handling BIOS calls in long mode, even though it's considerably slower than e.g. a PMode -> RMode -> PMode switch, but I remember that turning optimizations on made a huge difference in speed. I guess you'll probably want to optimize your code (after you've finished it, of course).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: Real Mode Emulator v2

Post by Karlosoft »

Very interesting, but not useful on real hardware. Simply some instruction used by modern BIOSes to increase the performances aren't covered (AAA, DAA, INS, OUTS and so on). It still work on emulators but not on real hardware. So I decide to add these and other instructions to the code. I hope the author doesn't mind ;)
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 v2

Post by thepowersgang »

Go ahead, but could you apply them as a patch to the git tree? I've been slowly working on it since I posted and I think I've implemented some of those opcodes myself.

The git link is git://www.mutabah.net/rme2.git pull from that and send me the patch in a PM
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: Real Mode Emulator v2

Post by Karlosoft »

Ok, in these days, school is starting again so I'll post the updates when I will have more time ;)
Post Reply