Can't use interrupts after returning to realmode under Bochs

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.
Post Reply
yakujabi
Posts: 12
Joined: Mon Feb 25, 2008 11:16 pm

Can't use interrupts after returning to realmode under Bochs

Post by yakujabi »

I'm trying to set a video mode by returning to real-mode and issuing an interrupt.

It works well under all VMs I've tried, but Bochs just hangs in the interrupt handler without returning. I also get the following line spammed in the logfile:

io write to address 00000000, len=2

The steps I've taken to return to real-mode are:

0) cli
1) copy some 16-bit code to a low address
2) far-jump to that code on a 16-bit, 64k-limit code segment
3) clear first bit of cr0
4) far-jump to the next instruction
5) set proper real-mode segment register values
5) reset IDT & GDT to the real-mode defaults
6) set proper real-mode segment register values again (don't know if it's needed)
7) issue an interrupt

I'll appreciate it if anyone points out any mistakes I've made or any Bochs-gotchas that could be causing this behaviour. Thanks
:)
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Post by Masterkiller »

Did you check memory location 0000h:0000h? It should containt Interrupt Vector Table. IDT is not valid in real-mode, you could even keep it. Address 0x00000 shoud contain 32-bit value seg:offset for INT 0 and so on up to 0x3FF.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Can't use interrupts after returning to realmode under B

Post by Brendan »

Hi,

I think you might end up with a 32-bit stack (where "push byte 0x00" decreases SP by 4). Try this to see:

0) cli
1) copy some 16-bit code to a low address
2) far-jump to that code on a 16-bit, 64k-limit code segment
3) load 16-bit data segment registers (especially SS)
4) clear first bit of cr0
5) far-jump to the next instruction
6) set proper real-mode segment register values
7) reset IDT to the real-mode default (don't worry about the GDT)
8 ) issue an interrupt


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.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

You could also compare your code to my vesa demos, as the does what you want to do.
http://www.dex4u.com/demos/VesaDemo.zip
yakujabi
Posts: 12
Joined: Mon Feb 25, 2008 11:16 pm

Re: Can't use interrupts after returning to realmode under B

Post by yakujabi »

Brendan wrote:Hi,
I think you might end up with a 32-bit stack
Brendan
Thanks Brendan! The problem was indeed stack-related,it's fixed now, and the interrupt returns just fine

...except that it doesn't much more than that :shock:
Doesn't crash, doesn't print anything to the logfile, and worst of all, doesn't change video-modes :(

Any ideas on this one?

Thanks :)
yakujabi
Posts: 12
Joined: Mon Feb 25, 2008 11:16 pm

Post by yakujabi »

Well, it turned out that I had a 16-bit stack that uses ESP, so now everything works well.

Thanks Brendan!
Post Reply