Working on qemu, rebooting real machine

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
cybek
Posts: 11
Joined: Tue Dec 27, 2011 4:41 pm

Working on qemu, rebooting real machine

Post by cybek »

Hi. I wrote my 2 stages bootloader which enable protected mode with A20 and jump to kernel in C. (0x100000)
In this kernel I have functions printf-like to print memory map (got from bios-int in bootloader). In qemu everything is working and kernel halt after printfs.
In real machine (laptop about 200MHz, Pentium?, something like that), computer is restarting probably after displaying messages (I'm able to see "Memory map count: bla bla"). At the end of main I have only "for(;;);".
But if I add calling Delay function (which is "for(a=0; a < 10000000; a++);"), I'm not able to see any message from kernel. Looks like this Delay function is rebooting PC. Can You help me?
I attached my floppy image and source codes. Probably bootloader is good enough and problem is in kernel (kernel.c) (compiled via cross-gcc) or in stack settings?
I will be grateful if You help me :)
Attachment is there: http://www.cybek.cba.pl/_asm/cybOS32.rar

PS: cybfs.img is fdd image, cybFSman is my "filesystem" manager
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Working on qemu, rebooting real machine

Post by bluemoon »

Computer does "for(a=0; a < 10000000; a++);" pretty quick, to make it worst if you enabled optimized it probably be omitted, your C code will soon end and the computer execute anything random after that, and probably crash very soon.

For having it "work on qemu but not work on real machine", it mostly cause by incomplete initialization, where emulators put the machine in good state by default (memory zero'ed, etc).
cybek
Posts: 11
Joined: Tue Dec 27, 2011 4:41 pm

Re: Working on qemu, rebooting real machine

Post by cybek »

But this for is only for delay and if I don't call it, I'm able to see for second a messages.
And at end of main function I have infinitive loop ( "for(;;);" ) so computer should halt, not do anything random.
I will look at my initialization code and check it. Thanks.
Post Reply