unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.53k stars 1.33k forks source link

No apparent binding / mechanism for raising hardware interrupts in the emulation. #1857

Open John-Titor opened 1 year ago

John-Titor commented 1 year ago

I say "apparent" because Qiling must have a way to do this, but I haven't been able to to work out how. QEMU itself has the machinery, but it doesn't appear to be surfaced in the bindings.

wtdcode commented 1 year ago

It depends how you implement "hardware interrupts". There is a FAQ about it:

https://github.com/unicorn-engine/unicorn/wiki/FAQ#how-to-emulate-interrupts-or-ticks-with-unicorn

John-Titor commented 1 year ago

This leaves you stuck (re) implementing the processor (family's) interrupt dispatch behaviour, which QEMU already has sorted (for emulation purposes). It'd be nice to have a binding that lets you invoke this from a hook, etc.

wtdcode commented 1 year ago

But note unicorn is a pure cpu emulator and how interrupts are handled largely depends on periphery devices (say, standalone interrupt controllers). Not every architecture behaves like the monolithic x86. That said, it's hard to maintain a elegant and simple API for such things. The current way is the best we could offer regarding our cross-architecture nature.

If you would like some interrupts handling logic, you may look at qiling