Is there somebody can help me to trigger a gpio interrupt inside qemu? I
wrote a simple function to trigger a interrupt in pl061.c as follow:
PL061State *gPl061;
void pl061_raise_irq()
{
    qemu_set_irq(gPl061->irq, 1);
}
gPl061 is assigned in function pl061_initfn:
static int pl061_initfn(SysBusDevice *sbd)
{
    DeviceState *dev = DEVICE(sbd);
    PL061State *s = PL061(dev);
    memory_region_init_io(&s->iomem, OBJECT(s), &pl061_ops, s, "pl061",
0x1000);
    sysbus_init_mmio(sbd, &s->iomem);
    sysbus_init_irq(sbd, &s->irq);
    qdev_init_gpio_in(dev, pl061_set_irq, 8);
    qdev_init_gpio_out(dev, s->out, 8);
    pl061_reset(s);
    gPl061 = s;
    return 0;
}
I installed an interrupt handler in the guest linux system:
MODULE_LICENSE("GPL");
MODULE_AUTHOR("sermonko");

int irq = 41;
char interface[] = "gpio";

int irq_handle_function(int irq, void *device_id)
{
    static int count = 1;
    MSG("[%d]receive the irq at %ld...\n", count, jiffies);
    count++;
    return IRQ_HANDLED;
}

int __init int_init_module()
{
    if(request_irq(irq, irq_handle_function, IRQF_SHARED, interface, (void
*)&irq))
    {
        MSG("regist irq failure...\n");
        return -EIO;
    }
    MSG("interface=%s and irq=%d...\n", interface, irq);
    MSG("regist irq success...\n");
    return 0;
}

void __exit int_cleanup_module()
{
    free_irq(irq, &irq);
    MSG("unregist irq...\n");
}
module_init(int_init_module);
module_exit(int_cleanup_module);
I start qemu using this command: qemu-system-arm -M versatilepb -kernel
output/images/zImage -drive file=output/images/rootfs.ext2,if=scsi -append
"root=/dev/sda console=ttyAMA0,115200" -serial stdio -net nic -net
bridge,br=br0
But when i call pl061_raise_irq inside qemu once, the guest run into an
infinite loop. it prints:
...
irq:[927012]receive the irq at -12002...
irq:[927013]receive the irq at -12002...
irq:[927014]receive the irq at -12002...
irq:[927015]receive the irq at -12002...
irq:[927016]receive the irq at -12002...
irq:[927017]receive the irq at -12002...
irq:[927018]receive the irq at -12002...
...
can somebody tell me what's wrong?

Reply via email to