summary refs log tree commit diff stats
path: root/rust/qemu-api/src/zeroable.rs (follow)
Commit message (Collapse)AuthorAgeFilesLines
* rust: chardev: provide basic bindings to character devicesPaolo Bonzini2025-03-061-0/+1
| | | | | | | | | | | | | Most of the character device API is pretty simple, with "0 or -errno" or "number of bytes or -errno" as the convention for return codes. Add safe wrappers for the API to the CharBackend bindgen-generated struct. The API is not complete, but it covers the parts that are used by the PL011 device, plus qemu_chr_fe_write which is needed to implement the standard library Write trait. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: fix doctestsPaolo Bonzini2025-02-131-1/+1
| | | | | | Doctests were not being run by CI, and have broken. Fix them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: qemu_api: add a documentation header for all modulesPaolo Bonzini2025-02-131-0/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust/timer/hpet: define hpet_fw_cfgZhao Liu2025-02-131-2/+4
| | | | | | | | | | | | | | | | Define HPETFwEntry structure with the same memory layout as hpet_fw_entry in C. Further, define the global hpet_cfg variable in Rust which is the same as the C version. This hpet_cfg variable in Rust will replace the C version one and allows both Rust code and C code to access it. The Rust version of hpet_cfg is self-contained, avoiding unsafe access to C code. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250210030051.2562726-8-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: add bindings for memattrsZhao Liu2025-02-131-0/+1
| | | | | | | | | | | | | The MemTxAttrs structure contains bitfield members, and bindgen is unable to generate an equivalent macro definition for MEMTXATTRS_UNSPECIFIED. Therefore, manually define a global constant variable MEMTXATTRS_UNSPECIFIED to support calls from Rust code. Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250125125137.1223277-6-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: bindings for MemoryRegionOpsPaolo Bonzini2025-02-131-0/+1
| | | | | Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust/zeroable: Implement Zeroable with const_zero macroZhao Liu2025-01-281-76/+61
| | | | | | | | | | | | | The `const_zero` crate provides a nice macro to zero type-specific constants, which doesn't need to enumerates the fields one by one. Introduce the `const_zero` macro to QEMU (along with its documentation), and use it to simplify the implementation of `Zeroable` trait. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Link: https://lore.kernel.org/r/20250123163143.679841-1-zhao1.liu@intel.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: vmstate: implement Zeroable for VMStateFieldPaolo Bonzini2025-01-231-0/+31
| | | | | | | | This shortens a bit the constants. Do not bother using it in the vmstate macros since most of them will go away soon. Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: fix doc test syntaxPaolo Bonzini2024-12-101-3/+3
| | | | | | | Allow "cargo test --doc" to pass. Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: do not use MaybeUninit::zeroed()Paolo Bonzini2024-11-051-14/+77
| | | | | | | | | | | | MaybeUninit::zeroed() is handy but is not available as a "const" function until Rust 1.75.0. Remove the default implementation of Zeroable::ZERO, and write by hand the definitions for those types that need it. It may be possible to add automatic implementation of the trait, via a procedural macro and/or a trick similar to offset_of!, but do it the easy way for now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rust: provide safe wrapper for MaybeUninit::zeroed()Paolo Bonzini2024-11-051-0/+23
MaybeUninit::zeroed() is handy, but it introduces unsafe (and has a pretty heavy syntax in general). Introduce a trait that provides the same functionality while staying within safe Rust. In addition, MaybeUninit::zeroed() is not available as a "const" function until Rust 1.75.0, so this also prepares for having handwritten implementations of the trait until we can assume that version. Reviewed-by: Junjie Mao <junjie.mao@hotmail.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>