567c0c41 | 13-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011, qemu_api tests: do not use ClassInitImpl
Outside the qemu_api crate, orphan rules make the usage of ClassInitImpl unwieldy. Now that it is optional, do not use it.
For PL011Class, thi
rust: pl011, qemu_api tests: do not use ClassInitImpl
Outside the qemu_api crate, orphan rules make the usage of ClassInitImpl unwieldy. Now that it is optional, do not use it.
For PL011Class, this makes it easier to provide a PL011Impl trait similar to the ones in the qemu_api crate. The device id consts are moved there.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
4551f342 | 12-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qom: add ObjectImpl::CLASS_INIT
As shown in the PL011 device, the orphan rules required a manual implementation of ClassInitImpl for anything not in the qemu_api crate; this gets in the way of
rust: qom: add ObjectImpl::CLASS_INIT
As shown in the PL011 device, the orphan rules required a manual implementation of ClassInitImpl for anything not in the qemu_api crate; this gets in the way of moving system emulation-specific code (including DeviceClass, which as a blanket ClassInitImpl<DeviceClass> implementation) into its own crate.
Make ClassInitImpl optional, at the cost of having to specify the CLASS_INIT member by hand in every implementation of ObjectImpl. The next commits will get rid of it, replacing all the "impl<T> ClassInitImpl<Class> for T" blocks with a generic class_init<T> method on Class.
Right now the definition is always the same, but do not provide a default as that will not be true once ClassInitImpl goes away.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
3212da00 | 12-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: add SysBusDeviceImpl
The only function, right now, is to ensure that anything with a SysBusDeviceClass class is a SysBusDevice.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paol
rust: add SysBusDeviceImpl
The only function, right now, is to ensure that anything with a SysBusDeviceClass class is a SysBusDevice.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
c48700e8 | 18-Feb-2025 |
Zhao Liu <zhao1.liu@intel.com> |
rust: prefer importing std::ptr over core::ptr
The std::ptr is same as core::ptr, but std has already been used in many cases and there's no need to choose non-std library.
So, use std::ptr directl
rust: prefer importing std::ptr over core::ptr
The std::ptr is same as core::ptr, but std has already been used in many cases and there's no need to choose non-std library.
So, use std::ptr directly to make the used ptr library as consistent as possible.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250218080835.3341082-1-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
7630ca2a | 10-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: convert pl011_create to safe Rust
Not a major change but, as a small but significant step in creating qdev bindings, show how pl011_create can be written without "unsafe" calls (apart f
rust: pl011: convert pl011_create to safe Rust
Not a major change but, as a small but significant step in creating qdev bindings, show how pl011_create can be written without "unsafe" calls (apart from converting pointers to references).
This also provides a starting point for creating Error** bindings.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
a22bd55f | 03-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: chardev, qdev: add bindings to qdev_prop_set_chr
Because the argument to the function is an Owned<Chardev>, this also adds an ObjectType implementation to Chardev.
Reviewed-by: Zhao Liu <zhao
rust: chardev, qdev: add bindings to qdev_prop_set_chr
Because the argument to the function is an Owned<Chardev>, this also adds an ObjectType implementation to Chardev.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
590faa03 | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: bindings for MemoryRegionOps
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
5472a38c | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: switch from legacy reset to Resettable
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
201ef001 | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: add clock creation
Add a Rust version of qdev_init_clock_in, which can be used in instance_init. There are a couple differences with the C version:
- in Rust the object keeps its own r
rust: qdev: add clock creation
Add a Rust version of qdev_init_clock_in, which can be used in instance_init. There are a couple differences with the C version:
- in Rust the object keeps its own reference to the clock (in addition to the one embedded in the NamedClockList), and the reference is dropped automatically by instance_finalize(); this is encoded in the signature of DeviceClassMethods::init_clock_in, which makes the lifetime of the clock independent of that of the object it holds. This goes unnoticed in the C version and is due to the existence of aliases.
- also, anything that happens during instance_init uses the pinned_init framework to operate on a partially initialized object, and is done through class methods (i.e. through DeviceClassMethods rather than DeviceMethods) because the device does not exist yet. Therefore, Rust code *must* create clocks from instance_init, which is stricter than C.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
ec3eba98 | 31-Oct-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qom: add object creation functionality
The basic object lifecycle test can now be implemented using safe code!
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzi
rust: qom: add object creation functionality
The basic object lifecycle test can now be implemented using safe code!
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
9955093b | 07-Feb-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: use default set of lints
Being the first crate added to QEMU, pl011 has a rather restrictive Clippy setup. This can be sometimes a bit too heavy on its suggestions, for example
error:
rust: pl011: use default set of lints
Being the first crate added to QEMU, pl011 has a rather restrictive Clippy setup. This can be sometimes a bit too heavy on its suggestions, for example
error: this could be a `const fn` --> hw/char/pl011/src/device.rs:382:5 | 382 | / fn set_read_trigger(&mut self) { 383 | | self.read_trigger = 1; 384 | | } | |_____^
Just use the standard set that is present in rust/Cargo.toml, with just a small adjustment to allow upper case acronyms which are used for register names.
Reported-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
669fab6a | 27-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: include rust_version in Cargo.toml
Tell clippy the minimum supported Rust version for QEMU.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
f2613789 | 27-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: remove unnecessary Cargo.toml metadata
Some items of Cargo.toml (readme, homepage, repository) are only present because of clippy::cargo warnings being enabled in rust/hw/char/pl011/src/lib.rs
rust: remove unnecessary Cargo.toml metadata
Some items of Cargo.toml (readme, homepage, repository) are only present because of clippy::cargo warnings being enabled in rust/hw/char/pl011/src/lib.rs. But these items are not particularly useful and would be all the same for all Cargo.toml files in the QEMU workspace. Clean them up.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
af7edb1d | 02-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: qdev: make reset take a shared reference
Because register reset is within a borrow_mut() call, reset does not need anymore a mut reference to the PL011State.
Reviewed-by: Zhao Liu <zhao1.liu@
rust: qdev: make reset take a shared reference
Because register reset is within a borrow_mut() call, reset does not need anymore a mut reference to the PL011State.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
20bcc96f | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: drop use of ControlFlow
It is a poor match for what the code is doing, anyway.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
b3a29b3d | 17-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: pull device-specific code out of MemoryRegionOps callbacks
read() can now return a simple u64.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat
rust: pl011: pull device-specific code out of MemoryRegionOps callbacks
read() can now return a simple u64.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
c44818a5 | 02-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: remove duplicate definitions
Unify the "Interrupt" enum and the "INT_*" constants with a struct that contains the bits. The "int_level" and "int_enabled" fields could use a crate such
rust: pl011: remove duplicate definitions
Unify the "Interrupt" enum and the "INT_*" constants with a struct that contains the bits. The "int_level" and "int_enabled" fields could use a crate such as "bitflags".
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
a1ab4eed | 24-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: wrap registers with BqlRefCell
This is a step towards making memory ops use a shared reference to the device type; it's not yet possible due to the calls to character device functions.
rust: pl011: wrap registers with BqlRefCell
This is a step towards making memory ops use a shared reference to the device type; it's not yet possible due to the calls to character device functions.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
49bfe63f | 24-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: extract PL011Registers
Pull all the mutable fields of PL011State into a separate struct.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
ab6b6a8a | 24-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: pull interrupt updates out of read/write ops
qemu_irqs are not part of the vmstate, therefore they will remain in PL011State. Update them if needed after regs_read()/regs_write().
App
rust: pl011: pull interrupt updates out of read/write ops
qemu_irqs are not part of the vmstate, therefore they will remain in PL011State. Update them if needed after regs_read()/regs_write().
Apply #[must_use] to functions that return whether the interrupt state could have changed, so that it's harder to forget the call to update().
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
13761277 | 06-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: extract CharBackend receive logic into a separate function
Prepare for moving all references to the registers and the FIFO into a separate struct.
Reviewed-by: Zhao Liu <zhao1.liu@inte
rust: pl011: extract CharBackend receive logic into a separate function
Prepare for moving all references to the registers and the FIFO into a separate struct.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
6d314cc0 | 10-Dec-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: extract conversion to RegisterOffset
As an added bonus, this also makes the new function return u32 instead of u64, thus factoring some casts into a single place.
Reviewed-by: Zhao Liu
rust: pl011: extract conversion to RegisterOffset
As an added bonus, this also makes the new function return u32 instead of u64, thus factoring some casts into a single place.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
d1f27ae9 | 14-Nov-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: hide unnecessarily "pub" items from outside pl011::device
The only public interfaces for pl011 are TYPE_PL011 and pl011_create. Remove pub from everything else.
Note: the "allow(dead_c
rust: pl011: hide unnecessarily "pub" items from outside pl011::device
The only public interfaces for pl011 are TYPE_PL011 and pl011_create. Remove pub from everything else.
Note: the "allow(dead_code)" is removed later.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
efe5719c | 12-Nov-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: pl011: remove unnecessary "extern crate"
Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
7d052039 | 23-Jan-2025 |
Paolo Bonzini <pbonzini@redhat.com> |
rust: prefer NonNull::new to assertions
Do not use new_unchecked; the effect is the same, but the code is easier to read and unsafe regions become smaller. Likewise, NonNull::new can be used instead
rust: prefer NonNull::new to assertions
Do not use new_unchecked; the effect is the same, but the code is easier to read and unsafe regions become smaller. Likewise, NonNull::new can be used instead of assertion and followed by as_ref() or as_mut() instead of dereferencing the pointer.
Suggested-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|