summary refs log tree commit diff stats
path: root/rust/qemu-api/src/irq.rs
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-02-03 11:04:07 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-02-13 12:19:34 +0100
commit61faf6ac7b25b9a743817f0c5fc935a6cdfa7dfb (patch)
tree08d4440cf19e37c6144e07ec43fc43e42c9d52a8 /rust/qemu-api/src/irq.rs
parent590faa03ee64b4221d1be39949190e82e361efb7 (diff)
downloadfocaccia-qemu-61faf6ac7b25b9a743817f0c5fc935a6cdfa7dfb.tar.gz
focaccia-qemu-61faf6ac7b25b9a743817f0c5fc935a6cdfa7dfb.zip
rust: irq: define ObjectType for IRQState
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>
Diffstat (limited to 'rust/qemu-api/src/irq.rs')
-rw-r--r--rust/qemu-api/src/irq.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/rust/qemu-api/src/irq.rs b/rust/qemu-api/src/irq.rs
index 638545c3a6..835b027d5e 100644
--- a/rust/qemu-api/src/irq.rs
+++ b/rust/qemu-api/src/irq.rs
@@ -5,11 +5,12 @@
 //! Bindings for interrupt sources
 
 use core::ptr;
-use std::{marker::PhantomData, os::raw::c_int};
+use std::{ffi::CStr, marker::PhantomData, os::raw::c_int};
 
 use crate::{
-    bindings::{qemu_set_irq, IRQState},
+    bindings::{self, qemu_set_irq},
     prelude::*,
+    qom::ObjectClass,
 };
 
 /// Interrupt sources are used by devices to pass changes to a value (typically
@@ -21,7 +22,8 @@ use crate::{
 /// method sends a `true` value to the sink.  If the guest has to see a
 /// different polarity, that change is performed by the board between the
 /// device and the interrupt controller.
-///
+pub type IRQState = bindings::IRQState;
+
 /// Interrupts are implemented as a pointer to the interrupt "sink", which has
 /// type [`IRQState`].  A device exposes its source as a QOM link property using
 /// a function such as [`SysBusDeviceMethods::init_irq`], and
@@ -91,3 +93,10 @@ impl Default for InterruptSource {
         }
     }
 }
+
+unsafe impl ObjectType for IRQState {
+    type Class = ObjectClass;
+    const TYPE_NAME: &'static CStr =
+        unsafe { CStr::from_bytes_with_nul_unchecked(bindings::TYPE_IRQ) };
+}
+qom_isa!(IRQState: Object);