All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jack Wang <163wangjack@gmail.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Alistair Francis <alistair@alistair23.me>,
	Fabiano Rosas <farosas@suse.de>,
	Laurent Vivier <lvivier@redhat.com>,
	qemu-arm@nongnu.org, qemu-rust@nongnu.org, caojunze424@gmail.com,
	Jack Wang <163wangjack@gmail.com>
Subject: [RFC PATCH v1 2/5] rust: add hw/gpio crate to the workspace
Date: Sun, 26 Jul 2026 22:51:16 +0800	[thread overview]
Message-ID: <20260726145119.19881-3-163wangjack@gmail.com> (raw)
In-Reply-To: <20260726145119.19881-1-163wangjack@gmail.com>

Register the new stm32f1xx_gpio crate in the Rust workspace and hook its
meson build and Kconfig into rust/hw so it is compiled into the softmmu
build when Rust is enabled.

Signed-off-by: Jack Wang <163wangjack@gmail.com>
---
 rust/Cargo.lock          | 17 ++++++++++++-
 rust/Cargo.toml          | 18 ++++++++++++++
 rust/hw/Kconfig          |  1 +
 rust/hw/gpio/Cargo.toml  | 28 +++++++++++++++++++++
 rust/hw/gpio/meson.build | 54 ++++++++++++++++++++++++++++++++++++++++
 rust/hw/meson.build      |  1 +
 6 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 rust/hw/gpio/Cargo.toml
 create mode 100644 rust/hw/gpio/meson.build

diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index cbb3ca15f7..2daadaaf15 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -184,7 +184,6 @@ dependencies = [
  "glib-sys",
  "migration-sys",
  "qom-sys",
- "system-sys",
  "util-sys",
 ]
 
@@ -387,6 +386,21 @@ version = "1.15.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
 
+[[package]]
+name = "stm32f1xx_gpio"
+version = "0.1.0"
+dependencies = [
+ "bql",
+ "common",
+ "glib-sys",
+ "hwcore",
+ "migration",
+ "qom",
+ "system",
+ "trace",
+ "util",
+]
+
 [[package]]
 name = "syn"
 version = "2.0.104"
@@ -431,6 +445,7 @@ version = "0.1.0"
 dependencies = [
  "common",
  "glib-sys",
+ "hwcore-sys",
  "migration-sys",
  "qom-sys",
  "util-sys",
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 0d24eb84e1..7661205d3c 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -1,9 +1,27 @@
 [workspace]
 resolver = "2"
 members = [
+    "bindings/chardev-sys",
+    "bindings/hwcore-sys",
+    "bindings/migration-sys",
+    "bindings/qom-sys",
+    "bindings/system-sys",
+    "bindings/util-sys",
+    "bits",
+    "bql",
+    "chardev",
+    "common",
     "hw/char/pl011",
+    "hw/core",
+    "hw/gpio",
     "hw/timer/hpet",
+    "migration",
+    "qemu-macros",
+    "qom",
+    "system",
     "tests",
+    "trace",
+    "util",
 ]
 
 [workspace.package]
diff --git a/rust/hw/Kconfig b/rust/hw/Kconfig
index 36f92ec028..ba1297ca2d 100644
--- a/rust/hw/Kconfig
+++ b/rust/hw/Kconfig
@@ -1,3 +1,4 @@
 # devices Kconfig
 source char/Kconfig
+source gpio/Kconfig
 source timer/Kconfig
diff --git a/rust/hw/gpio/Cargo.toml b/rust/hw/gpio/Cargo.toml
new file mode 100644
index 0000000000..5c6eade306
--- /dev/null
+++ b/rust/hw/gpio/Cargo.toml
@@ -0,0 +1,28 @@
+[package]
+name = "stm32f1xx_gpio"
+version = "0.1.0"
+description = "STM32F1xx GPIO device model for QEMU"
+resolver = "2"
+publish = false
+
+edition.workspace = true
+homepage.workspace = true
+license.workspace = true
+repository.workspace = true
+rust-version.workspace = true
+
+[dependencies]
+glib-sys.workspace = true
+
+# QEMU Rust foundations crate
+common = { path = "../../common" }
+util = { path = "../../util" }
+bql = { path = "../../bql" }
+migration = { path = "../../migration" }
+qom = { path = "../../qom" }
+system = { path = "../../system" }
+hwcore = { path = "../../hw/core" }
+trace = { path = "../../trace" }
+
+[lints]
+workspace = true
diff --git a/rust/hw/gpio/meson.build b/rust/hw/gpio/meson.build
new file mode 100644
index 0000000000..35da59991f
--- /dev/null
+++ b/rust/hw/gpio/meson.build
@@ -0,0 +1,54 @@
+_libstm32f1xx_gpio_rs = static_library(
+  'stm32f1xx_gpio',
+  files(
+    'src/lib.rs',
+    'src/gpio.rs',
+    'src/bindings.rs',
+  ),
+  override_options: ['rust_std=2021', 'build.rust_std=2021'],
+  rust_abi: 'rust',
+  link_with: [
+    _util_rs,
+    _migration_rs,
+    _bql_rs,
+    _qom_rs,
+    _system_rs,
+    _hwcore_rs,
+    _trace_rs,
+  ],
+  dependencies: [
+    common_rs,
+    glib_sys_rs,
+  ],
+)
+
+rust_devices_ss.add(when: 'CONFIG_X_STM32F1XX_GPIO_RUST', if_true: [declare_dependency(
+  link_whole: [_libstm32f1xx_gpio_rs],
+  variables: {'crate': 'stm32f1xx_gpio'},
+)])
+
+# Dependency usable by the in-crate integration test below.
+stm32f1xx_gpio_rs = declare_dependency(link_with: [_libstm32f1xx_gpio_rs],
+  dependencies: [common_rs, qom_rs, hwcore_rs, bql_rs, migration_rs,
+                 system_rs, util_rs])
+
+# Native Rust unit tests for the pure register logic (GpioRegisters). These
+# need no qtest and no machine boot: they construct GpioRegisters directly and
+# only require the BQL mock (bql::start_test). Run with:
+#   meson test --suite rust rust-stm32f1xx-gpio-integration
+test('rust-stm32f1xx-gpio-integration',
+    executable(
+        'rust-stm32f1xx-gpio-integration',
+        files('tests/tests.rs'),
+        override_options: ['rust_std=2021', 'build.rust_std=2021'],
+        rust_args: ['--test'],
+        install: false,
+        dependencies: [stm32f1xx_gpio_rs, common_rs, qom_rs, hwcore_rs,
+                       bql_rs, migration_rs, system_rs, util_rs]),
+    args: [
+        '--test', '--test-threads', '1',
+        '--format', 'pretty',
+    ],
+    protocol: 'rust',
+    suite: ['unit', 'rust'])
+
diff --git a/rust/hw/meson.build b/rust/hw/meson.build
index 9749d4adfc..d6b273170e 100644
--- a/rust/hw/meson.build
+++ b/rust/hw/meson.build
@@ -1,2 +1,3 @@
 subdir('char')
+subdir('gpio')
 subdir('timer')
-- 
2.53.0



  parent reply	other threads:[~2026-07-26 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 14:51 [RFC PATCH v1 0/5] hw/gpio: STM32F1xx GPIO controller in Rust Jack Wang
2026-07-26 14:51 ` [RFC PATCH v1 1/5] hw/gpio: add stm32f1xx GPIO device model (Rust) Jack Wang
2026-07-26 14:51 ` Jack Wang [this message]
2026-07-26 14:51 ` [RFC PATCH v1 3/5] hw/arm/stm32f103: instantiate and map GPIO ports Jack Wang
2026-07-26 14:51 ` [RFC PATCH v1 4/5] tests/qtest: add stm32f103 GPIO test Jack Wang
2026-07-26 14:51 ` [RFC PATCH v1 5/5] rust/hw/gpio: add native unit tests Jack Wang

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=20260726145119.19881-3-163wangjack@gmail.com \
    --to=163wangjack@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=caojunze424@gmail.com \
    --cc=farosas@suse.de \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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.