[solved] qemu not working ?

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
donkeeland
Posts: 7
Joined: Sun Feb 28, 2010 9:38 am

[solved] qemu not working ?

Post by donkeeland »

Hello,

I don't think that's qemu is bugged...

I can't correctly display text into the 80x35 VGA buffer.

I follow the http://wiki.osdev.org/Bare_Bones tutorial and it wasn't working on qemu.
Only the kernel.c is little bit different.
kernel.c
(768 Bytes) Downloaded 75 times
Finally i decide to fill all the screen and y add a surprise, i can't write every where in the screen like that.
i should do some thing like that for be sure to write char:

Code: Select all

for(int i=0; i < 150; i++)
    *((char*)0xb8000) = 'A';
The last line of Y is only half writted...

Since one week i can;t get things correctly working on qemu.
But if i directly run the kernel on my hardware there is no problem without the for loop.
I test it on three computer:
- my computer(intel core 2 quad): qemu=NG hard=OK
- my laptop (AMD): qemu=NG hard=OK
- a friend computer (???): qemu=OK hard=???


qemu:
QEMU PC emulator version 0.11.0 (qemu-kvm-0.11.0), Copyright (c) 2003-2008 Fabrice Bellard
Linux dell 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010 i686 GNU/Linux

Can you tell me if you have some idea about the problem and/or tell test it for see if you have the same problem.
Thank's
Last edited by donkeeland on Wed Mar 17, 2010 9:11 am, edited 1 time in total.
js
Member
Member
Posts: 38
Joined: Thu Feb 26, 2009 1:45 am

Re: qemu not working ?

Post by js »

donkeeland wrote:qemu-kvm-0.11.0
Make sure your hardware & kernel support kvm. AFAIK, this is the case only for recent stuff.

Also, try re-installing qemu via your distro's package manager, or even re-compiling it.

Anyway, like any software, QEMU isn't bug-free, I myself have some random bugs that sometimes occur when I run my OS (but, without re-compiling my OS, sometimes don't).
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: qemu not working ?

Post by qw »

donkeeland wrote:

Code: Select all

for(int i=0; i < 150; i++)
    *((char*)0xb8000) = 'A';
Are you writing 'A' in the upper left corner of the screen 150 times?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: qemu not working ?

Post by Combuster »

Without colour, I might add...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: qemu not working ?

Post by Creature »

So basically you're posting here because you think QEMU is broken, whilst you just posted code that puts the character A with a black background AND a black foreground in the SAME spot 150 times?
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
donkeeland
Posts: 7
Joined: Sun Feb 28, 2010 9:38 am

Re: qemu not working ?

Post by donkeeland »

Creature wrote:So basically you're posting here because you think QEMU is broken, whilst you just posted code that puts the character A with a black background AND a black foreground in the SAME spot 150 times?
I'm not posting here because is broken. I don't think that is it broken.

Yes, i do 150 times because a the first time it's not always works :(
So, after write memory after 150 times, the memory remember data ...
User avatar
mutex
Member
Member
Posts: 131
Joined: Sat Jul 07, 2007 7:49 pm

Re: qemu not working ?

Post by mutex »

That was a good one! :lol:
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: qemu not working ?

Post by Creature »

donkeeland wrote:
Creature wrote:So basically you're posting here because you think QEMU is broken, whilst you just posted code that puts the character A with a black background AND a black foreground in the SAME spot 150 times?
I'm not posting here because is broken. I don't think that is it broken.

Yes, i do 150 times because a the first time it's not always works :(
So, after write memory after 150 times, the memory remember data ...
Memory doesn't need 150 writes to remember what's stored in there, you only write once. Secondly, if you write a BLACK character to a BLACK background, of course you won't see anything.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
donkeeland
Posts: 7
Joined: Sun Feb 28, 2010 9:38 am

Re: qemu not working ?

Post by donkeeland »

I know that the memory need only one write for remember the data and it's not a color problem.

For more visibility i shorten the sour to the minimum:

Code: Select all

void kmain(void* mbd, unsigned int magic )
{
        unsigned char *videoram = (unsigned char *) 0xb8000;
        int i;
        for(i=0; i<150; i++)
        {
                videoram[0] = 'A';
                videoram[1] = 0x0F; /* char white on black */
        }
}
If i replace the 150 by 1, the character never display....
User avatar
mutex
Member
Member
Posts: 131
Joined: Sat Jul 07, 2007 7:49 pm

Re: qemu not working ?

Post by mutex »

Okay...

What might be the case is that the emulator only update screen after N cycles.. That can be the case in Bochs some times when it comes to the display atleast. That is the window of the emulator output is not updated, but the state of the memory is correct. If you lower the cycles/refresh rate it might help.

Anyway your code should work like a charm on a real pc..

try doing like this;

Code: Select all

video[0] = 'A';
video[1] = 0x0f;

while(1);
I dont know quemu settings, but in bochs there is a config file option to set the refresh rate of the display.

-
Thomas
donkeeland
Posts: 7
Joined: Sun Feb 28, 2010 9:38 am

Re: qemu not working ?

Post by donkeeland »

Thanks thomasnilsen =D>

I though that it was a problem with qemu.
But because i'm noob in kernel programming i was septic about a possibly qemu failure.


I searched about qemu vga settings, i found nothings good.
So finally i installed bochs and it's works pretty good ! :D
florianh80
Posts: 6
Joined: Fri Mar 19, 2010 10:57 am
Location: Kiel - Germany

Re: [solved] qemu not working ?

Post by florianh80 »

I've got the same "problem" here a while ago.

A solution for this is to unload the kvm modules (kvm_intel or kvm_amd or whatever).
After that everything works fine with qemu.

Flo
donkeeland
Posts: 7
Joined: Sun Feb 28, 2010 9:38 am

Re: [solved] qemu not working ?

Post by donkeeland »

florianh80 wrote:A solution for this is to unload the kvm modules (kvm_intel or kvm_amd or whatever).
After that everything works fine with qemu.
You're right, i try and it's work fine.

I prefer this solution because of the send_key command !!!
Post Reply