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 <[email protected]> --- 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
