[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/12] rust: irq: define ObjectType for IRQState
From: |
Paolo Bonzini |
Subject: |
[PATCH 10/12] rust: irq: define ObjectType for IRQState |
Date: |
Fri, 7 Feb 2025 11:16:21 +0100 |
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/qemu-api/src/irq.rs | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/rust/qemu-api/src/irq.rs b/rust/qemu-api/src/irq.rs
index 638545c3a64..835b027d5e5 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 @@
/// 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 @@ fn default() -> Self {
}
}
}
+
+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);
--
2.48.1
- [PATCH 04/12] rust: qdev: add clock creation, (continued)
- [PATCH 04/12] rust: qdev: add clock creation, Paolo Bonzini, 2025/02/07
- [PATCH 01/12] rust: qom: add reference counting functionality, Paolo Bonzini, 2025/02/07
- [PATCH 03/12] rust: callbacks: allow passing optional callbacks as (), Paolo Bonzini, 2025/02/07
- [PATCH 07/12] rust: qdev: switch from legacy reset to Resettable, Paolo Bonzini, 2025/02/07
- [PATCH 05/12] rust: qom: allow initializing interface vtables, Paolo Bonzini, 2025/02/07
- [PATCH 06/12] rust: qdev: make ObjectImpl a supertrait of DeviceImpl, Paolo Bonzini, 2025/02/07
- [PATCH 10/12] rust: irq: define ObjectType for IRQState,
Paolo Bonzini <=
- [PATCH 09/12] rust: bindings for MemoryRegionOps, Paolo Bonzini, 2025/02/07
- [PATCH 08/12] rust: bindings: add Send and Sync markers for types that have bindings, Paolo Bonzini, 2025/02/07
- [PATCH 11/12] rust: chardev, qdev: add bindings to qdev_prop_set_chr, Paolo Bonzini, 2025/02/07
- [PATCH 12/12] rust: pl011: convert pl011_create to safe Rust, Paolo Bonzini, 2025/02/07