aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-12-18 12:31:46 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2025-03-06 12:44:47 +0100
commitaa50bc4fb9d4fc1dc027c4d70babe0acb6c09971 (patch)
treed71289f1228ea4173b7bd6d63c5d78289d9d1198
parent9b642097d6b793c161c3d1c540dd19a66e02100f (diff)
downloadqemu-aa50bc4fb9d4fc1dc027c4d70babe0acb6c09971.zip
qemu-aa50bc4fb9d4fc1dc027c4d70babe0acb6c09971.tar.gz
qemu-aa50bc4fb9d4fc1dc027c4d70babe0acb6c09971.tar.bz2
rust: pl011: pass around registers::Data
The values stored in the Fifo are instances of the bitfield-struct registers::Data. Convert as soon as possible the value written into DR, and always refer to the bitfield struct; it's generally cleaner other than PL011State::receive having to do a double conversion u8=>u32=>registers::Data. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--rust/hw/char/pl011/src/device.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index 4e282bc..af93ae8 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -234,7 +234,7 @@ impl PL011Registers {
match offset {
DR => {
// interrupts always checked
- let _ = self.loopback_tx(value);
+ let _ = self.loopback_tx(value.into());
self.int_level |= Interrupt::TX.0;
return true;
}
@@ -301,7 +301,7 @@ impl PL011Registers {
#[inline]
#[must_use]
- fn loopback_tx(&mut self, value: u32) -> bool {
+ fn loopback_tx(&mut self, value: registers::Data) -> bool {
// Caveat:
//
// In real hardware, TX loopback happens at the serial-bit level
@@ -370,7 +370,7 @@ impl PL011Registers {
}
fn loopback_break(&mut self, enable: bool) -> bool {
- enable && self.loopback_tx(registers::Data::BREAK.into())
+ enable && self.loopback_tx(registers::Data::BREAK)
}
fn set_read_trigger(&mut self) {
@@ -429,11 +429,11 @@ impl PL011Registers {
}
#[must_use]
- pub fn put_fifo(&mut self, value: u32) -> bool {
+ pub fn put_fifo(&mut self, value: registers::Data) -> bool {
let depth = self.fifo_depth();
assert!(depth > 0);
let slot = (self.read_pos + self.read_count) & (depth - 1);
- self.read_fifo[slot] = registers::Data::from(value);
+ self.read_fifo[slot] = value;
self.read_count += 1;
self.flags.set_receive_fifo_empty(false);
if self.read_count == depth {
@@ -578,7 +578,8 @@ impl PL011State {
return;
}
let mut regs = self.regs.borrow_mut();
- let update_irq = !regs.loopback_enabled() && regs.put_fifo(buf[0].into());
+ let c: u32 = buf[0].into();
+ let update_irq = !regs.loopback_enabled() && regs.put_fifo(c.into());
// Release the BqlRefCell before calling self.update()
drop(regs);
@@ -591,7 +592,7 @@ impl PL011State {
let mut update_irq = false;
let mut regs = self.regs.borrow_mut();
if event == Event::CHR_EVENT_BREAK && !regs.loopback_enabled() {
- update_irq = regs.put_fifo(registers::Data::BREAK.into());
+ update_irq = regs.put_fifo(registers::Data::BREAK);
}
// Release the BqlRefCell before calling self.update()
drop(regs);