[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/10] rust/qdev: add the macro to define bit property
From: |
Zhao Liu |
Subject: |
[PATCH 02/10] rust/qdev: add the macro to define bit property |
Date: |
Sat, 25 Jan 2025 20:51:29 +0800 |
HPET device (Rust device) needs to define the bit type property.
Add a variant of define_property macro to define bit type property.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
rust/qemu-api/src/qdev.rs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/rust/qemu-api/src/qdev.rs b/rust/qemu-api/src/qdev.rs
index b348f2f4ce71..32740c873604 100644
--- a/rust/qemu-api/src/qdev.rs
+++ b/rust/qemu-api/src/qdev.rs
@@ -166,6 +166,18 @@ fn class_init(dc: &mut DeviceClass) {
#[macro_export]
macro_rules! define_property {
+ ($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, bit =
$bitnr:expr, default = $defval:expr$(,)*) => {
+ $crate::bindings::Property {
+ // use associated function syntax for type checking
+ name: ::std::ffi::CStr::as_ptr($name),
+ info: $prop,
+ offset: $crate::offset_of!($state, $field) as isize,
+ bitnr: $bitnr,
+ set_default: true,
+ defval: $crate::bindings::Property__bindgen_ty_1 { u: $defval as
u64 },
+ ..$crate::zeroable::Zeroable::ZERO
+ }
+ };
($name:expr, $state:ty, $field:ident, $prop:expr, $type:ty, default =
$defval:expr$(,)*) => {
$crate::bindings::Property {
// use associated function syntax for type checking
--
2.34.1
- [PATCH 00/10] rust: Add HPET timer device, Zhao Liu, 2025/01/25
- [PATCH 02/10] rust/qdev: add the macro to define bit property,
Zhao Liu <=
- [PATCH 03/10] rust/irq: Add a helper to convert [InterruptSource] to [*mut IRQState], Zhao Liu, 2025/01/25
- [PATCH 04/10] rust: add bindings for gpio_{in|out} initialization, Zhao Liu, 2025/01/25
- [PATCH 05/10] rust: add bindings for memattrs, Zhao Liu, 2025/01/25
- [PATCH 01/10] i386/fw_cfg: move hpet_cfg definition to hpet.c, Zhao Liu, 2025/01/25
- [PATCH 06/10] rust: add bindings for timer, Zhao Liu, 2025/01/25
- [PATCH 07/10] rust/timer/hpet: define hpet_cfg, Zhao Liu, 2025/01/25