From: Zhao Liu <zhao1.liu@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org
Subject: Re: [PATCH] rust: cell: add full example of declaring a SysBusDevice
Date: Wed, 5 Mar 2025 01:04:05 +0800 [thread overview]
Message-ID: <Z8cyhSfdeTufVzaj@intel.com> (raw)
In-Reply-To: <20250228085506.846381-1-pbonzini@redhat.com>
> +//! ### Example
> +//!
> +//! ```
> +//! # use qemu_api::prelude::*;
> +//! # use qemu_api::{c_str, cell::BqlRefCell, irq::InterruptSource, irq::IRQState};
> +//! # use qemu_api::{sysbus::SysBusDevice, qom::Owned, qom::ParentField};
> +//! # const N_GPIOS: usize = 8;
> +//! # struct PL061Registers { /* ... */ }
> +//! # unsafe impl ObjectType for PL061Device {
> +//! # type Class = <SysBusDevice as ObjectType>::Class;
> +//! # const TYPE_NAME: &'static std::ffi::CStr = c_str!("pl061");
> +//! # }
> +//! struct PL061Device {
Maybe PL061State?
> +//! parent_obj: ParentField<SysBusDevice>,
> +//!
> +//! // Configuration is read-only after initialization
> +//! pullups: u32,
> +//! pulldowns: u32,
> +//!
> +//! // Same for sub-objects of the device
> +//! out: [Owned<IRQState>; N_GPIOS],
Should this be InterruptSource type?
Just have a quick look at pl061.c:
qdev_init_gpio_out(dev, s->out, N_GPIOS);
So in Rust side, `out` would be initialized by
DeviceMethods::init_gpio_out().
Others are fine for me ~ with above nits fixed,
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
next prev parent reply other threads:[~2025-03-04 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 8:55 [PATCH] rust: cell: add full example of declaring a SysBusDevice Paolo Bonzini
2025-03-04 17:04 ` Zhao Liu [this message]
2025-03-04 19:44 ` Paolo Bonzini
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=Z8cyhSfdeTufVzaj@intel.com \
--to=zhao1.liu@intel.com \
--cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.