qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/5] rust/hw: Add the I2C and the first GPIO device
@ 2025-10-28 10:18 chenmiao
  2025-11-25 10:47 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: chenmiao @ 2025-10-28 10:18 UTC (permalink / raw)
  To: zhao1.liu, pbonzini, manos.pitsidianakis, richard.henderson,
	philmd
  Cc: chao.liu, qemu-rust, qemu-devel, hust-os-kernel-patches,
	Chen Miao

We have implemented I2C and the first GPIO device in Rust for QEMU.
Additionally, in the respective patches, we have shared our insights and
experiences regarding the use of Rust for device modeling within QEMU.

1. The first patch implements the BusState for the I2CBus infrastructure.
2. The second patch implements the I2CBus and I2CSlave infrastructure, along
   with a discussion of the challenges encountered during the implementation.
3. The third patch moves the struct definition of the PCF8574 to the
   corresponding header file.
4. The fourth patch provides a set of necessary helper functions for the PCF8574
   GPIO device.
5. The fifth patch implements the PCF8574 GPIO device, along with a discussion
   of the issues and considerations addressed during the implementation.

Regarding this series of patches, we have found that Rust for QEMU is indeed
still not mature enough and requires continuous iteration. Additionally, the
lack of basic documentation also needs to be addressed. In this regard, I hope
our team(HUST OpenAtom Open Source Club) can contribute to the documentation
efforts for Rust for QEMU.

Link: https://groups.google.com/g/hust-os-kernel-patches/c/z7vHWg3xvDc

Signed-off-by: Chao Liu <chao.liu@openatom.club>
Signed-off-by: Chen Miao <chenmiao@openatom.club>

---
Changes in V2:
  - According to Zhao's suggestions, some modifications were made to the first
    and second patches respectively, such as changing some bus names, adding
    some Safety comments, and adding callbacks for I2CSlave.
  - While we were making changes to the first PATCH, Chao Liu pointed out that
    the realize function was unnecessary in the bus. After discussion, we
    removed the bus::realize function. Since no other components are currently
    using the bus, we added a TODO comment for clarification.

chenmiao (5):
  rust/hw/core: Add the BusState of rust version
  rust/hw/core: Add rust bindings/funcs for i2c bus
  hw/gpio: Move the pcf8574 struct to header
  rust/hw/core: Provide some interfaces for the GPIO device
  rust/hw/gpio: Add the the first gpio device pcf8574

 hw/gpio/Kconfig                      |   5 +
 hw/gpio/meson.build                  |   2 +-
 hw/gpio/pcf8574.c                    |  32 --
 include/hw/gpio/pcf8574.h            |  36 +++
 rust/Cargo.lock                      |  21 +-
 rust/Cargo.toml                      |   1 +
 rust/hw/Kconfig                      |   1 +
 rust/hw/core/meson.build             |   2 +
 rust/hw/core/src/bus.rs              |  44 +++
 rust/hw/core/src/i2c.rs              | 421 +++++++++++++++++++++++++++
 rust/hw/core/src/irq.rs              |   6 +-
 rust/hw/core/src/lib.rs              |   6 +
 rust/hw/core/src/qdev.rs             |  12 +-
 rust/hw/core/wrapper.h               |   1 +
 rust/hw/gpio/Kconfig                 |   2 +
 rust/hw/gpio/meson.build             |   1 +
 rust/hw/gpio/pcf8574/Cargo.toml      |  31 ++
 rust/hw/gpio/pcf8574/build.rs        |   1 +
 rust/hw/gpio/pcf8574/meson.build     |  50 ++++
 rust/hw/gpio/pcf8574/src/bindings.rs |  29 ++
 rust/hw/gpio/pcf8574/src/device.rs   | 180 ++++++++++++
 rust/hw/gpio/pcf8574/src/lib.rs      |   4 +
 rust/hw/gpio/pcf8574/wrapper.h       |  51 ++++
 rust/hw/meson.build                  |   1 +
 24 files changed, 902 insertions(+), 38 deletions(-)
 create mode 100644 rust/hw/core/src/bus.rs
 create mode 100644 rust/hw/core/src/i2c.rs
 create mode 100644 rust/hw/gpio/Kconfig
 create mode 100644 rust/hw/gpio/meson.build
 create mode 100644 rust/hw/gpio/pcf8574/Cargo.toml
 create mode 120000 rust/hw/gpio/pcf8574/build.rs
 create mode 100644 rust/hw/gpio/pcf8574/meson.build
 create mode 100644 rust/hw/gpio/pcf8574/src/bindings.rs
 create mode 100644 rust/hw/gpio/pcf8574/src/device.rs
 create mode 100644 rust/hw/gpio/pcf8574/src/lib.rs
 create mode 100644 rust/hw/gpio/pcf8574/wrapper.h

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH v2 0/5] rust/hw: Add the I2C and the first GPIO device
  2025-10-28 10:18 [RFC PATCH v2 0/5] rust/hw: Add the I2C and the first GPIO device chenmiao
@ 2025-11-25 10:47 ` Paolo Bonzini
  2025-11-26  1:31   ` Chen Miao
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2025-11-25 10:47 UTC (permalink / raw)
  To: chenmiao
  Cc: zhao1.liu, manos.pitsidianakis, richard.henderson, philmd,
	chao.liu, qemu-rust, qemu-devel, hust-os-kernel-patches

On Tue, Oct 28, 2025 at 11:18 AM chenmiao <chenmiao@openatom.club> wrote:
>
> We have implemented I2C and the first GPIO device in Rust for QEMU.
> Additionally, in the respective patches, we have shared our insights and
> experiences regarding the use of Rust for device modeling within QEMU.
>
> 1. The first patch implements the BusState for the I2CBus infrastructure.
> 2. The second patch implements the I2CBus and I2CSlave infrastructure, along
>    with a discussion of the challenges encountered during the implementation.
> 3. The third patch moves the struct definition of the PCF8574 to the
>    corresponding header file.
> 4. The fourth patch provides a set of necessary helper functions for the PCF8574
>    GPIO device.
> 5. The fifth patch implements the PCF8574 GPIO device, along with a discussion
>    of the issues and considerations addressed during the implementation.
>
> Regarding this series of patches, we have found that Rust for QEMU is indeed
> still not mature enough and requires continuous iteration. Additionally, the
> lack of basic documentation also needs to be addressed. In this regard, I hope
> our team(HUST OpenAtom Open Source Club) can contribute to the documentation
> efforts for Rust for QEMU.
>
> Link: https://groups.google.com/g/hust-os-kernel-patches/c/z7vHWg3xvDc
>
> Signed-off-by: Chao Liu <chao.liu@openatom.club>
> Signed-off-by: Chen Miao <chenmiao@openatom.club>

Hi! Are you going to send v3?

Thanks,

Paolo

> ---
> Changes in V2:
>   - According to Zhao's suggestions, some modifications were made to the first
>     and second patches respectively, such as changing some bus names, adding
>     some Safety comments, and adding callbacks for I2CSlave.
>   - While we were making changes to the first PATCH, Chao Liu pointed out that
>     the realize function was unnecessary in the bus. After discussion, we
>     removed the bus::realize function. Since no other components are currently
>     using the bus, we added a TODO comment for clarification.
>
> chenmiao (5):
>   rust/hw/core: Add the BusState of rust version
>   rust/hw/core: Add rust bindings/funcs for i2c bus
>   hw/gpio: Move the pcf8574 struct to header
>   rust/hw/core: Provide some interfaces for the GPIO device
>   rust/hw/gpio: Add the the first gpio device pcf8574
>
>  hw/gpio/Kconfig                      |   5 +
>  hw/gpio/meson.build                  |   2 +-
>  hw/gpio/pcf8574.c                    |  32 --
>  include/hw/gpio/pcf8574.h            |  36 +++
>  rust/Cargo.lock                      |  21 +-
>  rust/Cargo.toml                      |   1 +
>  rust/hw/Kconfig                      |   1 +
>  rust/hw/core/meson.build             |   2 +
>  rust/hw/core/src/bus.rs              |  44 +++
>  rust/hw/core/src/i2c.rs              | 421 +++++++++++++++++++++++++++
>  rust/hw/core/src/irq.rs              |   6 +-
>  rust/hw/core/src/lib.rs              |   6 +
>  rust/hw/core/src/qdev.rs             |  12 +-
>  rust/hw/core/wrapper.h               |   1 +
>  rust/hw/gpio/Kconfig                 |   2 +
>  rust/hw/gpio/meson.build             |   1 +
>  rust/hw/gpio/pcf8574/Cargo.toml      |  31 ++
>  rust/hw/gpio/pcf8574/build.rs        |   1 +
>  rust/hw/gpio/pcf8574/meson.build     |  50 ++++
>  rust/hw/gpio/pcf8574/src/bindings.rs |  29 ++
>  rust/hw/gpio/pcf8574/src/device.rs   | 180 ++++++++++++
>  rust/hw/gpio/pcf8574/src/lib.rs      |   4 +
>  rust/hw/gpio/pcf8574/wrapper.h       |  51 ++++
>  rust/hw/meson.build                  |   1 +
>  24 files changed, 902 insertions(+), 38 deletions(-)
>  create mode 100644 rust/hw/core/src/bus.rs
>  create mode 100644 rust/hw/core/src/i2c.rs
>  create mode 100644 rust/hw/gpio/Kconfig
>  create mode 100644 rust/hw/gpio/meson.build
>  create mode 100644 rust/hw/gpio/pcf8574/Cargo.toml
>  create mode 120000 rust/hw/gpio/pcf8574/build.rs
>  create mode 100644 rust/hw/gpio/pcf8574/meson.build
>  create mode 100644 rust/hw/gpio/pcf8574/src/bindings.rs
>  create mode 100644 rust/hw/gpio/pcf8574/src/device.rs
>  create mode 100644 rust/hw/gpio/pcf8574/src/lib.rs
>  create mode 100644 rust/hw/gpio/pcf8574/wrapper.h
>
> --
> 2.43.0
>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH v2 0/5] rust/hw: Add the I2C and the first GPIO device
  2025-11-25 10:47 ` Paolo Bonzini
@ 2025-11-26  1:31   ` Chen Miao
  0 siblings, 0 replies; 3+ messages in thread
From: Chen Miao @ 2025-11-26  1:31 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: zhao1.liu, manos.pitsidianakis, richard.henderson, philmd,
	chao.liu, qemu-rust, qemu-devel, hust-os-kernel-patches

On 11/25/2025 6:47 PM, Paolo Bonzini wrote:
> On Tue, Oct 28, 2025 at 11:18 AM chenmiao <chenmiao@openatom.club> wrote:
>> We have implemented I2C and the first GPIO device in Rust for QEMU.
>> Additionally, in the respective patches, we have shared our insights and
>> experiences regarding the use of Rust for device modeling within QEMU.
>>
>> 1. The first patch implements the BusState for the I2CBus infrastructure.
>> 2. The second patch implements the I2CBus and I2CSlave infrastructure, along
>>     with a discussion of the challenges encountered during the implementation.
>> 3. The third patch moves the struct definition of the PCF8574 to the
>>     corresponding header file.
>> 4. The fourth patch provides a set of necessary helper functions for the PCF8574
>>     GPIO device.
>> 5. The fifth patch implements the PCF8574 GPIO device, along with a discussion
>>     of the issues and considerations addressed during the implementation.
>>
>> Regarding this series of patches, we have found that Rust for QEMU is indeed
>> still not mature enough and requires continuous iteration. Additionally, the
>> lack of basic documentation also needs to be addressed. In this regard, I hope
>> our team(HUST OpenAtom Open Source Club) can contribute to the documentation
>> efforts for Rust for QEMU.
>>
>> Link: https://groups.google.com/g/hust-os-kernel-patches/c/z7vHWg3xvDc
>>
>> Signed-off-by: Chao Liu <chao.liu@openatom.club>
>> Signed-off-by: Chen Miao <chenmiao@openatom.club>
> Hi! Are you going to send v3?
>
> Thanks,
>
> Paolo

Hello,

I've been a bit busy lately, but I believe we will complete V3 and send it out 
before mid-December.

Regards,

Chen Miao

>
>> ---
>> Changes in V2:
>>    - According to Zhao's suggestions, some modifications were made to the first
>>      and second patches respectively, such as changing some bus names, adding
>>      some Safety comments, and adding callbacks for I2CSlave.
>>    - While we were making changes to the first PATCH, Chao Liu pointed out that
>>      the realize function was unnecessary in the bus. After discussion, we
>>      removed the bus::realize function. Since no other components are currently
>>      using the bus, we added a TODO comment for clarification.
>>
>> chenmiao (5):
>>    rust/hw/core: Add the BusState of rust version
>>    rust/hw/core: Add rust bindings/funcs for i2c bus
>>    hw/gpio: Move the pcf8574 struct to header
>>    rust/hw/core: Provide some interfaces for the GPIO device
>>    rust/hw/gpio: Add the the first gpio device pcf8574
>>
>>   hw/gpio/Kconfig                      |   5 +
>>   hw/gpio/meson.build                  |   2 +-
>>   hw/gpio/pcf8574.c                    |  32 --
>>   include/hw/gpio/pcf8574.h            |  36 +++
>>   rust/Cargo.lock                      |  21 +-
>>   rust/Cargo.toml                      |   1 +
>>   rust/hw/Kconfig                      |   1 +
>>   rust/hw/core/meson.build             |   2 +
>>   rust/hw/core/src/bus.rs              |  44 +++
>>   rust/hw/core/src/i2c.rs              | 421 +++++++++++++++++++++++++++
>>   rust/hw/core/src/irq.rs              |   6 +-
>>   rust/hw/core/src/lib.rs              |   6 +
>>   rust/hw/core/src/qdev.rs             |  12 +-
>>   rust/hw/core/wrapper.h               |   1 +
>>   rust/hw/gpio/Kconfig                 |   2 +
>>   rust/hw/gpio/meson.build             |   1 +
>>   rust/hw/gpio/pcf8574/Cargo.toml      |  31 ++
>>   rust/hw/gpio/pcf8574/build.rs        |   1 +
>>   rust/hw/gpio/pcf8574/meson.build     |  50 ++++
>>   rust/hw/gpio/pcf8574/src/bindings.rs |  29 ++
>>   rust/hw/gpio/pcf8574/src/device.rs   | 180 ++++++++++++
>>   rust/hw/gpio/pcf8574/src/lib.rs      |   4 +
>>   rust/hw/gpio/pcf8574/wrapper.h       |  51 ++++
>>   rust/hw/meson.build                  |   1 +
>>   24 files changed, 902 insertions(+), 38 deletions(-)
>>   create mode 100644 rust/hw/core/src/bus.rs
>>   create mode 100644 rust/hw/core/src/i2c.rs
>>   create mode 100644 rust/hw/gpio/Kconfig
>>   create mode 100644 rust/hw/gpio/meson.build
>>   create mode 100644 rust/hw/gpio/pcf8574/Cargo.toml
>>   create mode 120000 rust/hw/gpio/pcf8574/build.rs
>>   create mode 100644 rust/hw/gpio/pcf8574/meson.build
>>   create mode 100644 rust/hw/gpio/pcf8574/src/bindings.rs
>>   create mode 100644 rust/hw/gpio/pcf8574/src/device.rs
>>   create mode 100644 rust/hw/gpio/pcf8574/src/lib.rs
>>   create mode 100644 rust/hw/gpio/pcf8574/wrapper.h
>>
>> --
>> 2.43.0
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-26  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 10:18 [RFC PATCH v2 0/5] rust/hw: Add the I2C and the first GPIO device chenmiao
2025-11-25 10:47 ` Paolo Bonzini
2025-11-26  1:31   ` Chen Miao

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).