mbox series

[00/10] rust: pl011: correctly use interior mutability

Message ID 20250117092657.1051233-1-pbonzini@redhat.com (mailing list archive)
Headers show
Series rust: pl011: correctly use interior mutability | expand

Message

Paolo Bonzini Jan. 17, 2025, 9:26 a.m. UTC
QOM devices are aliased from the moment that they are added to the
QOM tree, and therefore must not use &mut.  This has been a known
issue since the beginning of the Rust in QEMU project, and since
then a solution was developed in the form of BqlCell and BqlRefCell.

This series moves the MMIO code and registers from PL011State to
a new struct PL011Registers, which is wrapped with BqlRefCell.
This also allows to remove device-specific code from the device's
MemoryRegionOps callbacks, paving the way for MemoryRegionOps
bindings.

I am making this series a prerequisite to the usage of Resettable,
because it allows reset to reset take a shared reference to the
device.  Thus the Resettable implementation will not have to
temporarily take a mut reference.

Paolo


Paolo Bonzini (10):
  rust: pl011: remove unnecessary "extern crate"
  rust: pl011: hide unnecessarily "pub" items from outside pl011::device
  rust: pl011: extract conversion to RegisterOffset
  rust: pl011: extract CharBackend receive logic into a separate function
  rust: pl011: pull interrupt updates out of read/write ops
  rust: pl011: extract PL011Registers
  rust: pl011: wrap registers with BqlRefCell
  rust: pl011: remove duplicate definitions
  rust: pl011: pull device-specific code out of MemoryRegionOps callbacks
  rust: qdev: make reset take a shared reference

 rust/hw/char/pl011/src/device.rs       | 458 ++++++++++++++-----------
 rust/hw/char/pl011/src/device_class.rs |  52 +--
 rust/hw/char/pl011/src/lib.rs          |  61 ++--
 rust/hw/char/pl011/src/memory_ops.rs   |  23 +-
 rust/qemu-api/src/qdev.rs              |   2 +-
 5 files changed, 314 insertions(+), 282 deletions(-)