Skip to contentSkip to conversation

guest os time tick issue

Qemu-devel Michael Qiu 1 participant 1 message Apr 3, 2010

lore
Share & tools
lore
#0 lore raw

I'm using qemu to boot a mips kernel.
But it seems always hung like this:
"Calibrating delay loop..."
Actually, it is caused by following code in

int c0_compare_int_usable(void)

Quoted 34 lines
{
    unsigned int delta;
    unsigned int cnt;

    /*
     * IP7 already pending?  Try to clear it by acking the timer.
     */
    if (c0_compare_int_pending()) {
        write_c0_compare(read_c0_count());
        compare_change_hazard();
        if (c0_compare_int_pending())
            return 0;
    }

    for (delta = 0x10; delta <= 0x400000; delta <<= 1) {
        cnt = read_c0_count();
        cnt += delta;
        write_c0_compare(cnt);
        compare_change_hazard();
        if ((int)(read_c0_count() - cnt) < 0)
            break; // In qemu, it seems always 1024. Is this a configurable
value in qemu?
        /* increase delta if the timer was already expired */
    }

    while ((int)(read_c0_count() - cnt) <= 0)
        ;    /* Wait for expiry  */

    compare_change_hazard();
    if (!c0_compare_int_pending())
        return 0;  // If i comment out this, everything will be fine.

    write_c0_compare(read_c0_count());
    compare_change_hazard();
Quoted 9 lines
    if (c0_compare_int_pending())
        return 0;

    /*
     * Feels like a real count / compare timer.
     */
    return 1;
}

Seems the hight line will check the timer interrupt, as in real world, there should be a pending timer interrupt pending untill next write to compare.

I just guest the qemu will do like this:

while(1)
{
execute some guest code // is the number of instuctions fixed? If the
guest code access some memory io memory, simulated hw will be executed.
update background io // just like chardev, sdl relative... update count value in guest cpu // Is the value fixed?
}

Please correct me, thanks in advance