From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-rust@nongnu.org
Subject: [PATCH 02/15] rust: add SysBusDeviceImpl
Date: Fri, 21 Feb 2025 18:03:29 +0100 [thread overview]
Message-ID: <20250221170342.63591-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20250221170342.63591-1-pbonzini@redhat.com>
The only function, right now, is to ensure that anything with a
SysBusDeviceClass class is a SysBusDevice.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/hw/char/pl011/src/device.rs | 5 ++++-
rust/hw/timer/hpet/src/hpet.rs | 4 +++-
rust/qemu-api/src/sysbus.rs | 8 +++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index fe73771021e..7063b60c0cc 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -20,7 +20,7 @@
prelude::*,
qdev::{Clock, ClockEvent, DeviceImpl, DeviceState, Property, ResetType, ResettablePhasesImpl},
qom::{ClassInitImpl, ObjectImpl, Owned, ParentField},
- sysbus::{SysBusDevice, SysBusDeviceClass},
+ sysbus::{SysBusDevice, SysBusDeviceClass, SysBusDeviceImpl},
vmstate::VMStateDescription,
};
@@ -176,6 +176,8 @@ impl ResettablePhasesImpl for PL011State {
const HOLD: Option<fn(&Self, ResetType)> = Some(Self::reset_hold);
}
+impl SysBusDeviceImpl for PL011State {}
+
impl PL011Registers {
pub(self) fn read(&mut self, offset: RegisterOffset) -> (bool, u32) {
use RegisterOffset::*;
@@ -746,3 +748,4 @@ impl ObjectImpl for PL011Luminary {
impl DeviceImpl for PL011Luminary {}
impl ResettablePhasesImpl for PL011Luminary {}
+impl SysBusDeviceImpl for PL011Luminary {}
diff --git a/rust/hw/timer/hpet/src/hpet.rs b/rust/hw/timer/hpet/src/hpet.rs
index 75ff5b3e8d6..b4ffccf815f 100644
--- a/rust/hw/timer/hpet/src/hpet.rs
+++ b/rust/hw/timer/hpet/src/hpet.rs
@@ -23,7 +23,7 @@
qdev::{DeviceImpl, DeviceMethods, DeviceState, Property, ResetType, ResettablePhasesImpl},
qom::{ObjectImpl, ObjectType, ParentField},
qom_isa,
- sysbus::SysBusDevice,
+ sysbus::{SysBusDevice, SysBusDeviceImpl},
timer::{Timer, CLOCK_VIRTUAL},
};
@@ -887,3 +887,5 @@ fn properties() -> &'static [Property] {
impl ResettablePhasesImpl for HPETState {
const HOLD: Option<fn(&Self, ResetType)> = Some(Self::reset_hold);
}
+
+impl SysBusDeviceImpl for HPETState {}
diff --git a/rust/qemu-api/src/sysbus.rs b/rust/qemu-api/src/sysbus.rs
index fa36e12178f..fee2e3d478f 100644
--- a/rust/qemu-api/src/sysbus.rs
+++ b/rust/qemu-api/src/sysbus.rs
@@ -14,7 +14,7 @@
irq::{IRQState, InterruptSource},
memory::MemoryRegion,
prelude::*,
- qdev::{DeviceClass, DeviceState},
+ qdev::{DeviceClass, DeviceImpl, DeviceState},
qom::{ClassInitImpl, Owned},
};
@@ -25,10 +25,12 @@ unsafe impl ObjectType for SysBusDevice {
}
qom_isa!(SysBusDevice: DeviceState, Object);
-// TODO: add SysBusDeviceImpl
+// TODO: add virtual methods
+pub trait SysBusDeviceImpl: DeviceImpl + IsA<SysBusDevice> {}
+
impl<T> ClassInitImpl<SysBusDeviceClass> for T
where
- T: ClassInitImpl<DeviceClass>,
+ T: SysBusDeviceImpl + ClassInitImpl<DeviceClass>,
{
fn class_init(sdc: &mut SysBusDeviceClass) {
<T as ClassInitImpl<DeviceClass>>::class_init(&mut sdc.parent_class);
--
2.48.1
next prev parent reply other threads:[~2025-02-21 17:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 17:03 [PATCH 00/15] rust: prepare for splitting crates Paolo Bonzini
2025-02-21 17:03 ` [PATCH 01/15] rust: add IsA bounds to QOM implementation traits Paolo Bonzini
2025-02-24 14:43 ` Zhao Liu
2025-02-21 17:03 ` Paolo Bonzini [this message]
2025-02-24 14:46 ` [PATCH 02/15] rust: add SysBusDeviceImpl Zhao Liu
2025-02-21 17:03 ` [PATCH 03/15] rust: qom: add ObjectImpl::CLASS_INIT Paolo Bonzini
2025-02-24 14:56 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 04/15] rust: pl011, qemu_api tests: do not use ClassInitImpl Paolo Bonzini
2025-02-24 15:14 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 05/15] rust: qom: get rid of ClassInitImpl Paolo Bonzini
2025-02-24 15:24 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 06/15] rust: cell: add wrapper for FFI types Paolo Bonzini
2025-02-25 6:46 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 07/15] rust: qemu_api_macros: add Wrapper derive macro Paolo Bonzini
2025-02-25 7:54 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 08/15] rust: timer: wrap QEMUTimer with Opaque<> Paolo Bonzini
2025-02-25 7:56 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 09/15] rust: irq: wrap IRQState " Paolo Bonzini
2025-02-25 8:26 ` Zhao Liu
2025-02-25 8:28 ` Paolo Bonzini
2025-02-25 9:36 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 10/15] rust: qom: wrap Object " Paolo Bonzini
2025-02-25 8:47 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 11/15] rust: qdev: wrap Clock and DeviceState " Paolo Bonzini
2025-02-25 8:52 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 12/15] rust: sysbus: wrap SysBusDevice " Paolo Bonzini
2025-02-25 8:59 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 13/15] rust: memory: wrap MemoryRegion " Paolo Bonzini
2025-02-25 9:14 ` Zhao Liu
2025-02-25 9:47 ` Paolo Bonzini
2025-02-21 17:03 ` [PATCH 14/15] rust: chardev: wrap Chardev " Paolo Bonzini
2025-02-25 9:19 ` Zhao Liu
2025-02-21 17:03 ` [PATCH 15/15] rust: bindings: remove more unnecessary Send/Sync impls Paolo Bonzini
2025-02-25 9:20 ` Zhao Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250221170342.63591-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-rust@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).