[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/48] rust: pl011: extract CharBackend receive logic into a separ
From: |
Paolo Bonzini |
Subject: |
[PULL 39/48] rust: pl011: extract CharBackend receive logic into a separate function |
Date: |
Fri, 24 Jan 2025 10:44:33 +0100 |
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>
---
rust/hw/char/pl011/src/device.rs | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index 58b54547336..de5110038a5 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -6,7 +6,7 @@
use std::{
ffi::CStr,
ops::ControlFlow,
- os::raw::{c_int, c_uint, c_void},
+ os::raw::{c_int, c_void},
};
use qemu_api::{
@@ -488,6 +488,12 @@ pub fn can_receive(&self) -> bool {
self.read_count < self.fifo_depth()
}
+ pub fn receive(&mut self, ch: u32) {
+ if !self.loopback_enabled() {
+ self.put_fifo(ch)
+ }
+ }
+
pub fn event(&mut self, event: QEMUChrEvent) {
if event == QEMUChrEvent::CHR_EVENT_BREAK && !self.loopback_enabled() {
self.put_fifo(registers::Data::BREAK.into());
@@ -513,7 +519,7 @@ pub fn fifo_depth(&self) -> u32 {
1
}
- pub fn put_fifo(&mut self, value: c_uint) {
+ pub fn put_fifo(&mut self, value: u32) {
let depth = self.fifo_depth();
assert!(depth > 0);
let slot = (self.read_pos + self.read_count) & (depth - 1);
@@ -622,12 +628,9 @@ pub fn write(&mut self, offset: hwaddr, value: u64) {
pub unsafe extern "C" fn pl011_receive(opaque: *mut c_void, buf: *const u8,
size: c_int) {
let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
unsafe {
- if state.as_ref().loopback_enabled() {
- return;
- }
if size > 0 {
debug_assert!(!buf.is_null());
- state.as_mut().put_fifo(c_uint::from(buf.read_volatile()))
+ state.as_mut().receive(u32::from(buf.read_volatile()));
}
}
}
--
2.48.1
- [PULL 48/48] rust: qemu-api: add sub-subclass to the integration tests, (continued)
- [PULL 48/48] rust: qemu-api: add sub-subclass to the integration tests, Paolo Bonzini, 2025/01/24
- [PULL 21/48] rust/qdev: Make REALIZE safe, Paolo Bonzini, 2025/01/24
- [PULL 45/48] rust: pl011: drop use of ControlFlow, Paolo Bonzini, 2025/01/24
- [PULL 40/48] rust: pl011: pull interrupt updates out of read/write ops, Paolo Bonzini, 2025/01/24
- [PULL 32/48] rust: pl011: switch vmstate to new-style macros, Paolo Bonzini, 2025/01/24
- [PULL 38/48] rust: pl011: extract conversion to RegisterOffset, Paolo Bonzini, 2025/01/24
- [PULL 47/48] rust/zeroable: Implement Zeroable with const_zero macro, Paolo Bonzini, 2025/01/24
- [PULL 27/48] rust: vmstate: add varray support to vmstate_of!, Paolo Bonzini, 2025/01/24
- [PULL 28/48] rust: vmstate: implement Zeroable for VMStateField, Paolo Bonzini, 2025/01/24
- [PULL 31/48] rust: qemu_api: add vmstate_struct, Paolo Bonzini, 2025/01/24
- [PULL 39/48] rust: pl011: extract CharBackend receive logic into a separate function,
Paolo Bonzini <=
- [PULL 44/48] rust: pl011: pull device-specific code out of MemoryRegionOps callbacks, Paolo Bonzini, 2025/01/24
- [PULL 33/48] rust: vmstate: remove translation of C vmstate macros, Paolo Bonzini, 2025/01/24
- [PULL 41/48] rust: pl011: extract PL011Registers, Paolo Bonzini, 2025/01/24
- [PULL 46/48] rust: qdev: make reset take a shared reference, Paolo Bonzini, 2025/01/24
- Re: [PULL 00/48] i386, rust changes for 2024-01-24, Stefan Hajnoczi, 2025/01/24
- [PULL 00/48] i386, rust changes for 2024-01-24, Paolo Bonzini, 2025/01/28