summary refs log tree commit diff stats
path: root/rust/qemu-api/src/irq.rs (follow)
Commit message (Collapse)AuthorAgeFilesLines
* rust: irq: wrap IRQState with Opaque<>Paolo Bonzini2025-03-061-5/+10
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: prefer importing std::ptr over core::ptrZhao Liu2025-02-251-2/+1
| | | | | | | | | | | | The std::ptr is same as core::ptr, but std has already been used in many cases and there's no need to choose non-std library. So, use std::ptr directly to make the used ptr library as consistent as possible. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250218080835.3341082-1-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: add bindings for gpio_{in|out} initializationZhao Liu2025-02-131-1/+0
| | | | | | | | | | Wrap qdev_init_gpio_{in|out} as methods in DeviceMethods. And for qdev_init_gpio_in, based on FnCall, it can support idiomatic Rust callback without the need for C style wrapper. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-5-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust/irq: Add a helper to convert [InterruptSource] to pointerZhao Liu2025-02-131-0/+6
| | | | | | | | | | This is useful when taking an InterruptSource slice and passing it to C function. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-4-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: irq: define ObjectType for IRQStatePaolo Bonzini2025-02-131-3/+12
| | | | | | | This is a small preparation in order to use an Owned<IRQState> for the argument to sysbus_connect_irq. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: bindings: add Send and Sync markers for types that have bindingsPaolo Bonzini2025-02-131-0/+3
| | | | | | | | This is needed for the MemoryRegionOps<T> to be declared as static; Rust requires static elements to be Sync. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: qdev: expose inherited methods to subclasses of SysBusDevicePaolo Bonzini2025-01-101-2/+1
| | | | | | | | | | The ObjectDeref trait now provides all the magic that is required to fake inheritance. Replace the "impl SysBusDevice" block of qemu_api::sysbus with a trait, so that sysbus_init_irq() can be invoked as "self.init_irq()" without any intermediate upcast. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: add bindings for interrupt sourcesPaolo Bonzini2024-12-101-0/+91
The InterruptSource bindings let us call qemu_set_irq() and sysbus_init_irq() as safe code. Interrupt sources, qemu_irq in C code, are pointers to IRQState objects. They are QOM link properties and can be written to outside the control of the device (i.e. from a shared reference); therefore they must be interior-mutable in Rust. Since thread-safety is provided by the BQL, what we want here is the newly-introduced BqlCell. A pointer to the contents of the BqlCell (an IRQState**, or equivalently qemu_irq*) is then passed to the C sysbus_init_irq function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>