i have been studying some QEMU source code, in particular bcm2835_gpio.c, where it uses a qdev_init_gpio_out function to initialize some output GPIOs, and then store the qemu_irq in an array. Then, in gpclr and gpset func it uses qemu_set_irq(s->out[start + i], 1); whats the point of it? I couldnt find any device connected to this output GPIO. Maybe im not understandig the concept but here is what i think: to use this out gpio to generate an interrupt you would need to Connect another qemu_irq to it, in particular one input GPIO, using a qdev_connect_gpio_out function, then if outgpio rises a irq with qemu_set_irq it should activare handler function of the input gpio. I have tried doing this but it didnt work, did i missunderstood something? Im trying to connect one new output gpio from bcm2835_gpio to the input gpio number 49 of bcm2835_ic. Is there any other way to connect something to the output gpio? Thanks for your help😁
Yes, this is fairly normal for GPIO controller models in QEMU. We model the GPIO controller as a device, with its various input and output pins, but if the board model itself does not use those GPIO lines, they don't go anywhere.
Where a GPIO controller output is used by a board or SoC model by connecting it to a different device, qdev_connect_gpio_out() is the right thing to use. If it's not working then you've got something wrong in your modifications, but it's hard to say what when you don't tell us the changes you've made. The best way to debug this is probably to run QEMU under (host) gdb, and put a breakpoint in the function that calls qemu_set_irq() in the GPIO controller. Check you hit that breakpoint when you think you ought to, and then step through and make sure you end up in the interrupt controller code. That will help you narrow down whether the problem is that your guest code isn't actually raising the GPIO line, or that you've not wired it up at all, or that you've wired it to a different interrupt controller line than you thought you did, or that your guest code doesn't notice the interrupt because it's mis-programmed the interrupt controller. Watch out in particular for correct interrupt controller line numbering -- sometimes different sources count these starting from a different number depending on whether they include internal interrupts in the count. Cross-check against one of the existing connected interrupt lines. Also make sure you're connecting to the right one of the BCM2835_IC_ARM_IRQ or BCM2835_GPU_IRQ interrupt arrays.
There is no framework or UI for modelling the equivalent of "the hardware wires these lines up to expansion boards, LEDs or push-buttons". By and large the use case for QEMU is "run Linux on it", not "emulate doing embedded-button-and-LED stuff".